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
d02c6053
Unverified
Commit
d02c6053
authored
Aug 23, 2021
by
Marius van der Wijden
Committed by
GitHub
Aug 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: only check sendernoeoa in non fake mode (#23424)
parent
c368f728
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
20 deletions
+21
-20
simulated.go
accounts/abi/bind/backends/simulated.go
+1
-1
state_transition.go
core/state_transition.go
+9
-8
transaction.go
core/types/transaction.go
+5
-5
transaction_args.go
internal/ethapi/transaction_args.go
+2
-2
odr_test.go
les/odr_test.go
+2
-2
odr_test.go
light/odr_test.go
+1
-1
state_test_util.go
tests/state_test_util.go
+1
-1
No files found.
accounts/abi/bind/backends/simulated.go
View file @
d02c6053
...
@@ -795,7 +795,7 @@ type callMsg struct {
...
@@ -795,7 +795,7 @@ type callMsg struct {
func
(
m
callMsg
)
From
()
common
.
Address
{
return
m
.
CallMsg
.
From
}
func
(
m
callMsg
)
From
()
common
.
Address
{
return
m
.
CallMsg
.
From
}
func
(
m
callMsg
)
Nonce
()
uint64
{
return
0
}
func
(
m
callMsg
)
Nonce
()
uint64
{
return
0
}
func
(
m
callMsg
)
CheckNonce
()
bool
{
return
fals
e
}
func
(
m
callMsg
)
IsFake
()
bool
{
return
tru
e
}
func
(
m
callMsg
)
To
()
*
common
.
Address
{
return
m
.
CallMsg
.
To
}
func
(
m
callMsg
)
To
()
*
common
.
Address
{
return
m
.
CallMsg
.
To
}
func
(
m
callMsg
)
GasPrice
()
*
big
.
Int
{
return
m
.
CallMsg
.
GasPrice
}
func
(
m
callMsg
)
GasPrice
()
*
big
.
Int
{
return
m
.
CallMsg
.
GasPrice
}
func
(
m
callMsg
)
GasFeeCap
()
*
big
.
Int
{
return
m
.
CallMsg
.
GasFeeCap
}
func
(
m
callMsg
)
GasFeeCap
()
*
big
.
Int
{
return
m
.
CallMsg
.
GasFeeCap
}
...
...
core/state_transition.go
View file @
d02c6053
...
@@ -74,7 +74,7 @@ type Message interface {
...
@@ -74,7 +74,7 @@ type Message interface {
Value
()
*
big
.
Int
Value
()
*
big
.
Int
Nonce
()
uint64
Nonce
()
uint64
CheckNonc
e
()
bool
IsFak
e
()
bool
Data
()
[]
byte
Data
()
[]
byte
AccessList
()
types
.
AccessList
AccessList
()
types
.
AccessList
}
}
...
@@ -212,8 +212,9 @@ func (st *StateTransition) buyGas() error {
...
@@ -212,8 +212,9 @@ func (st *StateTransition) buyGas() error {
}
}
func
(
st
*
StateTransition
)
preCheck
()
error
{
func
(
st
*
StateTransition
)
preCheck
()
error
{
// Make sure this transaction's nonce is correct.
// Only check transactions that are not fake
if
st
.
msg
.
CheckNonce
()
{
if
!
st
.
msg
.
IsFake
()
{
// Make sure this transaction's nonce is correct.
stNonce
:=
st
.
state
.
GetNonce
(
st
.
msg
.
From
())
stNonce
:=
st
.
state
.
GetNonce
(
st
.
msg
.
From
())
if
msgNonce
:=
st
.
msg
.
Nonce
();
stNonce
<
msgNonce
{
if
msgNonce
:=
st
.
msg
.
Nonce
();
stNonce
<
msgNonce
{
return
fmt
.
Errorf
(
"%w: address %v, tx: %d state: %d"
,
ErrNonceTooHigh
,
return
fmt
.
Errorf
(
"%w: address %v, tx: %d state: %d"
,
ErrNonceTooHigh
,
...
@@ -222,11 +223,11 @@ func (st *StateTransition) preCheck() error {
...
@@ -222,11 +223,11 @@ func (st *StateTransition) preCheck() error {
return
fmt
.
Errorf
(
"%w: address %v, tx: %d state: %d"
,
ErrNonceTooLow
,
return
fmt
.
Errorf
(
"%w: address %v, tx: %d state: %d"
,
ErrNonceTooLow
,
st
.
msg
.
From
()
.
Hex
(),
msgNonce
,
stNonce
)
st
.
msg
.
From
()
.
Hex
(),
msgNonce
,
stNonce
)
}
}
}
// Make sure the sender is an EOA
// Make sure the sender is an EOA
if
codeHash
:=
st
.
state
.
GetCodeHash
(
st
.
msg
.
From
());
codeHash
!=
emptyCodeHash
&&
codeHash
!=
(
common
.
Hash
{})
{
if
codeHash
:=
st
.
state
.
GetCodeHash
(
st
.
msg
.
From
());
codeHash
!=
emptyCodeHash
&&
codeHash
!=
(
common
.
Hash
{})
{
return
fmt
.
Errorf
(
"%w: address %v, codehash: %s"
,
ErrSenderNoEOA
,
return
fmt
.
Errorf
(
"%w: address %v, codehash: %s"
,
ErrSenderNoEOA
,
st
.
msg
.
From
()
.
Hex
(),
codeHash
)
st
.
msg
.
From
()
.
Hex
(),
codeHash
)
}
}
}
// Make sure that transaction gasFeeCap is greater than the baseFee (post london)
// Make sure that transaction gasFeeCap is greater than the baseFee (post london)
if
st
.
evm
.
ChainConfig
()
.
IsLondon
(
st
.
evm
.
Context
.
BlockNumber
)
{
if
st
.
evm
.
ChainConfig
()
.
IsLondon
(
st
.
evm
.
Context
.
BlockNumber
)
{
...
...
core/types/transaction.go
View file @
d02c6053
...
@@ -579,10 +579,10 @@ type Message struct {
...
@@ -579,10 +579,10 @@ type Message struct {
gasTipCap
*
big
.
Int
gasTipCap
*
big
.
Int
data
[]
byte
data
[]
byte
accessList
AccessList
accessList
AccessList
checkNonce
bool
isFake
bool
}
}
func
NewMessage
(
from
common
.
Address
,
to
*
common
.
Address
,
nonce
uint64
,
amount
*
big
.
Int
,
gasLimit
uint64
,
gasPrice
,
gasFeeCap
,
gasTipCap
*
big
.
Int
,
data
[]
byte
,
accessList
AccessList
,
checkNonc
e
bool
)
Message
{
func
NewMessage
(
from
common
.
Address
,
to
*
common
.
Address
,
nonce
uint64
,
amount
*
big
.
Int
,
gasLimit
uint64
,
gasPrice
,
gasFeeCap
,
gasTipCap
*
big
.
Int
,
data
[]
byte
,
accessList
AccessList
,
isFak
e
bool
)
Message
{
return
Message
{
return
Message
{
from
:
from
,
from
:
from
,
to
:
to
,
to
:
to
,
...
@@ -594,7 +594,7 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b
...
@@ -594,7 +594,7 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b
gasTipCap
:
gasTipCap
,
gasTipCap
:
gasTipCap
,
data
:
data
,
data
:
data
,
accessList
:
accessList
,
accessList
:
accessList
,
checkNonce
:
checkNonc
e
,
isFake
:
isFak
e
,
}
}
}
}
...
@@ -610,7 +610,7 @@ func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error) {
...
@@ -610,7 +610,7 @@ func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error) {
amount
:
tx
.
Value
(),
amount
:
tx
.
Value
(),
data
:
tx
.
Data
(),
data
:
tx
.
Data
(),
accessList
:
tx
.
AccessList
(),
accessList
:
tx
.
AccessList
(),
checkNonce
:
tru
e
,
isFake
:
fals
e
,
}
}
// If baseFee provided, set gasPrice to effectiveGasPrice.
// If baseFee provided, set gasPrice to effectiveGasPrice.
if
baseFee
!=
nil
{
if
baseFee
!=
nil
{
...
@@ -631,4 +631,4 @@ func (m Message) Gas() uint64 { return m.gasLimit }
...
@@ -631,4 +631,4 @@ func (m Message) Gas() uint64 { return m.gasLimit }
func
(
m
Message
)
Nonce
()
uint64
{
return
m
.
nonce
}
func
(
m
Message
)
Nonce
()
uint64
{
return
m
.
nonce
}
func
(
m
Message
)
Data
()
[]
byte
{
return
m
.
data
}
func
(
m
Message
)
Data
()
[]
byte
{
return
m
.
data
}
func
(
m
Message
)
AccessList
()
AccessList
{
return
m
.
accessList
}
func
(
m
Message
)
AccessList
()
AccessList
{
return
m
.
accessList
}
func
(
m
Message
)
CheckNonce
()
bool
{
return
m
.
checkNonc
e
}
func
(
m
Message
)
IsFake
()
bool
{
return
m
.
isFak
e
}
internal/ethapi/transaction_args.go
View file @
d02c6053
...
@@ -171,7 +171,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
...
@@ -171,7 +171,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
return
nil
return
nil
}
}
// ToMessage converts th transaction arguments to the Message type used by the
// ToMessage converts th
e
transaction arguments to the Message type used by the
// core evm. This method is used in calls and traces that do not require a real
// core evm. This method is used in calls and traces that do not require a real
// live transaction.
// live transaction.
func
(
args
*
TransactionArgs
)
ToMessage
(
globalGasCap
uint64
,
baseFee
*
big
.
Int
)
(
types
.
Message
,
error
)
{
func
(
args
*
TransactionArgs
)
ToMessage
(
globalGasCap
uint64
,
baseFee
*
big
.
Int
)
(
types
.
Message
,
error
)
{
...
@@ -238,7 +238,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (t
...
@@ -238,7 +238,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (t
if
args
.
AccessList
!=
nil
{
if
args
.
AccessList
!=
nil
{
accessList
=
*
args
.
AccessList
accessList
=
*
args
.
AccessList
}
}
msg
:=
types
.
NewMessage
(
addr
,
args
.
To
,
0
,
value
,
gas
,
gasPrice
,
gasFeeCap
,
gasTipCap
,
data
,
accessList
,
fals
e
)
msg
:=
types
.
NewMessage
(
addr
,
args
.
To
,
0
,
value
,
gas
,
gasPrice
,
gasFeeCap
,
gasTipCap
,
data
,
accessList
,
tru
e
)
return
msg
,
nil
return
msg
,
nil
}
}
...
...
les/odr_test.go
View file @
d02c6053
...
@@ -135,7 +135,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
...
@@ -135,7 +135,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
from
:=
statedb
.
GetOrNewStateObject
(
bankAddr
)
from
:=
statedb
.
GetOrNewStateObject
(
bankAddr
)
from
.
SetBalance
(
math
.
MaxBig256
)
from
.
SetBalance
(
math
.
MaxBig256
)
msg
:=
callmsg
{
types
.
NewMessage
(
from
.
Address
(),
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
big
.
NewInt
(
params
.
InitialBaseFee
),
big
.
NewInt
(
params
.
InitialBaseFee
),
new
(
big
.
Int
),
data
,
nil
,
fals
e
)}
msg
:=
callmsg
{
types
.
NewMessage
(
from
.
Address
(),
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
big
.
NewInt
(
params
.
InitialBaseFee
),
big
.
NewInt
(
params
.
InitialBaseFee
),
new
(
big
.
Int
),
data
,
nil
,
tru
e
)}
context
:=
core
.
NewEVMBlockContext
(
header
,
bc
,
nil
)
context
:=
core
.
NewEVMBlockContext
(
header
,
bc
,
nil
)
txContext
:=
core
.
NewEVMTxContext
(
msg
)
txContext
:=
core
.
NewEVMTxContext
(
msg
)
...
@@ -150,7 +150,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
...
@@ -150,7 +150,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
header
:=
lc
.
GetHeaderByHash
(
bhash
)
header
:=
lc
.
GetHeaderByHash
(
bhash
)
state
:=
light
.
NewState
(
ctx
,
header
,
lc
.
Odr
())
state
:=
light
.
NewState
(
ctx
,
header
,
lc
.
Odr
())
state
.
SetBalance
(
bankAddr
,
math
.
MaxBig256
)
state
.
SetBalance
(
bankAddr
,
math
.
MaxBig256
)
msg
:=
callmsg
{
types
.
NewMessage
(
bankAddr
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
big
.
NewInt
(
params
.
InitialBaseFee
),
big
.
NewInt
(
params
.
InitialBaseFee
),
new
(
big
.
Int
),
data
,
nil
,
fals
e
)}
msg
:=
callmsg
{
types
.
NewMessage
(
bankAddr
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
big
.
NewInt
(
params
.
InitialBaseFee
),
big
.
NewInt
(
params
.
InitialBaseFee
),
new
(
big
.
Int
),
data
,
nil
,
tru
e
)}
context
:=
core
.
NewEVMBlockContext
(
header
,
lc
,
nil
)
context
:=
core
.
NewEVMBlockContext
(
header
,
lc
,
nil
)
txContext
:=
core
.
NewEVMTxContext
(
msg
)
txContext
:=
core
.
NewEVMTxContext
(
msg
)
vmenv
:=
vm
.
NewEVM
(
context
,
txContext
,
state
,
config
,
vm
.
Config
{
NoBaseFee
:
true
})
vmenv
:=
vm
.
NewEVM
(
context
,
txContext
,
state
,
config
,
vm
.
Config
{
NoBaseFee
:
true
})
...
...
light/odr_test.go
View file @
d02c6053
...
@@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
...
@@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
// Perform read-only call.
// Perform read-only call.
st
.
SetBalance
(
testBankAddress
,
math
.
MaxBig256
)
st
.
SetBalance
(
testBankAddress
,
math
.
MaxBig256
)
msg
:=
callmsg
{
types
.
NewMessage
(
testBankAddress
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
1000000
,
big
.
NewInt
(
params
.
InitialBaseFee
),
big
.
NewInt
(
params
.
InitialBaseFee
),
new
(
big
.
Int
),
data
,
nil
,
fals
e
)}
msg
:=
callmsg
{
types
.
NewMessage
(
testBankAddress
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
1000000
,
big
.
NewInt
(
params
.
InitialBaseFee
),
big
.
NewInt
(
params
.
InitialBaseFee
),
new
(
big
.
Int
),
data
,
nil
,
tru
e
)}
txContext
:=
core
.
NewEVMTxContext
(
msg
)
txContext
:=
core
.
NewEVMTxContext
(
msg
)
context
:=
core
.
NewEVMBlockContext
(
header
,
chain
,
nil
)
context
:=
core
.
NewEVMBlockContext
(
header
,
chain
,
nil
)
vmenv
:=
vm
.
NewEVM
(
context
,
txContext
,
st
,
config
,
vm
.
Config
{
NoBaseFee
:
true
})
vmenv
:=
vm
.
NewEVM
(
context
,
txContext
,
st
,
config
,
vm
.
Config
{
NoBaseFee
:
true
})
...
...
tests/state_test_util.go
View file @
d02c6053
...
@@ -348,7 +348,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (core.Messa
...
@@ -348,7 +348,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (core.Messa
}
}
msg
:=
types
.
NewMessage
(
from
,
to
,
tx
.
Nonce
,
value
,
gasLimit
,
gasPrice
,
msg
:=
types
.
NewMessage
(
from
,
to
,
tx
.
Nonce
,
value
,
gasLimit
,
gasPrice
,
tx
.
MaxFeePerGas
,
tx
.
MaxPriorityFeePerGas
,
data
,
accessList
,
tru
e
)
tx
.
MaxFeePerGas
,
tx
.
MaxPriorityFeePerGas
,
data
,
accessList
,
fals
e
)
return
msg
,
nil
return
msg
,
nil
}
}
...
...
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