good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
33256837
Commit
33256837
authored
Dec 18, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Fixed refund model
parent
f7287c62
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/state_transition.go
+4
-6
4 additions, 6 deletions
core/state_transition.go
state/state.go
+10
-7
10 additions, 7 deletions
state/state.go
tests/vm/gh_test.go
+4
-4
4 additions, 4 deletions
tests/vm/gh_test.go
with
18 additions
and
17 deletions
core/state_transition.go
+
4
−
6
View file @
33256837
...
@@ -213,13 +213,11 @@ func MakeContract(msg Message, state *state.StateDB) *state.StateObject {
...
@@ -213,13 +213,11 @@ func MakeContract(msg Message, state *state.StateDB) *state.StateObject {
func
(
self
*
StateTransition
)
RefundGas
()
{
func
(
self
*
StateTransition
)
RefundGas
()
{
coinbaseSub
:=
new
(
big
.
Int
)
.
Set
(
self
.
gas
)
coinbaseSub
:=
new
(
big
.
Int
)
.
Set
(
self
.
gas
)
uhalf
:=
new
(
big
.
Int
)
.
Div
(
self
.
GasUsed
(),
ethutil
.
Big2
)
uhalf
:=
new
(
big
.
Int
)
.
Div
(
self
.
GasUsed
(),
ethutil
.
Big2
)
for
addr
,
refs
:=
range
self
.
state
.
Refunds
()
{
for
addr
,
ref
:=
range
self
.
state
.
Refunds
()
{
for
_
,
ref
:=
range
refs
{
coinbaseSub
.
Add
(
self
.
gas
,
ref
)
refund
:=
ethutil
.
BigMin
(
uhalf
,
ref
)
refund
:=
ethutil
.
BigMin
(
uhalf
,
ref
)
coinbaseSub
.
Add
(
self
.
gas
,
refund
)
self
.
state
.
AddBalance
([]
byte
(
addr
),
refund
.
Mul
(
refund
,
self
.
msg
.
GasPrice
()))
self
.
state
.
AddBalance
([]
byte
(
addr
),
refund
.
Mul
(
refund
,
self
.
msg
.
GasPrice
()))
}
}
}
coinbase
,
sender
:=
self
.
Coinbase
(),
self
.
From
()
coinbase
,
sender
:=
self
.
Coinbase
(),
self
.
From
()
coinbase
.
RefundGas
(
coinbaseSub
,
self
.
msg
.
GasPrice
())
coinbase
.
RefundGas
(
coinbaseSub
,
self
.
msg
.
GasPrice
())
...
...
This diff is collapsed.
Click to expand it.
state/state.go
+
10
−
7
View file @
33256837
...
@@ -23,14 +23,14 @@ type StateDB struct {
...
@@ -23,14 +23,14 @@ type StateDB struct {
manifest
*
Manifest
manifest
*
Manifest
refund
map
[
string
]
[]
*
big
.
Int
refund
map
[
string
]
*
big
.
Int
logs
Logs
logs
Logs
}
}
// Create a new state from a given trie
// Create a new state from a given trie
func
New
(
trie
*
trie
.
Trie
)
*
StateDB
{
func
New
(
trie
*
trie
.
Trie
)
*
StateDB
{
return
&
StateDB
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
[]
*
big
.
Int
)}
return
&
StateDB
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
*
big
.
Int
)}
}
}
func
(
self
*
StateDB
)
EmptyLogs
()
{
func
(
self
*
StateDB
)
EmptyLogs
()
{
...
@@ -56,7 +56,10 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
...
@@ -56,7 +56,10 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
}
}
func
(
self
*
StateDB
)
Refund
(
addr
[]
byte
,
gas
*
big
.
Int
)
{
func
(
self
*
StateDB
)
Refund
(
addr
[]
byte
,
gas
*
big
.
Int
)
{
self
.
refund
[
string
(
addr
)]
=
append
(
self
.
refund
[
string
(
addr
)],
gas
)
if
self
.
refund
[
string
(
addr
)]
==
nil
{
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
}
self
.
refund
[
string
(
addr
)]
.
Add
(
self
.
refund
[
string
(
addr
)],
gas
)
}
}
func
(
self
*
StateDB
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
func
(
self
*
StateDB
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
...
@@ -207,7 +210,7 @@ func (self *StateDB) Copy() *StateDB {
...
@@ -207,7 +210,7 @@ func (self *StateDB) Copy() *StateDB {
}
}
for
addr
,
refund
:=
range
self
.
refund
{
for
addr
,
refund
:=
range
self
.
refund
{
state
.
refund
[
addr
]
=
refund
state
.
refund
[
addr
]
=
new
(
big
.
Int
)
.
Set
(
refund
)
}
}
logs
:=
make
(
Logs
,
len
(
self
.
logs
))
logs
:=
make
(
Logs
,
len
(
self
.
logs
))
...
@@ -269,17 +272,17 @@ func (s *StateDB) Sync() {
...
@@ -269,17 +272,17 @@ func (s *StateDB) Sync() {
func
(
self
*
StateDB
)
Empty
()
{
func
(
self
*
StateDB
)
Empty
()
{
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
refund
=
make
(
map
[
string
]
[]
*
big
.
Int
)
self
.
refund
=
make
(
map
[
string
]
*
big
.
Int
)
}
}
func
(
self
*
StateDB
)
Refunds
()
map
[
string
]
[]
*
big
.
Int
{
func
(
self
*
StateDB
)
Refunds
()
map
[
string
]
*
big
.
Int
{
return
self
.
refund
return
self
.
refund
}
}
func
(
self
*
StateDB
)
Update
(
gasUsed
*
big
.
Int
)
{
func
(
self
*
StateDB
)
Update
(
gasUsed
*
big
.
Int
)
{
var
deleted
bool
var
deleted
bool
self
.
refund
=
make
(
map
[
string
]
[]
*
big
.
Int
)
self
.
refund
=
make
(
map
[
string
]
*
big
.
Int
)
for
_
,
stateObject
:=
range
self
.
stateObjects
{
for
_
,
stateObject
:=
range
self
.
stateObjects
{
if
stateObject
.
remove
{
if
stateObject
.
remove
{
...
...
This diff is collapsed.
Click to expand it.
tests/vm/gh_test.go
+
4
−
4
View file @
33256837
...
@@ -77,11 +77,11 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -77,11 +77,11 @@ func RunVmTest(p string, t *testing.T) {
tests
:=
make
(
map
[
string
]
VmTest
)
tests
:=
make
(
map
[
string
]
VmTest
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
helper
.
Logger
.
SetLogLevel
(
5
)
//
helper.Logger.SetLogLevel(5)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
if
name
!=
"
ABAcalls
1"
{
//
if name != "
refund50_
1" {
continue
//
continue
}
//
}
statedb
:=
state
.
New
(
helper
.
NewTrie
())
statedb
:=
state
.
New
(
helper
.
NewTrie
())
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
obj
:=
StateObjectFromAccount
(
addr
,
account
)
obj
:=
StateObjectFromAccount
(
addr
,
account
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment