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
457a3c8f
Commit
457a3c8f
authored
Jul 06, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1410 from obscuren/newerrors-fix
core, miner: adopted new style errors
parents
aa450206
e6bb9c1c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
12 deletions
+20
-12
block_processor.go
core/block_processor.go
+2
-3
state_transition.go
core/state_transition.go
+7
-0
transaction.go
core/types/transaction.go
+3
-1
errors.go
core/vm/errors.go
+1
-1
worker.go
miner/worker.go
+7
-7
No files found.
core/block_processor.go
View file @
457a3c8f
...
@@ -9,7 +9,6 @@ import (
...
@@ -9,7 +9,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
...
@@ -73,7 +72,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
...
@@ -73,7 +72,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
cb
:=
statedb
.
GetStateObject
(
coinbase
.
Address
())
cb
:=
statedb
.
GetStateObject
(
coinbase
.
Address
())
_
,
gas
,
err
:=
ApplyMessage
(
NewEnv
(
statedb
,
self
.
bc
,
tx
,
header
),
tx
,
cb
)
_
,
gas
,
err
:=
ApplyMessage
(
NewEnv
(
statedb
,
self
.
bc
,
tx
,
header
),
tx
,
cb
)
if
err
!=
nil
&&
err
!=
vm
.
OutOfGasError
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
@@ -119,7 +118,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
...
@@ -119,7 +118,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
statedb
.
StartRecord
(
tx
.
Hash
(),
block
.
Hash
(),
i
)
statedb
.
StartRecord
(
tx
.
Hash
(),
block
.
Hash
(),
i
)
receipt
,
txGas
,
err
:=
self
.
ApplyTransaction
(
coinbase
,
statedb
,
header
,
tx
,
totalUsedGas
,
transientProcess
)
receipt
,
txGas
,
err
:=
self
.
ApplyTransaction
(
coinbase
,
statedb
,
header
,
tx
,
totalUsedGas
,
transientProcess
)
if
err
!=
nil
&&
err
!=
vm
.
OutOfGasError
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
core/state_transition.go
View file @
457a3c8f
...
@@ -203,16 +203,23 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
...
@@ -203,16 +203,23 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
glog
.
V
(
logger
.
Core
)
.
Infoln
(
"Insufficient gas for creating code. Require"
,
dataGas
,
"and have"
,
self
.
gas
)
glog
.
V
(
logger
.
Core
)
.
Infoln
(
"Insufficient gas for creating code. Require"
,
dataGas
,
"and have"
,
self
.
gas
)
}
}
}
}
glog
.
V
(
logger
.
Core
)
.
Infoln
(
"VM create err:"
,
err
)
}
else
{
}
else
{
// Increment the nonce for the next transaction
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
ret
,
err
=
vmenv
.
Call
(
sender
,
self
.
To
()
.
Address
(),
self
.
data
,
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
ret
,
err
=
vmenv
.
Call
(
sender
,
self
.
To
()
.
Address
(),
self
.
data
,
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
glog
.
V
(
logger
.
Core
)
.
Infoln
(
"VM call err:"
,
err
)
}
}
if
err
!=
nil
&&
IsValueTransferErr
(
err
)
{
if
err
!=
nil
&&
IsValueTransferErr
(
err
)
{
return
nil
,
nil
,
InvalidTxError
(
err
)
return
nil
,
nil
,
InvalidTxError
(
err
)
}
}
// We aren't interested in errors here. Errors returned by the VM are non-consensus errors and therefor shouldn't bubble up
if
err
!=
nil
{
err
=
nil
}
if
vm
.
Debug
{
if
vm
.
Debug
{
vm
.
StdErrFormat
(
vmenv
.
StructLogs
())
vm
.
StdErrFormat
(
vmenv
.
StructLogs
())
}
}
...
...
core/types/transaction.go
View file @
457a3c8f
...
@@ -15,6 +15,8 @@ import (
...
@@ -15,6 +15,8 @@ import (
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
)
)
var
ErrInvalidSig
=
errors
.
New
(
"invalid v, r, s values"
)
func
IsContractAddr
(
addr
[]
byte
)
bool
{
func
IsContractAddr
(
addr
[]
byte
)
bool
{
return
len
(
addr
)
==
0
return
len
(
addr
)
==
0
}
}
...
@@ -177,7 +179,7 @@ func (tx *Transaction) SignatureValues() (v byte, r *big.Int, s *big.Int) {
...
@@ -177,7 +179,7 @@ func (tx *Transaction) SignatureValues() (v byte, r *big.Int, s *big.Int) {
func
(
tx
*
Transaction
)
publicKey
()
([]
byte
,
error
)
{
func
(
tx
*
Transaction
)
publicKey
()
([]
byte
,
error
)
{
if
!
crypto
.
ValidateSignatureValues
(
tx
.
data
.
V
,
tx
.
data
.
R
,
tx
.
data
.
S
)
{
if
!
crypto
.
ValidateSignatureValues
(
tx
.
data
.
V
,
tx
.
data
.
R
,
tx
.
data
.
S
)
{
return
nil
,
errors
.
New
(
"invalid v, r, s values"
)
return
nil
,
ErrInvalidSig
}
}
// encode the signature in uncompressed format
// encode the signature in uncompressed format
...
...
core/vm/errors.go
View file @
457a3c8f
...
@@ -22,7 +22,7 @@ func (self StackError) Error() string {
...
@@ -22,7 +22,7 @@ func (self StackError) Error() string {
return
fmt
.
Sprintf
(
"stack error! require %v, have %v"
,
self
.
req
,
self
.
has
)
return
fmt
.
Sprintf
(
"stack error! require %v, have %v"
,
self
.
req
,
self
.
has
)
}
}
func
IsStack
(
err
error
)
bool
{
func
IsStack
Err
(
err
error
)
bool
{
_
,
ok
:=
err
.
(
StackError
)
_
,
ok
:=
err
.
(
StackError
)
return
ok
return
ok
}
}
miner/worker.go
View file @
457a3c8f
...
@@ -524,18 +524,18 @@ func (env *environment) commitTransactions(transactions types.Transactions, gasP
...
@@ -524,18 +524,18 @@ func (env *environment) commitTransactions(transactions types.Transactions, gasP
err
:=
env
.
commitTransaction
(
tx
,
proc
)
err
:=
env
.
commitTransaction
(
tx
,
proc
)
switch
{
switch
{
case
core
.
IsNonceErr
(
err
)
||
core
.
IsInvalidTxErr
(
err
)
:
env
.
remove
.
Add
(
tx
.
Hash
())
if
glog
.
V
(
logger
.
Detail
)
{
glog
.
Infof
(
"TX (%x) failed, will be removed: %v
\n
"
,
tx
.
Hash
()
.
Bytes
()[
:
4
],
err
)
}
case
state
.
IsGasLimitErr
(
err
)
:
case
state
.
IsGasLimitErr
(
err
)
:
// ignore the transactor so no nonce errors will be thrown for this account
// ignore the transactor so no nonce errors will be thrown for this account
// next time the worker is run, they'll be picked up again.
// next time the worker is run, they'll be picked up again.
env
.
ignoredTransactors
.
Add
(
from
)
env
.
ignoredTransactors
.
Add
(
from
)
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Gas limit reached for (%x) in this block. Continue to try smaller txs
\n
"
,
from
[
:
4
])
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Gas limit reached for (%x) in this block. Continue to try smaller txs
\n
"
,
from
[
:
4
])
case
err
!=
nil
:
env
.
remove
.
Add
(
tx
.
Hash
())
if
glog
.
V
(
logger
.
Detail
)
{
glog
.
Infof
(
"TX (%x) failed, will be removed: %v
\n
"
,
tx
.
Hash
()
.
Bytes
()[
:
4
],
err
)
}
default
:
default
:
env
.
tcount
++
env
.
tcount
++
}
}
...
@@ -545,7 +545,7 @@ func (env *environment) commitTransactions(transactions types.Transactions, gasP
...
@@ -545,7 +545,7 @@ func (env *environment) commitTransactions(transactions types.Transactions, gasP
func
(
env
*
environment
)
commitTransaction
(
tx
*
types
.
Transaction
,
proc
*
core
.
BlockProcessor
)
error
{
func
(
env
*
environment
)
commitTransaction
(
tx
*
types
.
Transaction
,
proc
*
core
.
BlockProcessor
)
error
{
snap
:=
env
.
state
.
Copy
()
snap
:=
env
.
state
.
Copy
()
receipt
,
_
,
err
:=
proc
.
ApplyTransaction
(
env
.
coinbase
,
env
.
state
,
env
.
header
,
tx
,
env
.
header
.
GasUsed
,
true
)
receipt
,
_
,
err
:=
proc
.
ApplyTransaction
(
env
.
coinbase
,
env
.
state
,
env
.
header
,
tx
,
env
.
header
.
GasUsed
,
true
)
if
err
!=
nil
&&
(
core
.
IsNonceErr
(
err
)
||
state
.
IsGasLimitErr
(
err
)
||
core
.
IsInvalidTxErr
(
err
))
{
if
err
!=
nil
{
env
.
state
.
Set
(
snap
)
env
.
state
.
Set
(
snap
)
return
err
return
err
}
}
...
...
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