Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
23bccbbc
Commit
23bccbbc
authored
Mar 24, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified according to poc 9 changes
* Refund of value
parent
bbe79545
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
9 deletions
+16
-9
execution.go
core/execution.go
+6
-4
state_transition.go
core/state_transition.go
+1
-1
environment.go
core/vm/environment.go
+1
-1
vm.go
tests/helper/vm.go
+1
-1
gh_test.go
tests/vm/gh_test.go
+7
-2
No files found.
core/execution.go
View file @
23bccbbc
...
...
@@ -39,20 +39,22 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm.
return
nil
,
vm
.
DepthError
{}
}
snapshot
:=
env
.
State
()
.
Copy
()
v
snapshot
:=
env
.
State
()
.
Copy
()
if
self
.
address
==
nil
{
// Generate a new address
nonce
:=
env
.
State
()
.
GetNonce
(
caller
.
Address
())
addr
:=
crypto
.
CreateAddress
(
caller
.
Address
(),
nonce
)
self
.
address
=
&
addr
env
.
State
()
.
SetNonce
(
caller
.
Address
(),
nonce
+
1
)
self
.
address
=
&
addr
}
snapshot
:=
env
.
State
()
.
Copy
()
from
,
to
:=
env
.
State
()
.
GetStateObject
(
caller
.
Address
()),
env
.
State
()
.
GetOrNewStateObject
(
*
self
.
address
)
err
=
env
.
Transfer
(
from
,
to
,
self
.
value
)
if
err
!=
nil
{
env
.
State
()
.
Set
(
snapshot
)
//caller.ReturnGas(self.Gas, self.price)
env
.
State
()
.
Set
(
vsnapshot
)
caller
.
ReturnGas
(
self
.
Gas
,
self
.
price
)
return
nil
,
ValueTransferErr
(
"insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
from
.
Balance
())
}
...
...
core/state_transition.go
View file @
23bccbbc
...
...
@@ -196,7 +196,6 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
vmenv
:=
self
.
env
var
ref
vm
.
ContextRef
...
...
@@ -214,6 +213,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
}
}
else
{
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
ret
,
err
=
vmenv
.
Call
(
self
.
From
(),
self
.
To
()
.
Address
(),
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
}
...
...
core/vm/environment.go
View file @
23bccbbc
...
...
@@ -7,8 +7,8 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/rlp"
)
type
Environment
interface
{
...
...
tests/helper/vm.go
View file @
23bccbbc
...
...
@@ -6,9 +6,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
)
type
Env
struct
{
...
...
tests/vm/gh_test.go
View file @
23bccbbc
...
...
@@ -7,10 +7,10 @@ import (
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/tests/helper"
)
...
...
@@ -144,6 +144,11 @@ func RunVmTest(p string, t *testing.T) {
if
obj
.
Balance
()
.
Cmp
(
common
.
Big
(
account
.
Balance
))
!=
0
{
t
.
Errorf
(
"%s's : (%x) balance failed. Expected %v, got %v => %v
\n
"
,
name
,
obj
.
Address
()
.
Bytes
()[
:
4
],
account
.
Balance
,
obj
.
Balance
(),
new
(
big
.
Int
)
.
Sub
(
common
.
Big
(
account
.
Balance
),
obj
.
Balance
()))
}
if
obj
.
Nonce
()
!=
common
.
String2Big
(
account
.
Nonce
)
.
Uint64
()
{
t
.
Errorf
(
"%s's : (%x) nonce failed. Expected %v, got %v
\n
"
,
name
,
obj
.
Address
()
.
Bytes
()[
:
4
],
account
.
Nonce
,
obj
.
Nonce
())
}
}
for
addr
,
value
:=
range
account
.
Storage
{
...
...
@@ -194,7 +199,7 @@ func RunVmTest(p string, t *testing.T) {
}
}
}
//
statedb.Trie().PrintRoot(
)
//
fmt.Println(string(statedb.Dump())
)
}
logger
.
Flush
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment