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
|
// 1. tx -> addr1 which is delegated to 0xaaaa
|
||||||
// 2. addr1:0xaaaa calls into addr2:0xbbbb
|
// 2. addr1:0xaaaa calls into addr2:0xbbbb
|
||||||
// 3. addr2:0xbbbb writes to storage
|
// 3. addr2:0xbbbb writes to storage
|
||||||
auth1, _ := types.SignAuth(&types.Authorization{
|
auth1, _ := types.SignAuth(types.Authorization{
|
||||||
ChainID: gspec.Config.ChainID.Uint64(),
|
ChainID: gspec.Config.ChainID.Uint64(),
|
||||||
Address: aa,
|
Address: aa,
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
}, key1)
|
}, key1)
|
||||||
|
auth2, _ := types.SignAuth(types.Authorization{
|
||||||
auth2, _ := types.SignAuth(&types.Authorization{
|
|
||||||
ChainID: 0,
|
ChainID: 0,
|
||||||
Address: bb,
|
Address: bb,
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
|
|
@ -4294,7 +4293,7 @@ func TestEIP7702(t *testing.T) {
|
||||||
Gas: 500000,
|
Gas: 500000,
|
||||||
GasFeeCap: uint256.MustFromBig(newGwei(5)),
|
GasFeeCap: uint256.MustFromBig(newGwei(5)),
|
||||||
GasTipCap: uint256.NewInt(2),
|
GasTipCap: uint256.NewInt(2),
|
||||||
AuthList: []*types.Authorization{auth1, auth2},
|
AuthList: []types.Authorization{auth1, auth2},
|
||||||
}
|
}
|
||||||
tx := types.MustSignNewTx(key1, signer, txdata)
|
tx := types.MustSignNewTx(key1, signer, txdata)
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func (result *ExecutionResult) Revert() []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
|
// 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
|
// Set the starting gas for the raw transaction
|
||||||
var gas uint64
|
var gas uint64
|
||||||
if isContractCreation && isHomestead {
|
if isContractCreation && isHomestead {
|
||||||
|
|
@ -143,7 +143,7 @@ type Message struct {
|
||||||
AccessList types.AccessList
|
AccessList types.AccessList
|
||||||
BlobGasFeeCap *big.Int
|
BlobGasFeeCap *big.Int
|
||||||
BlobHashes []common.Hash
|
BlobHashes []common.Hash
|
||||||
AuthList types.AuthorizationList
|
AuthList []types.Authorization
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
||||||
|
|
@ -475,7 +475,7 @@ func (tx *Transaction) WithBlobTxSidecar(sideCar *BlobTxSidecar) *Transaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthList returns the authorizations list of the transaction.
|
// AuthList returns the authorizations list of the transaction.
|
||||||
func (tx *Transaction) AuthList() AuthorizationList {
|
func (tx *Transaction) AuthList() []Authorization {
|
||||||
setcodetx, ok := tx.inner.(*SetCodeTx)
|
setcodetx, ok := tx.inner.(*SetCodeTx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -31,23 +31,23 @@ import (
|
||||||
type txJSON struct {
|
type txJSON struct {
|
||||||
Type hexutil.Uint64 `json:"type"`
|
Type hexutil.Uint64 `json:"type"`
|
||||||
|
|
||||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||||
Nonce *hexutil.Uint64 `json:"nonce"`
|
Nonce *hexutil.Uint64 `json:"nonce"`
|
||||||
To *common.Address `json:"to"`
|
To *common.Address `json:"to"`
|
||||||
Gas *hexutil.Uint64 `json:"gas"`
|
Gas *hexutil.Uint64 `json:"gas"`
|
||||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||||
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
||||||
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
||||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||||
Value *hexutil.Big `json:"value"`
|
Value *hexutil.Big `json:"value"`
|
||||||
Input *hexutil.Bytes `json:"input"`
|
Input *hexutil.Bytes `json:"input"`
|
||||||
AccessList *AccessList `json:"accessList,omitempty"`
|
AccessList *AccessList `json:"accessList,omitempty"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
AuthorizationList *AuthorizationList `json:"authorizationList,omitempty"`
|
AuthorizationList []Authorization `json:"authorizationList,omitempty"`
|
||||||
V *hexutil.Big `json:"v"`
|
V *hexutil.Big `json:"v"`
|
||||||
R *hexutil.Big `json:"r"`
|
R *hexutil.Big `json:"r"`
|
||||||
S *hexutil.Big `json:"s"`
|
S *hexutil.Big `json:"s"`
|
||||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||||
|
|
||||||
// Blob transaction sidecar encoding:
|
// Blob transaction sidecar encoding:
|
||||||
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
Blobs []kzg4844.Blob `json:"blobs,omitempty"`
|
||||||
|
|
@ -164,7 +164,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
|
||||||
enc.Value = (*hexutil.Big)(itx.Value.ToBig())
|
enc.Value = (*hexutil.Big)(itx.Value.ToBig())
|
||||||
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
||||||
enc.AccessList = &itx.AccessList
|
enc.AccessList = &itx.AccessList
|
||||||
enc.AuthorizationList = &itx.AuthList
|
enc.AuthorizationList = itx.AuthList
|
||||||
enc.V = (*hexutil.Big)(itx.V.ToBig())
|
enc.V = (*hexutil.Big)(itx.V.ToBig())
|
||||||
enc.R = (*hexutil.Big)(itx.R.ToBig())
|
enc.R = (*hexutil.Big)(itx.R.ToBig())
|
||||||
enc.S = (*hexutil.Big)(itx.S.ToBig())
|
enc.S = (*hexutil.Big)(itx.S.ToBig())
|
||||||
|
|
@ -467,7 +467,7 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
|
||||||
if dec.AuthorizationList == nil {
|
if dec.AuthorizationList == nil {
|
||||||
return errors.New("missing required field 'authorizationList' in transaction")
|
return errors.New("missing required field 'authorizationList' in transaction")
|
||||||
}
|
}
|
||||||
itx.AuthList = *dec.AuthorizationList
|
itx.AuthList = dec.AuthorizationList
|
||||||
|
|
||||||
// signature R
|
// signature R
|
||||||
var overflow bool
|
var overflow bool
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ type SetCodeTx struct {
|
||||||
Value *uint256.Int
|
Value *uint256.Int
|
||||||
Data []byte
|
Data []byte
|
||||||
AccessList AccessList
|
AccessList AccessList
|
||||||
AuthList AuthorizationList
|
AuthList []Authorization
|
||||||
|
|
||||||
// Signature values
|
// Signature values
|
||||||
V *uint256.Int `json:"v" gencodec:"required"`
|
V *uint256.Int `json:"v" gencodec:"required"`
|
||||||
|
|
@ -89,7 +89,7 @@ type authorizationMarshaling struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignAuth signs the provided authorization.
|
// 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(
|
h := prefixedRlpHash(
|
||||||
0x05,
|
0x05,
|
||||||
[]interface{}{
|
[]interface{}{
|
||||||
|
|
@ -100,16 +100,16 @@ func SignAuth(auth *Authorization, prv *ecdsa.PrivateKey) (*Authorization, error
|
||||||
|
|
||||||
sig, err := crypto.Sign(h[:], prv)
|
sig, err := crypto.Sign(h[:], prv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return Authorization{}, err
|
||||||
}
|
}
|
||||||
return auth.withSignature(sig), nil
|
return auth.withSignature(sig), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// withSignature updates the signature of an Authorization to be equal the
|
// withSignature updates the signature of an Authorization to be equal the
|
||||||
// decoded signature provided in sig.
|
// decoded signature provided in sig.
|
||||||
func (a *Authorization) withSignature(sig []byte) *Authorization {
|
func (a *Authorization) withSignature(sig []byte) Authorization {
|
||||||
r, s, _ := decodeSignature(sig)
|
r, s, _ := decodeSignature(sig)
|
||||||
cpy := Authorization{
|
return Authorization{
|
||||||
ChainID: a.ChainID,
|
ChainID: a.ChainID,
|
||||||
Address: a.Address,
|
Address: a.Address,
|
||||||
Nonce: a.Nonce,
|
Nonce: a.Nonce,
|
||||||
|
|
@ -117,11 +117,8 @@ func (a *Authorization) withSignature(sig []byte) *Authorization {
|
||||||
R: r,
|
R: r,
|
||||||
S: s,
|
S: s,
|
||||||
}
|
}
|
||||||
return &cpy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorizationList []*Authorization
|
|
||||||
|
|
||||||
// Authority recovers the authorizing
|
// Authority recovers the authorizing
|
||||||
func (a Authorization) Authority() (common.Address, error) {
|
func (a Authorization) Authority() (common.Address, error) {
|
||||||
sighash := prefixedRlpHash(
|
sighash := prefixedRlpHash(
|
||||||
|
|
@ -162,7 +159,7 @@ func (tx *SetCodeTx) copy() TxData {
|
||||||
Gas: tx.Gas,
|
Gas: tx.Gas,
|
||||||
// These are copied below.
|
// These are copied below.
|
||||||
AccessList: make(AccessList, len(tx.AccessList)),
|
AccessList: make(AccessList, len(tx.AccessList)),
|
||||||
AuthList: make(AuthorizationList, len(tx.AuthList)),
|
AuthList: make([]Authorization, len(tx.AuthList)),
|
||||||
Value: new(uint256.Int),
|
Value: new(uint256.Int),
|
||||||
ChainID: tx.ChainID,
|
ChainID: tx.ChainID,
|
||||||
GasTipCap: new(uint256.Int),
|
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
|
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
||||||
type RPCTransaction struct {
|
type RPCTransaction struct {
|
||||||
BlockHash *common.Hash `json:"blockHash"`
|
BlockHash *common.Hash `json:"blockHash"`
|
||||||
BlockNumber *hexutil.Big `json:"blockNumber"`
|
BlockNumber *hexutil.Big `json:"blockNumber"`
|
||||||
From common.Address `json:"from"`
|
From common.Address `json:"from"`
|
||||||
Gas hexutil.Uint64 `json:"gas"`
|
Gas hexutil.Uint64 `json:"gas"`
|
||||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||||
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
|
GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
|
||||||
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
|
GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
|
||||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
Input hexutil.Bytes `json:"input"`
|
Input hexutil.Bytes `json:"input"`
|
||||||
Nonce hexutil.Uint64 `json:"nonce"`
|
Nonce hexutil.Uint64 `json:"nonce"`
|
||||||
To *common.Address `json:"to"`
|
To *common.Address `json:"to"`
|
||||||
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
|
||||||
Value *hexutil.Big `json:"value"`
|
Value *hexutil.Big `json:"value"`
|
||||||
Type hexutil.Uint64 `json:"type"`
|
Type hexutil.Uint64 `json:"type"`
|
||||||
Accesses *types.AccessList `json:"accessList,omitempty"`
|
Accesses *types.AccessList `json:"accessList,omitempty"`
|
||||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
AuthorizationList types.AuthorizationList `json:"authorizationList,omitempty"`
|
AuthorizationList []types.Authorization `json:"authorizationList,omitempty"`
|
||||||
V *hexutil.Big `json:"v"`
|
V *hexutil.Big `json:"v"`
|
||||||
R *hexutil.Big `json:"r"`
|
R *hexutil.Big `json:"r"`
|
||||||
S *hexutil.Big `json:"s"`
|
S *hexutil.Big `json:"s"`
|
||||||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// newRPCTransaction returns a transaction that will serialize to the RPC
|
// newRPCTransaction returns a transaction that will serialize to the RPC
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ type TransactionArgs struct {
|
||||||
Proofs []kzg4844.Proof `json:"proofs"`
|
Proofs []kzg4844.Proof `json:"proofs"`
|
||||||
|
|
||||||
// For SetCodeTxType
|
// For SetCodeTxType
|
||||||
AuthList *types.AuthorizationList `json:"authList"`
|
AuthList []types.Authorization `json:"authList"`
|
||||||
|
|
||||||
// This configures whether blobs are allowed to be passed.
|
// This configures whether blobs are allowed to be passed.
|
||||||
blobSidecarAllowed bool
|
blobSidecarAllowed bool
|
||||||
|
|
@ -496,9 +496,9 @@ func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction {
|
||||||
if args.AccessList != nil {
|
if args.AccessList != nil {
|
||||||
al = *args.AccessList
|
al = *args.AccessList
|
||||||
}
|
}
|
||||||
authList := types.AuthorizationList{}
|
authList := []types.Authorization{}
|
||||||
if args.AuthList != nil {
|
if args.AuthList != nil {
|
||||||
authList = *args.AuthList
|
authList = args.AuthList
|
||||||
}
|
}
|
||||||
data = &types.SetCodeTx{
|
data = &types.SetCodeTx{
|
||||||
To: *args.To,
|
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
|
//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
|
// Authorization is an authorization from an account to deploy code at it's address.
|
||||||
// address.
|
|
||||||
type stAuthorization struct {
|
type stAuthorization struct {
|
||||||
ChainID uint64
|
ChainID uint64
|
||||||
Address common.Address `json:"address" gencodec:"required"`
|
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 {
|
if gasPrice == nil {
|
||||||
return nil, errors.New("no gas price provided")
|
return nil, errors.New("no gas price provided")
|
||||||
}
|
}
|
||||||
var authList types.AuthorizationList
|
var authList []types.Authorization
|
||||||
if tx.AuthorizationList != nil {
|
if tx.AuthorizationList != nil {
|
||||||
authList = make(types.AuthorizationList, 0)
|
authList = make([]types.Authorization, len(tx.AuthorizationList))
|
||||||
for _, auth := range tx.AuthorizationList {
|
for i, auth := range tx.AuthorizationList {
|
||||||
authList = append(authList, &types.Authorization{
|
authList[i] = types.Authorization{
|
||||||
ChainID: auth.ChainID,
|
ChainID: auth.ChainID,
|
||||||
Address: auth.Address,
|
Address: auth.Address,
|
||||||
Nonce: auth.Nonce,
|
Nonce: auth.Nonce,
|
||||||
V: auth.V,
|
V: auth.V,
|
||||||
R: auth.R,
|
R: auth.R,
|
||||||
S: auth.S,
|
S: auth.S,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue