mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rename to blobHashes and blobFeeCap
This commit is contained in:
parent
c90642a3ba
commit
b5c6a9ba80
3 changed files with 44 additions and 44 deletions
|
|
@ -747,11 +747,11 @@ func TestEstimateGas(t *testing.T) {
|
||||||
{
|
{
|
||||||
blockNumber: rpc.LatestBlockNumber,
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
call: TransactionArgs{
|
call: TransactionArgs{
|
||||||
From: &accounts[0].addr,
|
From: &accounts[0].addr,
|
||||||
To: &accounts[1].addr,
|
To: &accounts[1].addr,
|
||||||
Value: (*hexutil.Big)(big.NewInt(1)),
|
Value: (*hexutil.Big)(big.NewInt(1)),
|
||||||
BlobVersionedHashes: []common.Hash{common.Hash{0x01, 0x22}},
|
BlobHashes: []common.Hash{common.Hash{0x01, 0x22}},
|
||||||
MaxFeePerBlobGas: (*hexutil.Big)(big.NewInt(1)),
|
BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
|
||||||
},
|
},
|
||||||
want: 21000,
|
want: 21000,
|
||||||
},
|
},
|
||||||
|
|
@ -926,9 +926,9 @@ func TestCall(t *testing.T) {
|
||||||
{
|
{
|
||||||
blockNumber: rpc.LatestBlockNumber,
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
call: TransactionArgs{
|
call: TransactionArgs{
|
||||||
From: &accounts[1].addr,
|
From: &accounts[1].addr,
|
||||||
Input: &hexutil.Bytes{0x00},
|
Input: &hexutil.Bytes{0x00},
|
||||||
BlobVersionedHashes: []common.Hash{},
|
BlobHashes: []common.Hash{},
|
||||||
},
|
},
|
||||||
expectErr: core.ErrBlobTxCreate,
|
expectErr: core.ErrBlobTxCreate,
|
||||||
},
|
},
|
||||||
|
|
@ -936,10 +936,10 @@ func TestCall(t *testing.T) {
|
||||||
{
|
{
|
||||||
blockNumber: rpc.LatestBlockNumber,
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
call: TransactionArgs{
|
call: TransactionArgs{
|
||||||
From: &accounts[1].addr,
|
From: &accounts[1].addr,
|
||||||
To: &randomAccounts[2].addr,
|
To: &randomAccounts[2].addr,
|
||||||
BlobVersionedHashes: []common.Hash{common.Hash{0x01, 0x22}},
|
BlobHashes: []common.Hash{common.Hash{0x01, 0x22}},
|
||||||
MaxFeePerBlobGas: (*hexutil.Big)(big.NewInt(1)),
|
BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
|
||||||
},
|
},
|
||||||
overrides: StateOverride{
|
overrides: StateOverride{
|
||||||
randomAccounts[2].addr: {
|
randomAccounts[2].addr: {
|
||||||
|
|
@ -1028,10 +1028,10 @@ func TestSignBlobTransaction(t *testing.T) {
|
||||||
})
|
})
|
||||||
api := NewTransactionAPI(b, nil)
|
api := NewTransactionAPI(b, nil)
|
||||||
res, err := api.FillTransaction(context.Background(), TransactionArgs{
|
res, err := api.FillTransaction(context.Background(), TransactionArgs{
|
||||||
From: &b.acc.Address,
|
From: &b.acc.Address,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: (*hexutil.Big)(big.NewInt(1)),
|
Value: (*hexutil.Big)(big.NewInt(1)),
|
||||||
BlobVersionedHashes: []common.Hash{{0x01, 0x22}},
|
BlobHashes: []common.Hash{{0x01, 0x22}},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to fill tx defaults: %v\n", err)
|
t.Fatalf("failed to fill tx defaults: %v\n", err)
|
||||||
|
|
@ -1062,10 +1062,10 @@ func TestSendBlobTransaction(t *testing.T) {
|
||||||
})
|
})
|
||||||
api := NewTransactionAPI(b, nil)
|
api := NewTransactionAPI(b, nil)
|
||||||
res, err := api.FillTransaction(context.Background(), TransactionArgs{
|
res, err := api.FillTransaction(context.Background(), TransactionArgs{
|
||||||
From: &b.acc.Address,
|
From: &b.acc.Address,
|
||||||
To: &to,
|
To: &to,
|
||||||
Value: (*hexutil.Big)(big.NewInt(1)),
|
Value: (*hexutil.Big)(big.NewInt(1)),
|
||||||
BlobVersionedHashes: []common.Hash{common.Hash{0x01, 0x22}},
|
BlobHashes: []common.Hash{common.Hash{0x01, 0x22}},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to fill tx defaults: %v\n", err)
|
t.Fatalf("failed to fill tx defaults: %v\n", err)
|
||||||
|
|
@ -1097,8 +1097,8 @@ func argsFromTransaction(tx *types.Transaction, from common.Address) Transaction
|
||||||
ChainID: (*hexutil.Big)(tx.ChainId()),
|
ChainID: (*hexutil.Big)(tx.ChainId()),
|
||||||
// TODO: impl accessList conversion
|
// TODO: impl accessList conversion
|
||||||
//AccessList: tx.AccessList(),
|
//AccessList: tx.AccessList(),
|
||||||
MaxFeePerBlobGas: (*hexutil.Big)(tx.BlobGasFeeCap()),
|
BlobFeeCap: (*hexutil.Big)(tx.BlobGasFeeCap()),
|
||||||
BlobVersionedHashes: tx.BlobHashes(),
|
BlobHashes: tx.BlobHashes(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ type TransactionArgs struct {
|
||||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||||
|
|
||||||
// Introduced by EIP-4844.
|
// Introduced by EIP-4844.
|
||||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas"`
|
BlobFeeCap *hexutil.Big `json:"maxFeePerBlobGas"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// from retrieves the transaction sender address.
|
// from retrieves the transaction sender address.
|
||||||
|
|
@ -98,10 +98,10 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
|
||||||
if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
|
if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
|
||||||
return errors.New(`both "data" and "input" are set and not equal. Please use "input" to pass transaction call data`)
|
return errors.New(`both "data" and "input" are set and not equal. Please use "input" to pass transaction call data`)
|
||||||
}
|
}
|
||||||
if args.BlobVersionedHashes != nil && args.To == nil {
|
if args.BlobHashes != nil && args.To == nil {
|
||||||
return errors.New(`blob transactions cannot have the form of a create transaction`)
|
return errors.New(`blob transactions cannot have the form of a create transaction`)
|
||||||
}
|
}
|
||||||
if args.BlobVersionedHashes != nil && len(args.BlobVersionedHashes) == 0 {
|
if args.BlobHashes != nil && len(args.BlobHashes) == 0 {
|
||||||
return errors.New(`need at least 1 blob for a blob-tx`)
|
return errors.New(`need at least 1 blob for a blob-tx`)
|
||||||
}
|
}
|
||||||
if args.To == nil && len(args.data()) == 0 {
|
if args.To == nil && len(args.data()) == 0 {
|
||||||
|
|
@ -166,7 +166,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
|
||||||
return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
|
return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
|
||||||
}
|
}
|
||||||
// Sanity check the EIP-4844 fee parameters.
|
// Sanity check the EIP-4844 fee parameters.
|
||||||
if args.MaxFeePerBlobGas != nil && args.MaxFeePerBlobGas.ToInt().Sign() == 0 {
|
if args.BlobFeeCap != nil && args.BlobFeeCap.ToInt().Sign() == 0 {
|
||||||
return errors.New("maxFeePerBlobGas must be non-zero")
|
return errors.New("maxFeePerBlobGas must be non-zero")
|
||||||
}
|
}
|
||||||
// Sanity check the non-EIP-1559 fee parameters.
|
// Sanity check the non-EIP-1559 fee parameters.
|
||||||
|
|
@ -186,7 +186,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if isLondon {
|
} else if isLondon {
|
||||||
if args.MaxFeePerBlobGas != nil {
|
if args.BlobFeeCap != nil {
|
||||||
return errors.New("maxFeePerBlobGas is not valid before Cancun is active")
|
return errors.New("maxFeePerBlobGas is not valid before Cancun is active")
|
||||||
}
|
}
|
||||||
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
|
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
|
||||||
|
|
@ -194,7 +194,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil || args.MaxFeePerBlobGas != nil {
|
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil || args.BlobFeeCap != nil {
|
||||||
return errors.New("maxFeePerGas and maxPriorityFeePerGas and maxFeePerBlobGas are not valid before London is active")
|
return errors.New("maxFeePerGas and maxPriorityFeePerGas and maxFeePerBlobGas are not valid before London is active")
|
||||||
}
|
}
|
||||||
// London not active, set gas price.
|
// London not active, set gas price.
|
||||||
|
|
@ -210,14 +210,14 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
|
||||||
// setCancunFeeDefaults fills in reasonable default fee values for unspecified fields.
|
// setCancunFeeDefaults fills in reasonable default fee values for unspecified fields.
|
||||||
func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, head *types.Header, b Backend) error {
|
func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, head *types.Header, b Backend) error {
|
||||||
// Set maxFeePerBlobGas if it is missing.
|
// Set maxFeePerBlobGas if it is missing.
|
||||||
if args.BlobVersionedHashes != nil && args.MaxFeePerBlobGas == nil {
|
if args.BlobHashes != nil && args.BlobFeeCap == nil {
|
||||||
// ExcessBlobGas must be set for a Cancun block.
|
// ExcessBlobGas must be set for a Cancun block.
|
||||||
blobBaseFee := eip4844.CalcBlobFee(*head.ExcessBlobGas)
|
blobBaseFee := eip4844.CalcBlobFee(*head.ExcessBlobGas)
|
||||||
// Set the max fee to be 2 times larger than the previous block's blob base fee.
|
// Set the max fee to be 2 times larger than the previous block's blob base fee.
|
||||||
// The additional slack allows the tx to not become invalidated if the base
|
// The additional slack allows the tx to not become invalidated if the base
|
||||||
// fee is rising.
|
// fee is rising.
|
||||||
val := new(big.Int).Mul(blobBaseFee, big.NewInt(2))
|
val := new(big.Int).Mul(blobBaseFee, big.NewInt(2))
|
||||||
args.MaxFeePerBlobGas = (*hexutil.Big)(val)
|
args.BlobFeeCap = (*hexutil.Big)(val)
|
||||||
}
|
}
|
||||||
return args.setLondonFeeDefaults(ctx, head, b)
|
return args.setLondonFeeDefaults(ctx, head, b)
|
||||||
}
|
}
|
||||||
|
|
@ -309,9 +309,9 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if args.MaxFeePerBlobGas != nil {
|
if args.BlobFeeCap != nil {
|
||||||
blobGasFeeCap = args.MaxFeePerBlobGas.ToInt()
|
blobGasFeeCap = args.BlobFeeCap.ToInt()
|
||||||
} else if args.BlobVersionedHashes != nil {
|
} else if args.BlobHashes != nil {
|
||||||
blobGasFeeCap = new(big.Int)
|
blobGasFeeCap = new(big.Int)
|
||||||
}
|
}
|
||||||
value := new(big.Int)
|
value := new(big.Int)
|
||||||
|
|
@ -334,7 +334,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
|
||||||
Data: data,
|
Data: data,
|
||||||
AccessList: accessList,
|
AccessList: accessList,
|
||||||
BlobGasFeeCap: blobGasFeeCap,
|
BlobGasFeeCap: blobGasFeeCap,
|
||||||
BlobHashes: args.BlobVersionedHashes,
|
BlobHashes: args.BlobHashes,
|
||||||
SkipAccountChecks: true,
|
SkipAccountChecks: true,
|
||||||
}
|
}
|
||||||
return msg, nil
|
return msg, nil
|
||||||
|
|
@ -345,7 +345,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (*
|
||||||
func (args *TransactionArgs) toTransaction() *types.Transaction {
|
func (args *TransactionArgs) toTransaction() *types.Transaction {
|
||||||
var data types.TxData
|
var data types.TxData
|
||||||
switch {
|
switch {
|
||||||
case args.BlobVersionedHashes != nil:
|
case args.BlobHashes != nil:
|
||||||
al := types.AccessList{}
|
al := types.AccessList{}
|
||||||
if args.AccessList != nil {
|
if args.AccessList != nil {
|
||||||
al = *args.AccessList
|
al = *args.AccessList
|
||||||
|
|
@ -360,8 +360,8 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
|
||||||
Value: uint256.MustFromBig((*big.Int)(args.Value)),
|
Value: uint256.MustFromBig((*big.Int)(args.Value)),
|
||||||
Data: args.data(),
|
Data: args.data(),
|
||||||
AccessList: al,
|
AccessList: al,
|
||||||
BlobHashes: args.BlobVersionedHashes,
|
BlobHashes: args.BlobHashes,
|
||||||
BlobFeeCap: uint256.MustFromBig((*big.Int)(args.MaxFeePerBlobGas)),
|
BlobFeeCap: uint256.MustFromBig((*big.Int)(args.BlobFeeCap)),
|
||||||
}
|
}
|
||||||
case args.MaxFeePerGas != nil:
|
case args.MaxFeePerGas != nil:
|
||||||
al := types.AccessList{}
|
al := types.AccessList{}
|
||||||
|
|
@ -411,5 +411,5 @@ func (args *TransactionArgs) ToTransaction() *types.Transaction {
|
||||||
|
|
||||||
// IsEIP4844 returns an indicator if the args contains EIP4844 fields.
|
// IsEIP4844 returns an indicator if the args contains EIP4844 fields.
|
||||||
func (args *TransactionArgs) IsEIP4844() bool {
|
func (args *TransactionArgs) IsEIP4844() bool {
|
||||||
return args.BlobVersionedHashes != nil || args.MaxFeePerBlobGas != nil
|
return args.BlobHashes != nil || args.BlobFeeCap != nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,29 +210,29 @@ func TestSetFeeDefaults(t *testing.T) {
|
||||||
{
|
{
|
||||||
"set maxFeePerBlobGas pre cancun",
|
"set maxFeePerBlobGas pre cancun",
|
||||||
"london",
|
"london",
|
||||||
&TransactionArgs{MaxFeePerBlobGas: fortytwo},
|
&TransactionArgs{BlobFeeCap: fortytwo},
|
||||||
nil,
|
nil,
|
||||||
errors.New("maxFeePerBlobGas is not valid before Cancun is active"),
|
errors.New("maxFeePerBlobGas is not valid before Cancun is active"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"set maxFeePerBlobGas pre london",
|
"set maxFeePerBlobGas pre london",
|
||||||
"legacy",
|
"legacy",
|
||||||
&TransactionArgs{MaxFeePerBlobGas: fortytwo},
|
&TransactionArgs{BlobFeeCap: fortytwo},
|
||||||
nil,
|
nil,
|
||||||
errors.New("maxFeePerGas and maxPriorityFeePerGas and maxFeePerBlobGas are not valid before London is active"),
|
errors.New("maxFeePerGas and maxPriorityFeePerGas and maxFeePerBlobGas are not valid before London is active"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"set gas price and maxFee for blob-tx",
|
"set gas price and maxFee for blob-tx",
|
||||||
"cancun",
|
"cancun",
|
||||||
&TransactionArgs{GasPrice: fortytwo, MaxFeePerGas: maxFee, BlobVersionedHashes: []common.Hash{}},
|
&TransactionArgs{GasPrice: fortytwo, MaxFeePerGas: maxFee, BlobHashes: []common.Hash{}},
|
||||||
nil,
|
nil,
|
||||||
errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"),
|
errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fill maxFeePerBlobGas",
|
"fill maxFeePerBlobGas",
|
||||||
"cancun",
|
"cancun",
|
||||||
&TransactionArgs{BlobVersionedHashes: []common.Hash{}},
|
&TransactionArgs{BlobHashes: []common.Hash{}},
|
||||||
&TransactionArgs{BlobVersionedHashes: []common.Hash{}, MaxFeePerBlobGas: (*hexutil.Big)(big.NewInt(4)), MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
|
&TransactionArgs{BlobHashes: []common.Hash{}, BlobFeeCap: (*hexutil.Big)(big.NewInt(4)), MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue