mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 15:03:45 +00:00
core: update 2780 and 8038 parameters (#35454)
https://github.com/ethereum/EIPs/pull/12056 https://github.com/ethereum/EIPs/pull/11997
This commit is contained in:
parent
83f0795a60
commit
92a3bed7f2
4 changed files with 17 additions and 20 deletions
|
|
@ -69,7 +69,7 @@ func TestEIP2780Intrinsic(t *testing.T) {
|
||||||
value: uint256.NewInt(1),
|
value: uint256.NewInt(1),
|
||||||
// TxBaseCost + ColdAccountAccess + TxValueCost + TransferLogCost = 21,000
|
// TxBaseCost + ColdAccountAccess + TxValueCost + TransferLogCost = 21,000
|
||||||
want: params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
want: params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
||||||
params.TxValueCost2780 + params.TransferLogCost2780,
|
params.TxValueCost2780,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "contract creation, value = 0",
|
name: "contract creation, value = 0",
|
||||||
|
|
@ -85,7 +85,7 @@ func TestEIP2780Intrinsic(t *testing.T) {
|
||||||
to: nil,
|
to: nil,
|
||||||
value: uint256.NewInt(1),
|
value: uint256.NewInt(1),
|
||||||
// TxBaseCost + CreateAccess + TransferLogCost = 24,756 regular.
|
// TxBaseCost + CreateAccess + TransferLogCost = 24,756 regular.
|
||||||
want: params.TxBaseCost2780 + params.CreateAccessAmsterdam + params.TransferLogCost2780,
|
want: params.TxBaseCost2780 + params.CreateAccessAmsterdam,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "value transfer with authorizations",
|
name: "value transfer with authorizations",
|
||||||
|
|
@ -95,7 +95,7 @@ func TestEIP2780Intrinsic(t *testing.T) {
|
||||||
// Each authorization adds the state-independent per-auth base
|
// Each authorization adds the state-independent per-auth base
|
||||||
// (cold authority access included).
|
// (cold authority access included).
|
||||||
want: params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
want: params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
||||||
params.TxValueCost2780 + params.TransferLogCost2780 + 3*params.RegularPerAuthBaseCost,
|
params.TxValueCost2780 + 3*params.RegularPerAuthBaseCost,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|
@ -156,7 +156,7 @@ func TestEIP2780Gas(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
cold = params.ColdAccountAccessAmsterdam
|
cold = params.ColdAccountAccessAmsterdam
|
||||||
base = params.TxBaseCost2780
|
base = params.TxBaseCost2780
|
||||||
valueCst = params.TxValueCost2780 + params.TransferLogCost2780
|
valueCst = params.TxValueCost2780
|
||||||
)
|
)
|
||||||
var (
|
var (
|
||||||
existingEOA = common.HexToAddress("0xe0a0000000000000000000000000000000000001")
|
existingEOA = common.HexToAddress("0xe0a0000000000000000000000000000000000001")
|
||||||
|
|
@ -205,7 +205,7 @@ func TestEIP2780Gas(t *testing.T) {
|
||||||
// case 9: contract-creation transaction, value = 0.
|
// case 9: contract-creation transaction, value = 0.
|
||||||
{"create/zero-value", createTx(0, 300_000, nil), base + params.CreateAccessAmsterdam, newAccountState},
|
{"create/zero-value", createTx(0, 300_000, nil), base + params.CreateAccessAmsterdam, newAccountState},
|
||||||
// case 10: contract-creation transaction, value > 0.
|
// case 10: contract-creation transaction, value > 0.
|
||||||
{"create/value", valueCreateTx(1), base + params.CreateAccessAmsterdam + params.TransferLogCost2780, newAccountState},
|
{"create/value", valueCreateTx(1), base + params.CreateAccessAmsterdam, newAccountState},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
|
@ -404,7 +404,7 @@ func TestEIP2780RecipientOOG(t *testing.T) {
|
||||||
auth, authority := signAuth(t, authKeyA, delegate8037, 0)
|
auth, authority := signAuth(t, authKeyA, delegate8037, 0)
|
||||||
recipient := common.HexToAddress("0xbeef000000000000000000000000000000000004")
|
recipient := common.HexToAddress("0xbeef000000000000000000000000000000000004")
|
||||||
intrinsic := params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
intrinsic := params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
||||||
params.TxValueCost2780 + params.TransferLogCost2780 + params.RegularPerAuthBaseCost
|
params.TxValueCost2780 + params.RegularPerAuthBaseCost
|
||||||
// The reservoir case needs a near-cap intrinsic cost. This leaves just
|
// The reservoir case needs a near-cap intrinsic cost. This leaves just
|
||||||
// enough total budget for the authorization but not for the recipient leaf.
|
// enough total budget for the authorization but not for the recipient leaf.
|
||||||
const (
|
const (
|
||||||
|
|
@ -537,7 +537,7 @@ func TestEIP2780RecipientKinds(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
base = params.TxBaseCost2780
|
base = params.TxBaseCost2780
|
||||||
cold = params.ColdAccountAccessAmsterdam
|
cold = params.ColdAccountAccessAmsterdam
|
||||||
valueCst = params.TxValueCost2780 + params.TransferLogCost2780
|
valueCst = params.TxValueCost2780
|
||||||
)
|
)
|
||||||
nonceOnly := common.HexToAddress("0xbeef000000000000000000000000000000000005")
|
nonceOnly := common.HexToAddress("0xbeef000000000000000000000000000000000005")
|
||||||
precompile := common.BytesToAddress([]byte{4}) // identity; 15 gas for empty input
|
precompile := common.BytesToAddress([]byte{4}) // identity; 15 gas for empty input
|
||||||
|
|
@ -668,7 +668,7 @@ func TestEIP2780InstallDispatch(t *testing.T) {
|
||||||
base = params.TxBaseCost2780
|
base = params.TxBaseCost2780
|
||||||
cold = params.ColdAccountAccessAmsterdam
|
cold = params.ColdAccountAccessAmsterdam
|
||||||
perAuth = params.RegularPerAuthBaseCost
|
perAuth = params.RegularPerAuthBaseCost
|
||||||
valueCst = params.TxValueCost2780 + params.TransferLogCost2780
|
valueCst = params.TxValueCost2780
|
||||||
)
|
)
|
||||||
auth, authority := signAuth(t, authKeyA, delegate8037, 0)
|
auth, authority := signAuth(t, authKeyA, delegate8037, 0)
|
||||||
senderAuth, err := types.SignSetCode(senderKey, types.SetCodeAuthorization{
|
senderAuth, err := types.SignSetCode(senderKey, types.SetCodeAuthorization{
|
||||||
|
|
@ -978,7 +978,7 @@ func TestEIP2780AuthorityAccountWrite(t *testing.T) {
|
||||||
cold = params.ColdAccountAccessAmsterdam
|
cold = params.ColdAccountAccessAmsterdam
|
||||||
aw = params.AccountWriteAmsterdam
|
aw = params.AccountWriteAmsterdam
|
||||||
perAuth = params.RegularPerAuthBaseCost
|
perAuth = params.RegularPerAuthBaseCost
|
||||||
valueCst = params.TxValueCost2780 + params.TransferLogCost2780
|
valueCst = params.TxValueCost2780
|
||||||
)
|
)
|
||||||
existingEOA := common.HexToAddress("0xe0a0000000000000000000000000000000000002")
|
existingEOA := common.HexToAddress("0xe0a0000000000000000000000000000000000002")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,12 +185,10 @@ func intrinsicBaseGasEIP2780(from common.Address, to *common.Address, value *uin
|
||||||
|
|
||||||
// tx.value charge.
|
// tx.value charge.
|
||||||
switch {
|
switch {
|
||||||
case !hasValue || isSelfTransfer:
|
case !hasValue || isSelfTransfer || isContractCreation:
|
||||||
// No transfer log and no recipient balance write.
|
// No transfer log and no recipient balance write.
|
||||||
case isContractCreation:
|
|
||||||
gas += params.TransferLogCost2780
|
|
||||||
default:
|
default:
|
||||||
gas += params.TransferLogCost2780 + params.TxValueCost2780
|
gas += params.TxValueCost2780
|
||||||
}
|
}
|
||||||
return gas
|
return gas
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,7 @@ func TestIntrinsicGas(t *testing.T) {
|
||||||
value: uint256.NewInt(1),
|
value: uint256.NewInt(1),
|
||||||
// EIP-2780: TxBaseCost + ColdAccountAccess + TransferLogCost + TxValueCost = 21,000.
|
// EIP-2780: TxBaseCost + ColdAccountAccess + TransferLogCost + TxValueCost = 21,000.
|
||||||
want: params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
want: params.TxBaseCost2780 + params.ColdAccountAccessAmsterdam +
|
||||||
params.TransferLogCost2780 + params.TxValueCost2780,
|
params.TxValueCost2780,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "amsterdam/value-bearing-contract-creation",
|
name: "amsterdam/value-bearing-contract-creation",
|
||||||
|
|
@ -334,7 +334,7 @@ func TestIntrinsicGas(t *testing.T) {
|
||||||
value: uint256.NewInt(1),
|
value: uint256.NewInt(1),
|
||||||
// EIP-2780: TxBaseCost + CreateAccess + TransferLogCost = 24,756;
|
// EIP-2780: TxBaseCost + CreateAccess + TransferLogCost = 24,756;
|
||||||
// the new-account state charge is applied at runtime.
|
// the new-account state charge is applied at runtime.
|
||||||
want: params.TxBaseCost2780 + params.CreateAccessAmsterdam + params.TransferLogCost2780,
|
want: params.TxBaseCost2780 + params.CreateAccessAmsterdam,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,8 @@ const (
|
||||||
RegularPerAuthBaseCost uint64 = 7816
|
RegularPerAuthBaseCost uint64 = 7816
|
||||||
|
|
||||||
// EIP-2780: resource-based intrinsic transaction gas.
|
// EIP-2780: resource-based intrinsic transaction gas.
|
||||||
TxBaseCost2780 uint64 = 12000
|
TxBaseCost2780 uint64 = 12000
|
||||||
TxValueCost2780 uint64 = 4244
|
TxValueCost2780 uint64 = 6000
|
||||||
TransferLogCost2780 uint64 = 1756
|
|
||||||
|
|
||||||
// EIP-8038: state-access gas cost update (Amsterdam).
|
// EIP-8038: state-access gas cost update (Amsterdam).
|
||||||
ColdAccountAccessAmsterdam uint64 = 3000 // COLD_ACCOUNT_ACCESS: cold touch of an account
|
ColdAccountAccessAmsterdam uint64 = 3000 // COLD_ACCOUNT_ACCESS: cold touch of an account
|
||||||
|
|
@ -121,8 +120,8 @@ const (
|
||||||
StorageWriteAmsterdam uint64 = 10000 // STORAGE_WRITE: surcharge for first-time write to a storage slot
|
StorageWriteAmsterdam uint64 = 10000 // STORAGE_WRITE: surcharge for first-time write to a storage slot
|
||||||
StorageClearRefundAmsterdam uint64 = 12480 // STORAGE_CLEAR_REFUND: refund for clearing a storage slot
|
StorageClearRefundAmsterdam uint64 = 12480 // STORAGE_CLEAR_REFUND: refund for clearing a storage slot
|
||||||
CreateAccessAmsterdam uint64 = 11000 // CREATE_ACCESS = ACCOUNT_WRITE + COLD_STORAGE_ACCESS
|
CreateAccessAmsterdam uint64 = 11000 // CREATE_ACCESS = ACCOUNT_WRITE + COLD_STORAGE_ACCESS
|
||||||
TxAccessListAddressGasAmsterdam uint64 = 3000 // ACCESS_LIST_ADDRESS_COST
|
TxAccessListAddressGasAmsterdam uint64 = 2900 // ACCESS_LIST_ADDRESS_COST
|
||||||
TxAccessListStorageKeyGasAmsterdam uint64 = 3000 // ACCESS_LIST_STORAGE_KEY_COST
|
TxAccessListStorageKeyGasAmsterdam uint64 = 2900 // ACCESS_LIST_STORAGE_KEY_COST
|
||||||
|
|
||||||
// These have been changed during the course of the chain
|
// These have been changed during the course of the chain
|
||||||
CallGasFrontier uint64 = 40 // Once per CALL operation & message call transaction.
|
CallGasFrontier uint64 = 40 // Once per CALL operation & message call transaction.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue