mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fix: check for eip activation in SSTORE
This commit is contained in:
parent
6bfd4837cf
commit
926104ecdc
6 changed files with 11 additions and 2 deletions
|
|
@ -86,6 +86,7 @@ func NewEVMTxContext(msg *Message) vm.TxContext {
|
|||
if msg.BlobGasFeeCap != nil {
|
||||
ctx.BlobFeeCap = new(big.Int).Set(msg.BlobGasFeeCap)
|
||||
}
|
||||
ctx.Is5806 = msg.Delegate
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ var (
|
|||
ErrMaxCodeSizeExceeded = errors.New("max code size exceeded")
|
||||
ErrInvalidJump = errors.New("invalid jump destination")
|
||||
ErrWriteProtection = errors.New("write protection")
|
||||
ErrEip5806Write = errors.New("write attempt in eip5806 transaction")
|
||||
ErrReturnDataOutOfBounds = errors.New("return data out of bounds")
|
||||
ErrGasUintOverflow = errors.New("gas uint64 overflow")
|
||||
ErrInvalidCode = errors.New("invalid code: must not begin with 0xef")
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ type TxContext struct {
|
|||
GasPrice *big.Int // Provides information for GASPRICE (and is used to zero the basefee if NoBaseFee is set)
|
||||
BlobHashes []common.Hash // Provides information for BLOBHASH
|
||||
BlobFeeCap *big.Int // Is used to zero the blobbasefee if NoBaseFee is set
|
||||
Is5806 bool // Indicates if this is an eip-5806 transaction
|
||||
}
|
||||
|
||||
// EVM is the Ethereum Virtual Machine base object and provides
|
||||
|
|
|
|||
|
|
@ -518,8 +518,12 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
|
|||
}
|
||||
|
||||
func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||
// if scope is an account with no code (EOA delegation through EIP-5806) sstore is protected
|
||||
if interpreter.readOnly || scope.Contract.CodeHash == (common.Hash{}) {
|
||||
if interpreter.evm.TxContext.Is5806 {
|
||||
if scope.Contract.CodeHash == types.EmptyCodeHash || scope.Contract.CodeHash == (common.Hash{}) {
|
||||
return nil, ErrEip5806Write
|
||||
}
|
||||
}
|
||||
if interpreter.readOnly {
|
||||
return nil, ErrWriteProtection
|
||||
}
|
||||
loc := scope.Stack.pop()
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ func NewEnv(cfg *Config) *vm.EVM {
|
|||
GasPrice: cfg.GasPrice,
|
||||
BlobHashes: cfg.BlobHashes,
|
||||
BlobFeeCap: cfg.BlobFeeCap,
|
||||
Is5806: cfg.Is5806,
|
||||
}
|
||||
blockContext := vm.BlockContext{
|
||||
CanTransfer: core.CanTransfer,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ type Config struct {
|
|||
BlobHashes []common.Hash
|
||||
BlobFeeCap *big.Int
|
||||
Random *common.Hash
|
||||
Is5806 bool
|
||||
|
||||
State *state.StateDB
|
||||
GetHashFn func(n uint64) common.Hash
|
||||
|
|
|
|||
Loading…
Reference in a new issue