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
576df064
Commit
576df064
authored
Mar 24, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated for PV59
* Value XFER are refunded back to the sender if the execution fails
parent
4877e52c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
19 deletions
+16
-19
execution.go
core/execution.go
+8
-10
state_transition.go
core/state_transition.go
+7
-8
protocol.go
eth/protocol.go
+1
-1
No files found.
core/execution.go
View file @
576df064
...
...
@@ -5,9 +5,9 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"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
Execution
struct
{
...
...
@@ -29,6 +29,8 @@ func (self *Execution) Call(codeAddr common.Address, caller vm.ContextRef) ([]by
}
func
(
self
*
Execution
)
exec
(
contextAddr
*
common
.
Address
,
code
[]
byte
,
caller
vm
.
ContextRef
)
(
ret
[]
byte
,
err
error
)
{
start
:=
time
.
Now
()
env
:=
self
.
env
evm
:=
vm
.
NewVm
(
env
)
if
env
.
Depth
()
==
vm
.
MaxCallDepth
{
...
...
@@ -37,7 +39,7 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm.
return
nil
,
vm
.
DepthError
{}
}
v
snapshot
:=
env
.
State
()
.
Copy
()
snapshot
:=
env
.
State
()
.
Copy
()
if
self
.
address
==
nil
{
// Generate a new address
nonce
:=
env
.
State
()
.
GetNonce
(
caller
.
Address
())
...
...
@@ -49,21 +51,17 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm.
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
(
vsnapshot
)
caller
.
ReturnGas
(
self
.
Gas
,
self
.
price
)
env
.
State
()
.
Set
(
snapshot
)
//caller.ReturnGas(self.Gas, self.price)
return
nil
,
ValueTransferErr
(
"insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
from
.
Balance
())
}
snapshot
:=
env
.
State
()
.
Copy
()
start
:=
time
.
Now
()
context
:=
vm
.
NewContext
(
caller
,
to
,
self
.
value
,
self
.
Gas
,
self
.
price
)
context
.
SetCallCode
(
contextAddr
,
code
)
ret
,
err
=
evm
.
Run
(
context
,
self
.
input
)
//self.value, self.Gas, self.price, self.input)
chainlogger
.
Debugf
(
"vm took %v
\n
"
,
time
.
Since
(
start
)
)
ret
,
err
=
evm
.
Run
(
context
,
self
.
input
)
evm
.
Printf
(
"message call took %v"
,
time
.
Since
(
start
))
.
Endl
(
)
if
err
!=
nil
{
env
.
State
()
.
Set
(
snapshot
)
}
...
...
core/state_transition.go
View file @
576df064
...
...
@@ -5,9 +5,9 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"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"
)
const
tryJit
=
false
...
...
@@ -182,10 +182,6 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
return
nil
,
nil
,
InvalidTxError
(
err
)
}
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
//sender.Nonce += 1
// Pay data gas
var
dgas
int64
for
_
,
byt
:=
range
self
.
data
{
...
...
@@ -199,12 +195,15 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
return
nil
,
nil
,
InvalidTxError
(
err
)
}
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
vmenv
:=
self
.
env
var
ref
vm
.
ContextRef
if
MessageCreatesContract
(
msg
)
{
contract
:=
makeContract
(
msg
,
self
.
state
)
addr
:=
contract
.
Address
()
ret
,
err
,
ref
=
vmenv
.
Create
(
sender
,
&
addr
,
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
//
contract := makeContract(msg, self.state)
//
addr := contract.Address()
ret
,
err
,
ref
=
vmenv
.
Create
(
sender
,
nil
,
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
if
err
==
nil
{
dataGas
:=
big
.
NewInt
(
int64
(
len
(
ret
)))
dataGas
.
Mul
(
dataGas
,
vm
.
GasCreateByte
)
...
...
eth/protocol.go
View file @
576df064
...
...
@@ -13,7 +13,7 @@ import (
)
const
(
ProtocolVersion
=
5
8
ProtocolVersion
=
5
9
NetworkId
=
0
ProtocolLength
=
uint64
(
8
)
ProtocolMaxMsgSize
=
10
*
1024
*
1024
...
...
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