mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
core/types: remove AuthorizationList and use Authorization as value instead of pointer
This commit is contained in:
parent
d3e82b485d
commit
b8fb4d68de
8 changed files with 63 additions and 68 deletions
|
|
@ -4273,13 +4273,12 @@ func TestEIP7702(t *testing.T) {
|
|||
// 1. tx -> addr1 which is delegated to 0xaaaa
|
||||
// 2. addr1:0xaaaa calls into addr2:0xbbbb
|
||||
// 3. addr2:0xbbbb writes to storage
|
||||
auth1, _ := types.SignAuth(&types.Authorization{
|
||||
auth1, _ := types.SignAuth(types.Authorization{
|
||||
ChainID: gspec.Config.ChainID.Uint64(),
|
||||
Address: aa,
|
||||
Nonce: 1,
|
||||
}, key1)
|
||||
|
||||
auth2, _ := types.SignAuth(&types.Authorization{
|
||||
auth2, _ := types.SignAuth(types.Authorization{
|
||||
ChainID: 0,
|
||||
Address: bb,
|
||||
Nonce: 0,
|
||||
|
|
@ -4294,7 +4293,7 @@ func TestEIP7702(t *testing.T) {
|
|||
Gas: 500000,
|
||||
GasFeeCap: uint256.MustFromBig(newGwei(5)),
|
||||
GasTipCap: uint256.NewInt(2),
|
||||
AuthList: []*types.Authorization{auth1, auth2},
|
||||
AuthList: []types.Authorization{auth1, auth2},
|
||||
}
|
||||
tx := types.MustSignNewTx(key1, signer, txdata)
|
||||
b.AddTx(tx)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func (result *ExecutionResult) Revert() []byte {
|
|||
}
|
||||
|
||||
// IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
|
||||
func IntrinsicGas(data []byte, accessList types.AccessList, authList types.AuthorizationList, isContractCreation, isHomestead, isEIP2028, isEIP3860 bool) (uint64, error) {
|
||||
func IntrinsicGas(data []byte, accessList types.AccessList, authList []types.Authorization, isContractCreation, isHomestead, isEIP2028, isEIP3860 bool) (uint64, error) {
|
||||
// Set the starting gas for the raw transaction
|
||||
var gas uint64
|
||||
if isContractCreation && isHomestead {
|
||||
|
|
@ -143,7 +143,7 @@ type Message struct {
|
|||
AccessList types.AccessList
|
||||
BlobGasFeeCap *big.Int
|
||||
BlobHashes []common.Hash
|
||||
AuthList types.AuthorizationList
|
||||
AuthList []types.Authorization
|
||||
|
||||
// When SkipNonceChecks is true, the message nonce is not checked against the
|
||||
// account nonce in state.
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ func (tx *Transaction) WithBlobTxSidecar(sideCar *BlobTxSidecar) *Transaction {
|
|||
}
|
||||
|
||||
// AuthList returns the authorizations list of the transaction.
|
||||
func (tx *Transaction) AuthList() AuthorizationList {
|
||||
func (tx *Transaction) AuthList() []Authorization {
|
||||
setcodetx, ok := tx.inner.(*SetCodeTx)
|
||||
if !ok {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -31,23 +31,23 @@ import (
|
|||
type txJSON struct {
|
||||
Type hexutil.Uint64 `json:"type"`
|
||||
|
||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||
Nonce *hexutil.Uint64 `json:"nonce"`
|
||||
To *common.Address `json:"to"`
|
||||
Gas *hexutil.Uint64 `json:"gas"`
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
||||
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Input *hexutil.Bytes `json:"input"`
|
||||
AccessList *AccessList `json:"accessList,omitempty"`
|
||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||
AuthorizationList *AuthorizationList `json:"authorizationList,omitempty"`
|
||||
V *hexutil.Big `json:"v"`
|
||||
R *hexutil.Big `json:"r"`
|
||||
S *hexutil.Big `json:"s"`
|
||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||
Nonce *hexutil.Uint64 `json:"nonce"`
|
||||
To *common.Address `json:"to"`
|
||||
Gas *hexutil.Uint64 `json:"gas"`
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
||||
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Input *hexutil.Bytes `json:"input"`
|
||||
AccessList *AccessList `json:"accessList,omitempty"`
|
||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||
AuthorizationList []Authorization `json:"authorizationList,omitempty"`
|
||||
V *hexutil.Big `json:"v"`
|
||||
R *hexutil.Big `json:"r"`
|
||||
S *hexutil.Big `json:"s"`
|
||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||
|
||||
// Blob transaction sidecar encoding:
|
||||
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
||||
|
|
@ -164,7 +164,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
|
|||
enc.Value = (*hexutil.Big)(itx.Value.ToBig())
|
||||
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
||||
enc.AccessList = &itx.AccessList
|
||||
enc.AuthorizationList = &itx.AuthList
|
||||
enc.AuthorizationList = itx.AuthList
|
||||
enc.V = (*hexutil.Big)(itx.V.ToBig())
|
||||
enc.R = (*hexutil.Big)(itx.R.ToBig())
|
||||
enc.S = (*hexutil.Big)(itx.S.ToBig())
|
||||
|
|
@ -467,7 +467,7 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
|
|||
if dec.AuthorizationList == nil {
|
||||
return errors.New("missing required field 'authorizationList' in transaction")
|
||||
}
|
||||
itx.AuthList = *dec.AuthorizationList
|
||||
itx.AuthList = dec.AuthorizationList
|
||||
|
||||
// signature R
|
||||
var overflow bool
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ type SetCodeTx struct {
|
|||
Value *uint256.Int
|
||||
Data []byte
|
||||
AccessList AccessList
|
||||
AuthList AuthorizationList
|
||||
AuthList []Authorization
|
||||
|
||||
// Signature values
|
||||
V *uint256.Int `json:"v" gencodec:"required"`
|
||||
|
|
@ -89,7 +89,7 @@ type authorizationMarshaling struct {
|
|||
}
|
||||
|
||||
// SignAuth signs the provided authorization.
|
||||
func SignAuth(auth *Authorization, prv *ecdsa.PrivateKey) (*Authorization, error) {
|
||||
func SignAuth(auth Authorization, prv *ecdsa.PrivateKey) (Authorization, error) {
|
||||
h := prefixedRlpHash(
|
||||
0x05,
|
||||
[]interface{}{
|
||||
|
|
@ -100,16 +100,16 @@ func SignAuth(auth *Authorization, prv *ecdsa.PrivateKey) (*Authorization, error
|
|||
|
||||
sig, err := crypto.Sign(h[:], prv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return Authorization{}, err
|
||||
}
|
||||
return auth.withSignature(sig), nil
|
||||
}
|
||||
|
||||
// withSignature updates the signature of an Authorization to be equal the
|
||||
// decoded signature provided in sig.
|
||||
func (a *Authorization) withSignature(sig []byte) *Authorization {
|
||||
func (a *Authorization) withSignature(sig []byte) Authorization {
|
||||
r, s, _ := decodeSignature(sig)
|
||||
cpy := Authorization{
|
||||
return Authorization{
|
||||
ChainID: a.ChainID,
|
||||
Address: a.Address,
|
||||
Nonce: a.Nonce,
|
||||
|
|
@ -117,11 +117,8 @@ func (a *Authorization) withSignature(sig []byte) *Authorization {
|
|||
R: r,
|
||||
S: s,
|
||||
}
|
||||
return &cpy
|
||||
}
|
||||
|
||||
type AuthorizationList []*Authorization
|
||||
|
||||
// Authority recovers the authorizing
|
||||
func (a Authorization) Authority() (common.Address, error) {
|
||||
sighash := prefixedRlpHash(
|
||||
|
|
@ -162,7 +159,7 @@ func (tx *SetCodeTx) copy() TxData {
|
|||
Gas: tx.Gas,
|
||||
// These are copied below.
|
||||
AccessList: make(AccessList, len(tx.AccessList)),
|
||||
AuthList: make(AuthorizationList, len(tx.AuthList)),
|
||||
AuthList: make([]Authorization, len(tx.AuthList)),
|
||||
Value: new(uint256.Int),
|
||||
ChainID: tx.ChainID,
|
||||
GasTipCap: new(uint256.Int),
|
||||
|
|
|
|||
|
|
@ -937,29 +937,29 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
|
|||
|
||||
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
||||
type RPCTransaction struct {
|
||||
BlockHash *common.Hash `json:"blockHash"`
|
||||
BlockNumber *hexutil.Big `json:"blockNumber"`
|
||||
From common.Address `json:"from"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
|
||||
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
Hash common.Hash `json:"hash"`
|
||||
Input hexutil.Bytes `json:"input"`
|
||||
Nonce hexutil.Uint64 `json:"nonce"`
|
||||
To *common.Address `json:"to"`
|
||||
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Type hexutil.Uint64 `json:"type"`
|
||||
Accesses *types.AccessList `json:"accessList,omitempty"`
|
||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||
AuthorizationList types.AuthorizationList `json:"authorizationList,omitempty"`
|
||||
V *hexutil.Big `json:"v"`
|
||||
R *hexutil.Big `json:"r"`
|
||||
S *hexutil.Big `json:"s"`
|
||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||
BlockHash *common.Hash `json:"blockHash"`
|
||||
BlockNumber *hexutil.Big `json:"blockNumber"`
|
||||
From common.Address `json:"from"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
|
||||
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
Hash common.Hash `json:"hash"`
|
||||
Input hexutil.Bytes `json:"input"`
|
||||
Nonce hexutil.Uint64 `json:"nonce"`
|
||||
To *common.Address `json:"to"`
|
||||
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Type hexutil.Uint64 `json:"type"`
|
||||
Accesses *types.AccessList `json:"accessList,omitempty"`
|
||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||
AuthorizationList []types.Authorization `json:"authorizationList,omitempty"`
|
||||
V *hexutil.Big `json:"v"`
|
||||
R *hexutil.Big `json:"r"`
|
||||
S *hexutil.Big `json:"s"`
|
||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||
}
|
||||
|
||||
// newRPCTransaction returns a transaction that will serialize to the RPC
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ type TransactionArgs struct {
|
|||
Proofs []kzg4844.Proof `json:"proofs"`
|
||||
|
||||
// For SetCodeTxType
|
||||
AuthList *types.AuthorizationList `json:"authList"`
|
||||
AuthList []types.Authorization `json:"authList"`
|
||||
|
||||
// This configures whether blobs are allowed to be passed.
|
||||
blobSidecarAllowed bool
|
||||
|
|
@ -496,9 +496,9 @@ func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction {
|
|||
if args.AccessList != nil {
|
||||
al = *args.AccessList
|
||||
}
|
||||
authList := types.AuthorizationList{}
|
||||
authList := []types.Authorization{}
|
||||
if args.AuthList != nil {
|
||||
authList = *args.AuthList
|
||||
authList = args.AuthList
|
||||
}
|
||||
data = &types.SetCodeTx{
|
||||
To: *args.To,
|
||||
|
|
|
|||
|
|
@ -138,8 +138,7 @@ type stTransactionMarshaling struct {
|
|||
|
||||
//go:generate go run github.com/fjl/gencodec -type stAuthorization -field-override stAuthorizationMarshaling -out gen_stauthorization.go
|
||||
|
||||
// Authorization is an authorization from an account to deploy code at it's
|
||||
// address.
|
||||
// Authorization is an authorization from an account to deploy code at it's address.
|
||||
type stAuthorization struct {
|
||||
ChainID uint64
|
||||
Address common.Address `json:"address" gencodec:"required"`
|
||||
|
|
@ -442,18 +441,18 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
|
|||
if gasPrice == nil {
|
||||
return nil, errors.New("no gas price provided")
|
||||
}
|
||||
var authList types.AuthorizationList
|
||||
var authList []types.Authorization
|
||||
if tx.AuthorizationList != nil {
|
||||
authList = make(types.AuthorizationList, 0)
|
||||
for _, auth := range tx.AuthorizationList {
|
||||
authList = append(authList, &types.Authorization{
|
||||
authList = make([]types.Authorization, len(tx.AuthorizationList))
|
||||
for i, auth := range tx.AuthorizationList {
|
||||
authList[i] = types.Authorization{
|
||||
ChainID: auth.ChainID,
|
||||
Address: auth.Address,
|
||||
Nonce: auth.Nonce,
|
||||
V: auth.V,
|
||||
R: auth.R,
|
||||
S: auth.S,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue