|
|
@ -131,19 +131,19 @@ func toWordSize(size uint64) uint64 { |
|
|
|
// A Message contains the data derived from a single transaction that is relevant to state
|
|
|
|
// A Message contains the data derived from a single transaction that is relevant to state
|
|
|
|
// processing.
|
|
|
|
// processing.
|
|
|
|
type Message struct { |
|
|
|
type Message struct { |
|
|
|
To *common.Address |
|
|
|
To *common.Address |
|
|
|
From common.Address |
|
|
|
From common.Address |
|
|
|
Nonce uint64 |
|
|
|
Nonce uint64 |
|
|
|
Value *big.Int |
|
|
|
Value *big.Int |
|
|
|
GasLimit uint64 |
|
|
|
GasLimit uint64 |
|
|
|
GasPrice *big.Int |
|
|
|
GasPrice *big.Int |
|
|
|
GasFeeCap *big.Int |
|
|
|
GasFeeCap *big.Int |
|
|
|
GasTipCap *big.Int |
|
|
|
GasTipCap *big.Int |
|
|
|
Data []byte |
|
|
|
Data []byte |
|
|
|
AccessList types.AccessList |
|
|
|
AccessList types.AccessList |
|
|
|
BlobGasFeeCap *big.Int |
|
|
|
BlobGasFeeCap *big.Int |
|
|
|
BlobHashes []common.Hash |
|
|
|
BlobHashes []common.Hash |
|
|
|
AuthList []types.SetCodeAuthorization |
|
|
|
SetCodeAuthorizations []types.SetCodeAuthorization |
|
|
|
|
|
|
|
|
|
|
|
// When SkipNonceChecks is true, the message nonce is not checked against the
|
|
|
|
// When SkipNonceChecks is true, the message nonce is not checked against the
|
|
|
|
// account nonce in state.
|
|
|
|
// account nonce in state.
|
|
|
@ -157,20 +157,20 @@ type Message struct { |
|
|
|
// TransactionToMessage converts a transaction into a Message.
|
|
|
|
// TransactionToMessage converts a transaction into a Message.
|
|
|
|
func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.Int) (*Message, error) { |
|
|
|
func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.Int) (*Message, error) { |
|
|
|
msg := &Message{ |
|
|
|
msg := &Message{ |
|
|
|
Nonce: tx.Nonce(), |
|
|
|
Nonce: tx.Nonce(), |
|
|
|
GasLimit: tx.Gas(), |
|
|
|
GasLimit: tx.Gas(), |
|
|
|
GasPrice: new(big.Int).Set(tx.GasPrice()), |
|
|
|
GasPrice: new(big.Int).Set(tx.GasPrice()), |
|
|
|
GasFeeCap: new(big.Int).Set(tx.GasFeeCap()), |
|
|
|
GasFeeCap: new(big.Int).Set(tx.GasFeeCap()), |
|
|
|
GasTipCap: new(big.Int).Set(tx.GasTipCap()), |
|
|
|
GasTipCap: new(big.Int).Set(tx.GasTipCap()), |
|
|
|
To: tx.To(), |
|
|
|
To: tx.To(), |
|
|
|
Value: tx.Value(), |
|
|
|
Value: tx.Value(), |
|
|
|
Data: tx.Data(), |
|
|
|
Data: tx.Data(), |
|
|
|
AccessList: tx.AccessList(), |
|
|
|
AccessList: tx.AccessList(), |
|
|
|
AuthList: tx.AuthList(), |
|
|
|
SetCodeAuthorizations: tx.SetCodeAuthorizations(), |
|
|
|
SkipNonceChecks: false, |
|
|
|
SkipNonceChecks: false, |
|
|
|
SkipFromEOACheck: false, |
|
|
|
SkipFromEOACheck: false, |
|
|
|
BlobHashes: tx.BlobHashes(), |
|
|
|
BlobHashes: tx.BlobHashes(), |
|
|
|
BlobGasFeeCap: tx.BlobGasFeeCap(), |
|
|
|
BlobGasFeeCap: tx.BlobGasFeeCap(), |
|
|
|
} |
|
|
|
} |
|
|
|
// If baseFee provided, set gasPrice to effectiveGasPrice.
|
|
|
|
// If baseFee provided, set gasPrice to effectiveGasPrice.
|
|
|
|
if baseFee != nil { |
|
|
|
if baseFee != nil { |
|
|
@ -372,11 +372,11 @@ 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.
|
|
|
|
if msg.AuthList != nil { |
|
|
|
if msg.SetCodeAuthorizations != nil { |
|
|
|
if msg.To == nil { |
|
|
|
if msg.To == nil { |
|
|
|
return fmt.Errorf("%w (sender %v)", ErrSetCodeTxCreate, msg.From) |
|
|
|
return fmt.Errorf("%w (sender %v)", ErrSetCodeTxCreate, msg.From) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(msg.AuthList) == 0 { |
|
|
|
if len(msg.SetCodeAuthorizations) == 0 { |
|
|
|
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From) |
|
|
|
return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -417,7 +417,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) { |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
|
|
|
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
|
|
|
gas, err := IntrinsicGas(msg.Data, msg.AccessList, msg.AuthList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai) |
|
|
|
gas, err := IntrinsicGas(msg.Data, msg.AccessList, msg.SetCodeAuthorizations, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -467,8 +467,8 @@ func (st *stateTransition) execute() (*ExecutionResult, error) { |
|
|
|
st.state.SetNonce(msg.From, st.state.GetNonce(msg.From)+1) |
|
|
|
st.state.SetNonce(msg.From, st.state.GetNonce(msg.From)+1) |
|
|
|
|
|
|
|
|
|
|
|
// Apply EIP-7702 authorizations.
|
|
|
|
// Apply EIP-7702 authorizations.
|
|
|
|
if msg.AuthList != nil { |
|
|
|
if msg.SetCodeAuthorizations != nil { |
|
|
|
for _, auth := range msg.AuthList { |
|
|
|
for _, auth := range msg.SetCodeAuthorizations { |
|
|
|
// Note errors are ignored, we simply skip invalid authorizations here.
|
|
|
|
// Note errors are ignored, we simply skip invalid authorizations here.
|
|
|
|
st.applyAuthorization(msg, &auth) |
|
|
|
st.applyAuthorization(msg, &auth) |
|
|
|
} |
|
|
|
} |
|
|
|