Skip to content

Commit

Permalink
remove GetAuthorization function from Transaction interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeepdino008 committed Jul 12, 2024
1 parent 7f6416e commit f92c5ed
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
1 change: 0 additions & 1 deletion core/types/blob_tx_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions core/types/legacy_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions core/types/set_code_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tests/transaction_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions turbo/jsonrpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f92c5ed

Please sign in to comment.