mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
core: improve checks for 7702
- prevent SetCodeTx in create mode (similar to blob tx) - move check for non-empty auth list to preCheck
This commit is contained in:
parent
33888a9e6b
commit
e7c0f80e4f
2 changed files with 18 additions and 17 deletions
|
|
@ -117,12 +117,10 @@ var (
|
||||||
|
|
||||||
// -- EIP-7702 errors --
|
// -- EIP-7702 errors --
|
||||||
|
|
||||||
// ErrEmptyAuthList is returned if a set code transaction has an empty auth list.
|
// Message validation errors:
|
||||||
ErrEmptyAuthList = errors.New("set code transaction with empty auth list")
|
ErrEmptyAuthList = errors.New("EIP-7702 transaction with empty auth list")
|
||||||
|
ErrSetCodeTxCreate = errors.New("EIP-7702 transaction cannot be used to create contract")
|
||||||
// ErrAuthSignatureVeryHigh is returned if a set code transaction has a
|
ErrAuthSignatureVeryHigh = errors.New("EIP-7702 authorization with R or S value greater than 2^256 - 1")
|
||||||
// signature with R or S larger than 2^256-1.
|
|
||||||
ErrAuthSignatureVeryHigh = errors.New("set code transaction has authorization with R or S value greater than 2^256 - 1")
|
|
||||||
|
|
||||||
// EIP-7702 state transition errors:
|
// EIP-7702 state transition errors:
|
||||||
ErrAuthorizationWrongChainID = errors.New("EIP-7702 authorization chain ID mismatch")
|
ErrAuthorizationWrongChainID = errors.New("EIP-7702 authorization chain ID mismatch")
|
||||||
|
|
|
||||||
|
|
@ -372,12 +372,20 @@ func (st *stateTransition) preCheck() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check that EIP-7702 authorization list signatures are well formed.
|
// Check that EIP-7702 authorization list signatures are well formed.
|
||||||
for i, auth := range msg.AuthList {
|
if msg.AuthList != nil {
|
||||||
switch {
|
if msg.To == nil {
|
||||||
case auth.R.BitLen() > 256:
|
return fmt.Errorf("%w (sender %v)", ErrSetCodeTxCreate, msg.From)
|
||||||
return fmt.Errorf("%w: address %v, authorization %d", ErrAuthSignatureVeryHigh, msg.From.Hex(), i)
|
}
|
||||||
case auth.S.BitLen() > 256:
|
if len(msg.AuthList) == 0 {
|
||||||
return fmt.Errorf("%w: address %v, authorization %d", ErrAuthSignatureVeryHigh, msg.From.Hex(), i)
|
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From)
|
||||||
|
}
|
||||||
|
for i, auth := range msg.AuthList {
|
||||||
|
switch {
|
||||||
|
case auth.R.BitLen() > 256:
|
||||||
|
return fmt.Errorf("%w: address %v, authorization %d", ErrAuthSignatureVeryHigh, msg.From.Hex(), i)
|
||||||
|
case auth.S.BitLen() > 256:
|
||||||
|
return fmt.Errorf("%w: address %v, authorization %d", ErrAuthSignatureVeryHigh, msg.From.Hex(), i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return st.buyGas()
|
return st.buyGas()
|
||||||
|
|
@ -451,11 +459,6 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
||||||
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize)
|
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an authorization list exists, verify it is not empty.
|
|
||||||
if msg.AuthList != nil && len(msg.AuthList) == 0 {
|
|
||||||
return nil, fmt.Errorf("%w: address %v", ErrEmptyAuthList, msg.From.Hex())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute the preparatory steps for state transition which includes:
|
// Execute the preparatory steps for state transition which includes:
|
||||||
// - prepare accessList(post-berlin)
|
// - prepare accessList(post-berlin)
|
||||||
// - reset transient storage(eip 1153)
|
// - reset transient storage(eip 1153)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue