core, core/types: rename AuthList to SetCodeAuthorizations (#30935)
As a follow-up to #30933, I propose to also use the SetCode prefix in our internal APIs for the authorization list.
This commit is contained in:
parent
f861535f1e
commit
f1e6372eea
|
@ -133,7 +133,7 @@ func Transaction(ctx *cli.Context) error {
|
|||
r.Address = sender
|
||||
}
|
||||
// Check intrinsic gas
|
||||
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.AuthList(), tx.To() == nil,
|
||||
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil,
|
||||
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0)); err != nil {
|
||||
r.Error = err
|
||||
results = append(results, r)
|
||||
|
|
|
@ -131,19 +131,19 @@ func toWordSize(size uint64) uint64 {
|
|||
// A Message contains the data derived from a single transaction that is relevant to state
|
||||
// processing.
|
||||
type Message struct {
|
||||
To *common.Address
|
||||
From common.Address
|
||||
Nonce uint64
|
||||
Value *big.Int
|
||||
GasLimit uint64
|
||||
GasPrice *big.Int
|
||||
GasFeeCap *big.Int
|
||||
GasTipCap *big.Int
|
||||
Data []byte
|
||||
AccessList types.AccessList
|
||||
BlobGasFeeCap *big.Int
|
||||
BlobHashes []common.Hash
|
||||
AuthList []types.SetCodeAuthorization
|
||||
To *common.Address
|
||||
From common.Address
|
||||
Nonce uint64
|
||||
Value *big.Int
|
||||
GasLimit uint64
|
||||
GasPrice *big.Int
|
||||
GasFeeCap *big.Int
|
||||
GasTipCap *big.Int
|
||||
Data []byte
|
||||
AccessList types.AccessList
|
||||
BlobGasFeeCap *big.Int
|
||||
BlobHashes []common.Hash
|
||||
SetCodeAuthorizations []types.SetCodeAuthorization
|
||||
|
||||
// When SkipNonceChecks is true, the message nonce is not checked against the
|
||||
// account nonce in state.
|
||||
|
@ -157,20 +157,20 @@ type Message struct {
|
|||
// TransactionToMessage converts a transaction into a Message.
|
||||
func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.Int) (*Message, error) {
|
||||
msg := &Message{
|
||||
Nonce: tx.Nonce(),
|
||||
GasLimit: tx.Gas(),
|
||||
GasPrice: new(big.Int).Set(tx.GasPrice()),
|
||||
GasFeeCap: new(big.Int).Set(tx.GasFeeCap()),
|
||||
GasTipCap: new(big.Int).Set(tx.GasTipCap()),
|
||||
To: tx.To(),
|
||||
Value: tx.Value(),
|
||||
Data: tx.Data(),
|
||||
AccessList: tx.AccessList(),
|
||||
AuthList: tx.AuthList(),
|
||||
SkipNonceChecks: false,
|
||||
SkipFromEOACheck: false,
|
||||
BlobHashes: tx.BlobHashes(),
|
||||
BlobGasFeeCap: tx.BlobGasFeeCap(),
|
||||
Nonce: tx.Nonce(),
|
||||
GasLimit: tx.Gas(),
|
||||
GasPrice: new(big.Int).Set(tx.GasPrice()),
|
||||
GasFeeCap: new(big.Int).Set(tx.GasFeeCap()),
|
||||
GasTipCap: new(big.Int).Set(tx.GasTipCap()),
|
||||
To: tx.To(),
|
||||
Value: tx.Value(),
|
||||
Data: tx.Data(),
|
||||
AccessList: tx.AccessList(),
|
||||
SetCodeAuthorizations: tx.SetCodeAuthorizations(),
|
||||
SkipNonceChecks: false,
|
||||
SkipFromEOACheck: false,
|
||||
BlobHashes: tx.BlobHashes(),
|
||||
BlobGasFeeCap: tx.BlobGasFeeCap(),
|
||||
}
|
||||
// If baseFee provided, set gasPrice to effectiveGasPrice.
|
||||
if baseFee != nil {
|
||||
|
@ -372,11 +372,11 @@ func (st *stateTransition) preCheck() error {
|
|||
}
|
||||
}
|
||||
// Check that EIP-7702 authorization list signatures are well formed.
|
||||
if msg.AuthList != nil {
|
||||
if msg.SetCodeAuthorizations != nil {
|
||||
if msg.To == nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
|||
)
|
||||
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -467,8 +467,8 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
|||
st.state.SetNonce(msg.From, st.state.GetNonce(msg.From)+1)
|
||||
|
||||
// Apply EIP-7702 authorizations.
|
||||
if msg.AuthList != nil {
|
||||
for _, auth := range msg.AuthList {
|
||||
if msg.SetCodeAuthorizations != nil {
|
||||
for _, auth := range msg.SetCodeAuthorizations {
|
||||
// Note errors are ignored, we simply skip invalid authorizations here.
|
||||
st.applyAuthorization(msg, &auth)
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
|||
}
|
||||
// Ensure the transaction has more gas than the bare minimum needed to cover
|
||||
// the transaction metadata
|
||||
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.AuthList(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time))
|
||||
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -474,8 +474,8 @@ func (tx *Transaction) WithBlobTxSidecar(sideCar *BlobTxSidecar) *Transaction {
|
|||
return cpy
|
||||
}
|
||||
|
||||
// AuthList returns the authorizations list of the transaction.
|
||||
func (tx *Transaction) AuthList() []SetCodeAuthorization {
|
||||
// SetCodeAuthorizations returns the authorizations list of the transaction.
|
||||
func (tx *Transaction) SetCodeAuthorizations() []SetCodeAuthorization {
|
||||
setcodetx, ok := tx.inner.(*SetCodeTx)
|
||||
if !ok {
|
||||
return nil
|
||||
|
|
|
@ -245,7 +245,7 @@ func (s pragueSigner) Hash(tx *Transaction) common.Hash {
|
|||
tx.Value(),
|
||||
tx.Data(),
|
||||
tx.AccessList(),
|
||||
tx.AuthList(),
|
||||
tx.SetCodeAuthorizations(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ func (t *prestateTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction
|
|||
t.lookupAccount(env.Coinbase)
|
||||
|
||||
// Add accounts with authorizations to the prestate before they get applied.
|
||||
for _, auth := range tx.AuthList() {
|
||||
for _, auth := range tx.SetCodeAuthorizations() {
|
||||
addr, err := auth.Authority()
|
||||
if err != nil {
|
||||
continue
|
||||
|
|
|
@ -1049,7 +1049,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
|
|||
} else {
|
||||
result.GasPrice = (*hexutil.Big)(tx.GasFeeCap())
|
||||
}
|
||||
result.AuthorizationList = tx.AuthList()
|
||||
result.AuthorizationList = tx.SetCodeAuthorizations()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -454,21 +454,21 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck, skipEoA
|
|||
accessList = *args.AccessList
|
||||
}
|
||||
return &core.Message{
|
||||
From: args.from(),
|
||||
To: args.To,
|
||||
Value: (*big.Int)(args.Value),
|
||||
Nonce: uint64(*args.Nonce),
|
||||
GasLimit: uint64(*args.Gas),
|
||||
GasPrice: gasPrice,
|
||||
GasFeeCap: gasFeeCap,
|
||||
GasTipCap: gasTipCap,
|
||||
Data: args.data(),
|
||||
AccessList: accessList,
|
||||
BlobGasFeeCap: (*big.Int)(args.BlobFeeCap),
|
||||
BlobHashes: args.BlobHashes,
|
||||
AuthList: args.AuthorizationList,
|
||||
SkipNonceChecks: skipNonceCheck,
|
||||
SkipFromEOACheck: skipEoACheck,
|
||||
From: args.from(),
|
||||
To: args.To,
|
||||
Value: (*big.Int)(args.Value),
|
||||
Nonce: uint64(*args.Nonce),
|
||||
GasLimit: uint64(*args.Gas),
|
||||
GasPrice: gasPrice,
|
||||
GasFeeCap: gasFeeCap,
|
||||
GasTipCap: gasTipCap,
|
||||
Data: args.data(),
|
||||
AccessList: accessList,
|
||||
BlobGasFeeCap: (*big.Int)(args.BlobFeeCap),
|
||||
BlobHashes: args.BlobHashes,
|
||||
SetCodeAuthorizations: args.AuthorizationList,
|
||||
SkipNonceChecks: skipNonceCheck,
|
||||
SkipFromEOACheck: skipEoACheck,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -457,19 +457,19 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
|
|||
}
|
||||
|
||||
msg := &core.Message{
|
||||
From: from,
|
||||
To: to,
|
||||
Nonce: tx.Nonce,
|
||||
Value: value,
|
||||
GasLimit: gasLimit,
|
||||
GasPrice: gasPrice,
|
||||
GasFeeCap: tx.MaxFeePerGas,
|
||||
GasTipCap: tx.MaxPriorityFeePerGas,
|
||||
Data: data,
|
||||
AccessList: accessList,
|
||||
BlobHashes: tx.BlobVersionedHashes,
|
||||
BlobGasFeeCap: tx.BlobGasFeeCap,
|
||||
AuthList: authList,
|
||||
From: from,
|
||||
To: to,
|
||||
Nonce: tx.Nonce,
|
||||
Value: value,
|
||||
GasLimit: gasLimit,
|
||||
GasPrice: gasPrice,
|
||||
GasFeeCap: tx.MaxFeePerGas,
|
||||
GasTipCap: tx.MaxPriorityFeePerGas,
|
||||
Data: data,
|
||||
AccessList: accessList,
|
||||
BlobHashes: tx.BlobVersionedHashes,
|
||||
BlobGasFeeCap: tx.BlobGasFeeCap,
|
||||
SetCodeAuthorizations: authList,
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
|
|||
return nil, nil, err
|
||||
}
|
||||
// Intrinsic gas
|
||||
requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.AuthList(), tx.To() == nil, isHomestead, isIstanbul, false)
|
||||
requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, isHomestead, isIstanbul, false)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue