Skip to content

Commit 6757113

Browse files
committed
Updated changes in refunds: EIP-3529
Refunds are not accounted in Solidity's gas meter.
1 parent 63cdfc3 commit 6757113

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

libevmasm/GasMeter.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ namespace GasCosts
5959
}
6060
static unsigned const keccak256Gas = 30;
6161
static unsigned const keccak256WordGas = 6;
62+
/// Corresponds to ACCESS_LIST_ADDRESS_COST from EIP-2930
63+
static unsigned const accessListAddressCost = 2400;
64+
/// Corresponds to ACCESS_LIST_STORAGE_COST from EIP-2930
65+
static unsigned const accessListStorageKeyCost = 1900;
6266
/// Corresponds to COLD_SLOAD_COST from EIP-2929
6367
static unsigned const coldSloadCost = 2100;
6468
/// Corresponds to COLD_ACCOUNT_ACCESS_COST from EIP-2929
@@ -80,7 +84,14 @@ namespace GasCosts
8084
static unsigned const sstoreSetGas = 20000;
8185
/// Corresponds to SSTORE_RESET_GAS from EIP-2929
8286
static unsigned const sstoreResetGas = 5000 - coldSloadCost;
83-
static unsigned const sstoreRefundGas = 15000;
87+
/// Corresponds to SSTORE_CLEARS_SCHEDULE from EIP-2200
88+
inline static unsigned sstoreClearsSchedule(langutil::EVMVersion _evmVersion)
89+
{
90+
if (_evmVersion >= langutil::EVMVersion::london())
91+
return sstoreResetGas + accessListStorageKeyCost;
92+
else
93+
return 15000;
94+
}
8495
inline static unsigned totalSstoreSetGas(langutil::EVMVersion _evmVersion)
8596
{
8697
if (_evmVersion >= langutil::EVMVersion::berlin())
@@ -144,7 +155,13 @@ namespace GasCosts
144155
else
145156
return 0;
146157
}
147-
static unsigned const selfdestructRefundGas = 24000;
158+
inline unsigned selfdestructGasRefundGas(langutil::EVMVersion _evmVersion)
159+
{
160+
if (_evmVersion >= langutil::EVMVersion::london())
161+
return 0;
162+
else
163+
return 24000;
164+
}
148165
static unsigned const memoryGas = 3;
149166
static unsigned const quadCoeffDiv = 512;
150167
static unsigned const createDataGas = 200;

0 commit comments

Comments
 (0)