From f92c5ed72c2ec949108d1d8a23bfcd26e6c6952e Mon Sep 17 00:00:00 2001 From: sudeepdino008 Date: Fri, 12 Jul 2024 11:49:23 +0530 Subject: [PATCH] remove GetAuthorization function from Transaction interface --- core/state_transition.go | 2 +- core/types/blob_tx_wrapper.go | 1 - core/types/legacy_tx.go | 4 ---- core/types/set_code_tx.go | 4 ++++ core/types/transaction.go | 1 - tests/transaction_test_util.go | 6 +++++- turbo/jsonrpc/eth_api.go | 5 +++-- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 0c731c6fd81..013911f00b4 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -390,7 +390,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype // 6. add authority account to accesses_addresses verifiedAuthorities = append(verifiedAuthorities, authority) - // authority is added to acceessed_address in prepare step + // authority is added to accessed_address in prepare step } } diff --git a/core/types/blob_tx_wrapper.go b/core/types/blob_tx_wrapper.go index 056ea998336..65315f2467b 100644 --- a/core/types/blob_tx_wrapper.go +++ b/core/types/blob_tx_wrapper.go @@ -319,7 +319,6 @@ func (txw *BlobTxWrapper) GetGas() uint64 { return txw.Tx.Ge func (txw *BlobTxWrapper) GetBlobGas() uint64 { return txw.Tx.GetBlobGas() } func (txw *BlobTxWrapper) GetValue() *uint256.Int { return txw.Tx.GetValue() } func (txw *BlobTxWrapper) GetTo() *libcommon.Address { return txw.Tx.GetTo() } -func (txw *BlobTxWrapper) GetAuthorizations() []Authorization { return txw.Tx.GetAuthorizations() } func (txw *BlobTxWrapper) AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Message, error) { return txw.Tx.AsMessage(s, baseFee, rules) diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index d8e7dc836f1..f20700f648b 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -94,10 +94,6 @@ func (ct *CommonTx) GetBlobHashes() []libcommon.Hash { return []libcommon.Hash{} } -func (ct *CommonTx) GetAuthorizations() []Authorization { - return nil -} - // LegacyTx is the transaction data of regular Ethereum transactions. type LegacyTx struct { CommonTx diff --git a/core/types/set_code_tx.go b/core/types/set_code_tx.go index a3113a44e84..937e05a959d 100644 --- a/core/types/set_code_tx.go +++ b/core/types/set_code_tx.go @@ -32,6 +32,10 @@ func (tx *SetCodeTransaction) GetBlobHashes() []libcommon.Hash { return []libcommon.Hash{} } +func (tx *SetCodeTransaction) GetAuthorizations() []Authorization { + return tx.Authorizations +} + func (tx *SetCodeTransaction) copy() *SetCodeTransaction { cpy := &SetCodeTransaction{} cpy.DynamicFeeTransaction = *tx.DynamicFeeTransaction.copy() diff --git a/core/types/transaction.go b/core/types/transaction.go index d7c4a8a190d..369276467e0 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -72,7 +72,6 @@ type Transaction interface { GetBlobGas() uint64 GetValue() *uint256.Int GetTo() *libcommon.Address - GetAuthorizations() []Authorization AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Message, error) WithSignature(signer Signer, sig []byte) (Transaction, error) FakeSign(address libcommon.Address) Transaction diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index b0dc36ab557..faafe4e32a9 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -74,7 +74,11 @@ func (tt *TransactionTest) Run(chainID *big.Int) error { sender := msg.From() // Intrinsic gas - requiredGas, err := core.IntrinsicGas(msg.Data(), msg.AccessList(), msg.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai, uint64(len(tx.GetAuthorizations()))) + authorizationsLen := uint64(0) + if stx, ok := tx.(*types.SetCodeTransaction); ok { + authorizationsLen = uint64(len(stx.GetAuthorizations())) + } + requiredGas, err := core.IntrinsicGas(msg.Data(), msg.AccessList(), msg.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai, authorizationsLen) if err != nil { return nil, nil, 0, err } diff --git a/turbo/jsonrpc/eth_api.go b/turbo/jsonrpc/eth_api.go index 2dd9d9da5dd..07cbc3d5f3d 100644 --- a/turbo/jsonrpc/eth_api.go +++ b/turbo/jsonrpc/eth_api.go @@ -461,8 +461,9 @@ func NewRPCTransaction(txn types.Transaction, blockHash common.Hash, blockNumber result.MaxFeePerBlobGas = (*hexutil.Big)(blobTx.MaxFeePerBlobGas.ToBig()) result.BlobVersionedHashes = blobTx.BlobVersionedHashes } else if txn.Type() == types.SetCodeTxType { - ats := make([]types.JsonAuthorization, len(txn.GetAuthorizations())) - for i, a := range txn.GetAuthorizations() { + setCodeTx := txn.(*types.SetCodeTransaction) + ats := make([]types.JsonAuthorization, len(setCodeTx.GetAuthorizations())) + for i, a := range setCodeTx.GetAuthorizations() { ats[i] = types.JsonAuthorization{}.FromAuthorization(a) } result.Authorizations = &ats