From bdaeedb09f8eca1c16397cef5a0d46d1fc8aa2ed Mon Sep 17 00:00:00 2001 From: andri lim Date: Fri, 4 Aug 2023 19:43:30 +0700 Subject: [PATCH] rename data gas to blob gas (#1659) * rename data gas to blob gas * bump more submodules * extend evmc tx_context with EIP-4844 blob_hashes --- fluffy/conf.nim | 20 ++--- fluffy/network/history/history_network.nim | 2 +- .../network/wire/portal_protocol_config.nim | 10 +-- .../beacon_lc_bridge/beacon_lc_bridge.nim | 8 +- .../beacon_lc_bridge_conf.nim | 4 +- fluffy/tools/blockwalk.nim | 4 +- .../tools/eth_data_exporter/exporter_conf.nim | 8 +- fluffy/tools/portalcli.nim | 12 +-- .../consensus/extract_consensus_data.nim | 4 +- nimbus/common/chain_config.nim | 8 +- nimbus/common/genesis.nim | 4 +- nimbus/constants.nim | 12 +-- nimbus/core/eip4844.nim | 82 +++++++++---------- nimbus/core/executor/process_transaction.nim | 4 +- nimbus/core/tx_pool/tx_chain.nim | 24 +++--- nimbus/core/tx_pool/tx_tasks/tx_classify.nim | 4 +- nimbus/core/tx_pool/tx_tasks/tx_packer.nim | 12 +-- nimbus/core/validate.nim | 12 +-- .../data_sources/json_rpc_data_source.nim | 6 +- nimbus/evm/computation.nim | 10 +-- nimbus/evm/evmc_api.nim | 22 ++--- nimbus/graphql/ethapi.nim | 10 +-- nimbus/transaction/call_common.nim | 2 +- nimbus/transaction/host_call_nested.nim | 2 +- nimbus/transaction/host_services.nim | 9 ++ nimbus/transaction/host_trace.nim | 2 +- nimbus/utils/debug.nim | 8 +- .../nimbus_verified_proxy_conf.nim | 4 +- tests/replay/pp.nim | 4 +- tests/test_eip4844.nim | 4 +- tools/evmstate/helpers.nim | 6 +- tools/t8n/helpers.nim | 16 ++-- tools/t8n/testdata/00-517/env.json | 4 +- tools/t8n/testdata/00-517/exp.json | 4 +- tools/t8n/testdata/00-518/env.json | 4 +- tools/t8n/testdata/00-518/exp.json | 4 +- tools/t8n/transition.nim | 24 +++--- tools/t8n/types.nim | 10 ++- vendor/nim-blscurve | 2 +- vendor/nim-chronos | 2 +- vendor/nim-confutils | 2 +- vendor/nim-eth | 2 +- vendor/nim-evmc | 2 +- vendor/nim-faststreams | 2 +- vendor/nim-json-rpc | 2 +- vendor/nim-snappy | 2 +- vendor/nim-taskpools | 2 +- vendor/nim-web3 | 2 +- vendor/nimbus-eth2 | 2 +- vendor/nimcrypto | 2 +- 50 files changed, 215 insertions(+), 198 deletions(-) diff --git a/fluffy/conf.nim b/fluffy/conf.nim index bb5942a80..e5a5ce176 100644 --- a/fluffy/conf.nim +++ b/fluffy/conf.nim @@ -240,25 +240,25 @@ func completeCmdArg*(T: type TrustedDigest, input: string): seq[string] = return @[] proc parseCmdArg*(T: type enr.Record, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = if not fromURI(result, p): - raise newException(ConfigurationError, "Invalid ENR") + raise newException(ValueError, "Invalid ENR") proc completeCmdArg*(T: type enr.Record, val: string): seq[string] = return @[] proc parseCmdArg*(T: type Node, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = var record: enr.Record if not fromURI(record, p): - raise newException(ConfigurationError, "Invalid ENR") + raise newException(ValueError, "Invalid ENR") let n = newNode(record) if n.isErr: - raise newException(ConfigurationError, $n.error) + raise newException(ValueError, $n.error) if n[].address.isNone(): - raise newException(ConfigurationError, "ENR without address") + raise newException(ValueError, "ENR without address") n[] @@ -266,17 +266,17 @@ proc completeCmdArg*(T: type Node, val: string): seq[string] = return @[] proc parseCmdArg*(T: type PrivateKey, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = try: result = PrivateKey.fromHex(p).tryGet() except CatchableError: - raise newException(ConfigurationError, "Invalid private key") + raise newException(ValueError, "Invalid private key") proc completeCmdArg*(T: type PrivateKey, val: string): seq[string] = return @[] proc parseCmdArg*(T: type ClientConfig, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = let uri = parseUri(p) if (uri.scheme == "http" or uri.scheme == "https"): getHttpClientConfig(p) @@ -284,7 +284,7 @@ proc parseCmdArg*(T: type ClientConfig, p: string): T getWebSocketClientConfig(p) else: raise newException( - ConfigurationError, "Proxy uri should have defined scheme (http/https/ws/wss)" + ValueError, "Proxy uri should have defined scheme (http/https/ws/wss)" ) proc completeCmdArg*(T: type ClientConfig, val: string): seq[string] = diff --git a/fluffy/network/history/history_network.nim b/fluffy/network/history/history_network.nim index 75b385f6c..a41dff7db 100644 --- a/fluffy/network/history/history_network.nim +++ b/fluffy/network/history/history_network.nim @@ -209,7 +209,7 @@ func validateBlockHeaderBytes*( let header = ? decodeRlp(bytes, BlockHeader) - if header.excessDataGas.isSome: + if header.excessBlobGas.isSome: return err("EIP-4844 not yet implemented") # TODO: Verify timestamp with Shanghai timestamp to if isSome() diff --git a/fluffy/network/wire/portal_protocol_config.nim b/fluffy/network/wire/portal_protocol_config.nim index 5862af272..8ce53963e 100644 --- a/fluffy/network/wire/portal_protocol_config.nim +++ b/fluffy/network/wire/portal_protocol_config.nim @@ -54,7 +54,7 @@ proc init*( ) proc parseCmdArg*(T: type RadiusConfig, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = if p.startsWith("dynamic") and len(p) == 7: RadiusConfig(kind: Dynamic) elif p.startsWith("static:"): @@ -64,11 +64,11 @@ proc parseCmdArg*(T: type RadiusConfig, p: string): T uint16.parseCmdArg(num) except ValueError: let msg = "Provided logRadius: " & num & " is not a valid number" - raise newException(ConfigurationError, msg) + raise newException(ValueError, msg) if parsed > 256: raise newException( - ConfigurationError, "Provided logRadius should be <= 256" + ValueError, "Provided logRadius should be <= 256" ) RadiusConfig(kind: Static, logRadius: parsed) @@ -80,11 +80,11 @@ proc parseCmdArg*(T: type RadiusConfig, p: string): T let msg = "Not supported radius config option: " & p & " . " & "Supported options: dynamic and static:logRadius" - raise newException(ConfigurationError, msg) + raise newException(ValueError, msg) if parsed > 256: raise newException( - ConfigurationError, "Provided logRadius should be <= 256") + ValueError, "Provided logRadius should be <= 256") RadiusConfig(kind: Static, logRadius: parsed) diff --git a/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge.nim b/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge.nim index 867138074..a1deadf6c 100644 --- a/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge.nim +++ b/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge.nim @@ -248,8 +248,8 @@ proc asPortalBlockData*( nonce: default(BlockNonce), fee: some(payload.baseFeePerGas), withdrawalsRoot: withdrawalsRoot, - dataGasUsed: options.none(uint64), - excessDataGas: options.none(uint64) + blobGasUsed: options.none(uint64), + excessBlobGas: options.none(uint64) ) headerWithProof = BlockHeaderWithProof( @@ -293,8 +293,8 @@ proc asPortalBlockData*( nonce: default(BlockNonce), fee: some(payload.baseFeePerGas), withdrawalsRoot: withdrawalsRoot, - dataGasUsed: options.none(uint64), - excessDataGas: options.none(uint64) # TODO: adjust later according to deneb fork + blobGasUsed: options.none(uint64), + excessBlobGas: options.none(uint64) # TODO: adjust later according to deneb fork ) headerWithProof = BlockHeaderWithProof( diff --git a/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge_conf.nim b/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge_conf.nim index 56755111c..a3c32e4ab 100644 --- a/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge_conf.nim +++ b/fluffy/tools/beacon_lc_bridge/beacon_lc_bridge_conf.nim @@ -170,7 +170,7 @@ type BeaconBridgeConf* = object name: "direct-peer" .}: seq[string] proc parseCmdArg*( - T: type Web3Url, p: string): T {.raises: [ConfigurationError].} = + T: type Web3Url, p: string): T {.raises: [ValueError].} = let url = parseUri(p) normalizedScheme = url.scheme.toLowerAscii() @@ -181,7 +181,7 @@ proc parseCmdArg*( Web3Url(kind: WsUrl, web3Url: p) else: raise newException( - ConfigurationError, + ValueError, "The Web3 URL must specify one of following protocols: http/https/ws/wss" ) diff --git a/fluffy/tools/blockwalk.nim b/fluffy/tools/blockwalk.nim index fba3df7e0..5d3438c61 100644 --- a/fluffy/tools/blockwalk.nim +++ b/fluffy/tools/blockwalk.nim @@ -40,12 +40,12 @@ type name: "block-hash" .}: Hash256 proc parseCmdArg*(T: type Hash256, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = var hash: Hash256 try: hexToByteArray(p, hash.data) except ValueError: - raise newException(ConfigurationError, "Invalid Hash256") + raise newException(ValueError, "Invalid Hash256") return hash diff --git a/fluffy/tools/eth_data_exporter/exporter_conf.nim b/fluffy/tools/eth_data_exporter/exporter_conf.nim index 879d50911..1b08dc48b 100644 --- a/fluffy/tools/eth_data_exporter/exporter_conf.nim +++ b/fluffy/tools/eth_data_exporter/exporter_conf.nim @@ -184,7 +184,7 @@ type discard proc parseCmdArg*( - T: type Web3Url, p: string): T {.raises: [ConfigurationError].} = + T: type Web3Url, p: string): T {.raises: [ValueError].} = let url = parseUri(p) normalizedScheme = url.scheme.toLowerAscii() @@ -195,7 +195,7 @@ proc parseCmdArg*( Web3Url(kind: WsUrl, url: p) else: raise newException( - ConfigurationError, + ValueError, "The Web3 URL must specify one of following protocols: http/https/ws/wss" ) @@ -203,14 +203,14 @@ proc completeCmdArg*(T: type Web3Url, val: string): seq[string] = return @[] proc parseCmdArg*(T: type StorageMode, p: string): T - {.raises: [ConfigurationError].} = + {.raises: [ValueError].} = if p == "db": return DbStorage elif p == "json": return JsonStorage else: let msg = "Provided mode: " & p & " is not a valid. Should be `json` or `db`" - raise newException(ConfigurationError, msg) + raise newException(ValueError, msg) proc completeCmdArg*(T: type StorageMode, val: string): seq[string] = return @[] diff --git a/fluffy/tools/portalcli.nim b/fluffy/tools/portalcli.nim index f4831327a..e24795495 100644 --- a/fluffy/tools/portalcli.nim +++ b/fluffy/tools/portalcli.nim @@ -143,7 +143,7 @@ type proc parseCmdArg*(T: type enr.Record, p: string): T = if not fromURI(result, p): - raise newException(ConfigurationError, "Invalid ENR") + raise newException(ValueError, "Invalid ENR") proc completeCmdArg*(T: type enr.Record, val: string): seq[string] = return @[] @@ -151,14 +151,14 @@ proc completeCmdArg*(T: type enr.Record, val: string): seq[string] = proc parseCmdArg*(T: type Node, p: string): T = var record: enr.Record if not fromURI(record, p): - raise newException(ConfigurationError, "Invalid ENR") + raise newException(ValueError, "Invalid ENR") let n = newNode(record) if n.isErr: - raise newException(ConfigurationError, $n.error) + raise newException(ValueError, $n.error) if n[].address.isNone(): - raise newException(ConfigurationError, "ENR without address") + raise newException(ValueError, "ENR without address") n[] @@ -169,7 +169,7 @@ proc parseCmdArg*(T: type PrivateKey, p: string): T = try: result = PrivateKey.fromHex(p).tryGet() except CatchableError: - raise newException(ConfigurationError, "Invalid private key") + raise newException(ValueError, "Invalid private key") proc completeCmdArg*(T: type PrivateKey, val: string): seq[string] = return @[] @@ -178,7 +178,7 @@ proc parseCmdArg*(T: type PortalProtocolId, p: string): T = try: result = byteutils.hexToByteArray(p, 2) except ValueError: - raise newException(ConfigurationError, + raise newException(ValueError, "Invalid protocol id, not a valid hex value") proc completeCmdArg*(T: type PortalProtocolId, val: string): seq[string] = diff --git a/hive_integration/nodocker/consensus/extract_consensus_data.nim b/hive_integration/nodocker/consensus/extract_consensus_data.nim index 848a36475..e6178d91d 100644 --- a/hive_integration/nodocker/consensus/extract_consensus_data.nim +++ b/hive_integration/nodocker/consensus/extract_consensus_data.nim @@ -45,8 +45,8 @@ proc parseGenesis(n: JsonNode): Genesis = for x in genFields: genesis[x] = gen[x] optionalField("baseFeePerGas", genesis, gen) - optionalField("dataGasUsed", genesis, gen) - optionalField("excessDataGas", genesis, gen) + optionalField("blobGasUsed", genesis, gen) + optionalField("excessBlobGas", genesis, gen) genesis["alloc"] = n["pre"] parseGenesis($genesis) diff --git a/nimbus/common/chain_config.nim b/nimbus/common/chain_config.nim index da073f899..f808d3c54 100644 --- a/nimbus/common/chain_config.nim +++ b/nimbus/common/chain_config.nim @@ -35,8 +35,8 @@ type gasUser* : GasInt parentHash* : Hash256 baseFeePerGas*: Option[UInt256] - dataGasUsed* : Option[uint64] # EIP-4844 - excessDataGas*: Option[uint64] # EIP-4844 + blobGasUsed* : Option[uint64] # EIP-4844 + excessBlobGas*: Option[uint64] # EIP-4844 GenesisAlloc* = Table[EthAddress, GenesisAccount] GenesisAccount* = object @@ -67,8 +67,8 @@ type gasUser* : GasInt parentHash* : Hash256 baseFeePerGas*: Option[UInt256] - dataGasUsed* : Option[uint64] # EIP-4844 - excessDataGas*: Option[uint64] # EIP-4844 + blobGasUsed* : Option[uint64] # EIP-4844 + excessBlobGas*: Option[uint64] # EIP-4844 const CustomNet* = 0.NetworkId diff --git a/nimbus/common/genesis.nim b/nimbus/common/genesis.nim index d8792f3c4..94b91498c 100644 --- a/nimbus/common/genesis.nim +++ b/nimbus/common/genesis.nim @@ -81,8 +81,8 @@ proc toGenesisHeader*( result.withdrawalsRoot = some(EMPTY_ROOT_HASH) if fork >= Cancun: - result.dataGasUsed = g.dataGasUsed - result.excessDataGas = g.excessDataGas + result.blobGasUsed = g.blobGasUsed + result.excessBlobGas = g.excessBlobGas proc toGenesisHeader*( genesis: Genesis; diff --git a/nimbus/constants.nim b/nimbus/constants.nim index ee3b6b466..9cb0f9217 100644 --- a/nimbus/constants.nim +++ b/nimbus/constants.nim @@ -78,11 +78,11 @@ const MAX_TX_WRAP_COMMITMENTS* = 1 shl 12 # 2^12 BLOB_COMMITMENT_VERSION_KZG* = 0x01.byte FIELD_ELEMENTS_PER_BLOB* = 4096 - DATA_GAS_PER_BLOB* = (1 shl 17).uint64 # 2^17 - TARGET_DATA_GAS_PER_BLOCK* = (1 shl 18).uint64 # 2^18 - MIN_DATA_GASPRICE* = 1'u64 - DATA_GASPRICE_UPDATE_FRACTION* = 2225652'u64 - MAX_DATA_GAS_PER_BLOCK* = (1 shl 19).uint64 # 2^19 - MaxAllowedBlob* = MAX_DATA_GAS_PER_BLOCK div DATA_GAS_PER_BLOB + GAS_PER_BLOB* = (1 shl 17).uint64 # 2^17 + TARGET_BLOB_GAS_PER_BLOCK* = (1 shl 18).uint64 # 2^18 + MIN_BLOB_GASPRICE* = 1'u64 + BLOB_GASPRICE_UPDATE_FRACTION* = 2225652'u64 + MAX_BLOB_GAS_PER_BLOCK* = (1 shl 19).uint64 # 2^19 + MaxAllowedBlob* = MAX_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB # End diff --git a/nimbus/core/eip4844.nim b/nimbus/core/eip4844.nim index 742628b72..d89dd9fa4 100644 --- a/nimbus/core/eip4844.nim +++ b/nimbus/core/eip4844.nim @@ -77,16 +77,16 @@ proc pointEvaluation*(input: openArray[byte]): Result[void, string] = ok() -# calcExcessDataGas implements calc_excess_data_gas from EIP-4844 -proc calcExcessDataGas*(parent: BlockHeader): uint64 = +# calcExcessBlobGas implements calc_excess_data_gas from EIP-4844 +proc calcExcessBlobGas*(parent: BlockHeader): uint64 = let - excessDataGas = parent.excessDataGas.get(0'u64) - dataGasUsed = parent.dataGasUsed.get(0'u64) + excessBlobGas = parent.excessBlobGas.get(0'u64) + blobGasUsed = parent.blobGasUsed.get(0'u64) - if excessDataGas + dataGasUsed < TARGET_DATA_GAS_PER_BLOCK: + if excessBlobGas + blobGasUsed < TARGET_BLOB_GAS_PER_BLOCK: 0'u64 else: - excessDataGas + dataGasUsed - TARGET_DATA_GAS_PER_BLOCK + excessBlobGas + blobGasUsed - TARGET_BLOB_GAS_PER_BLOCK # fakeExponential approximates factor * e ** (num / denom) using a taylor expansion # as described in the EIP-4844 spec. @@ -103,33 +103,33 @@ func fakeExponential*(factor, numerator, denominator: uint64): uint64 = output div denominator -proc getTotalDataGas*(tx: Transaction): uint64 = - DATA_GAS_PER_BLOB * tx.versionedHashes.len.uint64 +proc getTotalBlobGas*(tx: Transaction): uint64 = + GAS_PER_BLOB * tx.versionedHashes.len.uint64 -proc getTotalDataGas*(versionedHashesLen: int): uint64 = - DATA_GAS_PER_BLOB * versionedHasheslen.uint64 +proc getTotalBlobGas*(versionedHashesLen: int): uint64 = + GAS_PER_BLOB * versionedHasheslen.uint64 -# getDataGasPrice implements get_data_gas_price from EIP-4844 -func getDataGasprice*(parentExcessDataGas: uint64): uint64 = +# getBlobGasPrice implements get_data_gas_price from EIP-4844 +func getBlobGasprice*(parentExcessBlobGas: uint64): uint64 = fakeExponential( - MIN_DATA_GASPRICE, - parentExcessDataGas, - DATA_GASPRICE_UPDATE_FRACTION + MIN_BLOB_GASPRICE, + parentExcessBlobGas, + BLOB_GASPRICE_UPDATE_FRACTION ) proc calcDataFee*(tx: Transaction, - parentExcessDataGas: Option[uint64]): uint64 = - tx.getTotalDataGas * - getDataGasprice(parentExcessDataGas.get(0'u64)) + parentExcessBlobGas: Option[uint64]): uint64 = + tx.getTotalBlobGas * + getBlobGasprice(parentExcessBlobGas.get(0'u64)) proc calcDataFee*(versionedHashesLen: int, - parentExcessDataGas: Option[uint64]): uint64 = - getTotalDataGas(versionedHashesLen) * - getDataGasprice(parentExcessDataGas.get(0'u64)) + parentExcessBlobGas: Option[uint64]): uint64 = + getTotalBlobGas(versionedHashesLen) * + getBlobGasprice(parentExcessBlobGas.get(0'u64)) -func dataGasUsed(txs: openArray[Transaction]): uint64 = +func blobGasUsed(txs: openArray[Transaction]): uint64 = for tx in txs: - result += tx.getTotalDataGas + result += tx.getTotalBlobGas # https://eips.ethereum.org/EIPS/eip-4844 func validateEip4844Header*( @@ -137,34 +137,34 @@ func validateEip4844Header*( txs: openArray[Transaction]): Result[void, string] {.raises: [].} = if not com.forkGTE(Cancun): - if header.dataGasUsed.isSome: - return err("unexpected EIP-4844 dataGasUsed in block header") + if header.blobGasUsed.isSome: + return err("unexpected EIP-4844 blobGasUsed in block header") - if header.excessDataGas.isSome: - return err("unexpected EIP-4844 excessDataGas in block header") + if header.excessBlobGas.isSome: + return err("unexpected EIP-4844 excessBlobGas in block header") return ok() - if header.dataGasUsed.isNone: - return err("expect EIP-4844 dataGasUsed in block header") + if header.blobGasUsed.isNone: + return err("expect EIP-4844 blobGasUsed in block header") - if header.excessDataGas.isNone: - return err("expect EIP-4844 excessDataGas in block header") + if header.excessBlobGas.isNone: + return err("expect EIP-4844 excessBlobGas in block header") let - headerDataGasUsed = header.dataGasUsed.get() - dataGasUsed = dataGasUsed(txs) - headerExcessDataGas = header.excessDataGas.get - excessDataGas = calcExcessDataGas(parentHeader) + headerBlobGasUsed = header.blobGasUsed.get() + blobGasUsed = blobGasUsed(txs) + headerExcessBlobGas = header.excessBlobGas.get + excessBlobGas = calcExcessBlobGas(parentHeader) - if dataGasUsed > MAX_DATA_GAS_PER_BLOCK: - return err("dataGasUsed " & $dataGasUsed & " exceeds maximum allowance " & $MAX_DATA_GAS_PER_BLOCK) + if blobGasUsed > MAX_BLOB_GAS_PER_BLOCK: + return err("blobGasUsed " & $blobGasUsed & " exceeds maximum allowance " & $MAX_BLOB_GAS_PER_BLOCK) - if headerDataGasUsed != dataGasUsed: - return err("calculated dataGas not equal header.dataGasUsed") + if headerBlobGasUsed != blobGasUsed: + return err("calculated blobGas not equal header.blobGasUsed") - if headerExcessDataGas != excessDataGas: - return err("calculated excessDataGas not equal header.excessDataGas") + if headerExcessBlobGas != excessBlobGas: + return err("calculated excessBlobGas not equal header.excessBlobGas") return ok() diff --git a/nimbus/core/executor/process_transaction.nim b/nimbus/core/executor/process_transaction.nim index 24b94b33e..5063012e9 100644 --- a/nimbus/core/executor/process_transaction.nim +++ b/nimbus/core/executor/process_transaction.nim @@ -78,7 +78,7 @@ proc asyncProcessTransactionImpl( baseFee = baseFee256.truncate(GasInt) tx = eip1559TxNormalization(tx, baseFee, fork) priorityFee = min(tx.maxPriorityFee, tx.maxFee - baseFee) - excessDataGas = vmState.parent.excessDataGas.get(0'u64) + excessBlobGas = vmState.parent.excessBlobGas.get(0'u64) # Return failure unless explicitely set `ok()` var res: Result[GasInt, string] = err("") @@ -100,7 +100,7 @@ proc asyncProcessTransactionImpl( # before leaving is crucial for some unit tests that us a direct/deep call # of the `processTransaction()` function. So there is no `return err()` # statement, here. - let txRes = roDB.validateTransaction(tx, sender, header.gasLimit, baseFee256, excessDataGas, fork) + let txRes = roDB.validateTransaction(tx, sender, header.gasLimit, baseFee256, excessBlobGas, fork) if txRes.isOk: # EIP-1153 diff --git a/nimbus/core/tx_pool/tx_chain.nim b/nimbus/core/tx_pool/tx_chain.nim index 21d2eab63..ffa6ad51a 100644 --- a/nimbus/core/tx_pool/tx_chain.nim +++ b/nimbus/core/tx_pool/tx_chain.nim @@ -52,10 +52,10 @@ type profit: UInt256 ## Net reward (w/o PoW specific block rewards) txRoot: Hash256 ## `rootHash` after packing stateRoot: Hash256 ## `stateRoot` after packing - dataGasUsed: - Option[uint64] ## EIP-4844 block dataGasUsed - excessDataGas: - Option[uint64] ## EIP-4844 block excessDataGas + blobGasUsed: + Option[uint64] ## EIP-4844 block blobGasUsed + excessBlobGas: + Option[uint64] ## EIP-4844 block excessBlobGas TxChainRef* = ref object ##\ ## State cache of the transaction environment for creating a new\ @@ -144,8 +144,8 @@ proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256]) dh.txEnv.txRoot = EMPTY_ROOT_HASH dh.txEnv.stateRoot = dh.txEnv.vmState.parent.stateRoot - dh.txEnv.dataGasUsed = none(uint64) - dh.txEnv.excessDataGas = none(uint64) + dh.txEnv.blobGasUsed = none(uint64) + dh.txEnv.excessBlobGas = none(uint64) proc update(dh: TxChainRef; parent: BlockHeader) {.gcsafe,raises: [CatchableError].} = @@ -224,8 +224,8 @@ proc getHeader*(dh: TxChainRef): BlockHeader # mixDigest: Hash256 # mining hash for given difficulty # nonce: BlockNonce # mining free vaiable fee: dh.txEnv.vmState.fee, - dataGasUsed: dh.txEnv.dataGasUsed, - excessDataGas: dh.txEnv.excessDataGas) + blobGasUsed: dh.txEnv.blobGasUsed, + excessBlobGas: dh.txEnv.excessBlobGas) if dh.com.forkGTE(Shanghai): result.withdrawalsRoot = some(calcWithdrawalsRoot(dh.withdrawals)) @@ -378,13 +378,13 @@ proc `txRoot=`*(dh: TxChainRef; val: Hash256) = proc `withdrawals=`*(dh: TxChainRef, val: sink seq[Withdrawal]) = dh.withdrawals = system.move(val) -proc `excessDataGas=`*(dh: TxChainRef; val: Option[uint64]) = +proc `excessBlobGas=`*(dh: TxChainRef; val: Option[uint64]) = ## Setter - dh.txEnv.excessDataGas = val + dh.txEnv.excessBlobGas = val -proc `dataGasUsed=`*(dh: TxChainRef; val: Option[uint64]) = +proc `blobGasUsed=`*(dh: TxChainRef; val: Option[uint64]) = ## Setter - dh.txEnv.dataGasUsed = val + dh.txEnv.blobGasUsed = val # ------------------------------------------------------------------------------ # End diff --git a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim index bc4fc6c0a..c0a96cfbb 100644 --- a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim +++ b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim @@ -233,9 +233,9 @@ proc classifyValidatePacked*(xp: TxPoolRef; else: xp.chain.limits.trgLimit tx = item.tx.eip1559TxNormalization(xp.chain.baseFee.GasInt, fork) - excessDataGas = vmState.parent.excessDataGas.get(0'u64) + excessBlobGas = vmState.parent.excessBlobGas.get(0'u64) - roDB.validateTransaction(tx, item.sender, gasLimit, baseFee, excessDataGas, fork).isOk + roDB.validateTransaction(tx, item.sender, gasLimit, baseFee, excessBlobGas, fork).isOk proc classifyPacked*(xp: TxPoolRef; gasBurned, moreBurned: GasInt): bool = ## Classifier for *packing* (i.e. adding up `gasUsed` values after executing diff --git a/nimbus/core/tx_pool/tx_tasks/tx_packer.nim b/nimbus/core/tx_pool/tx_tasks/tx_packer.nim index 2d8d48515..f601b643b 100644 --- a/nimbus/core/tx_pool/tx_tasks/tx_packer.nim +++ b/nimbus/core/tx_pool/tx_tasks/tx_packer.nim @@ -37,7 +37,7 @@ type tr: CoreDbMptRef cleanState: bool balance: UInt256 - dataGasUsed: uint64 + blobGasUsed: uint64 const receiptsExtensionSize = ##\ @@ -132,9 +132,9 @@ proc runTxCommit(pst: TxPackerStateRef; item: TxItemRef; gasBurned: GasInt) vmState.cumulativeGasUsed += gasBurned vmState.receipts[inx] = vmState.makeReceipt(item.tx.txType) - # EIP-4844, count dataGasUsed + # EIP-4844, count blobGasUsed if item.tx.txType >= TxEip4844: - pst.dataGasUsed += item.tx.getTotalDataGas + pst.blobGasUsed += item.tx.getTotalBlobGas # Update txRoot pst.tr.put(rlp.encode(inx), rlp.encode(item.tx.removeNetworkPayload)) @@ -245,9 +245,9 @@ proc vmExecCommit(pst: TxPackerStateRef) if vmState.com.forkGTE(Cancun): # EIP-4844 - let excessDataGas = calcExcessDataGas(vmState.parent) - xp.chain.excessDataGas = some(excessDataGas) - xp.chain.dataGasUsed = some(pst.dataGasUsed) + let excessBlobGas = calcExcessBlobGas(vmState.parent) + xp.chain.excessBlobGas = some(excessBlobGas) + xp.chain.blobGasUsed = some(pst.blobGasUsed) proc balanceDelta: UInt256 = let postBalance = vmState.readOnlyStateDB.getBalance(xp.chain.feeRecipient) diff --git a/nimbus/core/validate.nim b/nimbus/core/validate.nim index 69bdd87a2..c59c62d5f 100644 --- a/nimbus/core/validate.nim +++ b/nimbus/core/validate.nim @@ -234,7 +234,7 @@ proc validateUncles(com: CommonRef; header: BlockHeader; func gasCost(tx: Transaction): UInt256 = if tx.txType >= TxEip4844: - tx.gasLimit.u256 * tx.maxFee.u256 + tx.getTotalDataGas.u256 * tx.maxFeePerDataGas.u256 + tx.gasLimit.u256 * tx.maxFee.u256 + tx.getTotalBlobGas.u256 * tx.maxFeePerBlobGas.u256 elif tx.txType >= TxEip1559: tx.gasLimit.u256 * tx.maxFee.u256 else: @@ -246,7 +246,7 @@ proc validateTransaction*( sender: EthAddress; ## tx.getSender or tx.ecRecover maxLimit: GasInt; ## gasLimit from block header baseFee: UInt256; ## baseFee from block header - excessDataGas: uint64; ## excessDataGas from parent block header + excessBlobGas: uint64; ## excessBlobGas from parent block header fork: EVMFork): Result[void, string] = let @@ -359,10 +359,10 @@ proc validateTransaction*( "get=$1, expect=$2" % [$bv.data[0].int, $BLOB_COMMITMENT_VERSION_KZG.int]) # ensure that the user was willing to at least pay the current data gasprice - let dataGasPrice = getDataGasPrice(excessDataGas) - if tx.maxFeePerDataGas.uint64 < dataGasPrice: - return err("invalid tx: maxFeePerDataGas smaller than dataGasPrice. " & - "maxFeePerDataGas=$1, dataGasPrice=$2" % [$tx.maxFeePerDataGas, $dataGasPrice]) + let blobGasPrice = getBlobGasPrice(excessBlobGas) + if tx.maxFeePerBlobGas.uint64 < blobGasPrice: + return err("invalid tx: maxFeePerBlobGas smaller than blobGasPrice. " & + "maxFeePerBlobGas=$1, blobGasPrice=$2" % [$tx.maxFeePerBlobGas, $blobGasPrice]) except CatchableError as ex: return err(ex.msg) diff --git a/nimbus/evm/async/data_sources/json_rpc_data_source.nim b/nimbus/evm/async/data_sources/json_rpc_data_source.nim index 34992b3f7..7f5db6c90 100644 --- a/nimbus/evm/async/data_sources/json_rpc_data_source.nim +++ b/nimbus/evm/async/data_sources/json_rpc_data_source.nim @@ -78,7 +78,7 @@ proc makeAnRpcClient*(web3Url: string): Future[RpcClient] {.async.} = uncles*: seq[Hash256] # list of uncle hashes. baseFeePerGas*: Option[UInt256] # EIP-1559 withdrawalsRoot*: Option[Hash256] # EIP-4895 - excessDataGas*: Option[UInt256] # EIP-4844 + excessBlobGas*: Option[UInt256] # EIP-4844 ]# func fromQty(x: Option[Quantity]): Option[uint64] = @@ -107,8 +107,8 @@ func blockHeaderFromBlockObject(o: BlockObject): BlockHeader = nonce: nonce, fee: o.baseFeePerGas, withdrawalsRoot: o.withdrawalsRoot.map(toHash), - dataGasUsed: fromQty(o.dataGasUsed), - excessDataGas: fromQty(o.excessDataGas) + blobGasUsed: fromQty(o.blobGasUsed), + excessBlobGas: fromQty(o.excessBlobGas) ) proc fetchBlockHeaderWithHash*(rpcClient: RpcClient, h: Hash256): Future[BlockHeader] {.async.} = diff --git a/nimbus/evm/computation.nim b/nimbus/evm/computation.nim index 5c9cfd7b2..ecca93820 100644 --- a/nimbus/evm/computation.nim +++ b/nimbus/evm/computation.nim @@ -35,13 +35,13 @@ when defined(evmc_enabled): evmc/evmc, evmc_helpers, evmc_api, - stew/ranges/ptr_arith + stew/ptrops export evmc, evmc_helpers, evmc_api, - ptr_arith + ptrops const evmc_enabled* = defined(evmc_enabled) @@ -117,15 +117,13 @@ template getGasPrice*(c: Computation): GasInt = template getVersionedHash*(c: Computation, index: int): VersionedHash = when evmc_enabled: - # TODO: implement - Hash256() + cast[ptr UncheckedArray[VersionedHash]](c.host.getTxContext().blob_hashes)[index] else: c.vmState.txVersionedHashes[index] template getVersionedHashesLen*(c: Computation): int = when evmc_enabled: - # TODO: implement - 0 + c.host.getTxContext().blob_hashes_count.int else: c.vmState.txVersionedHashes.len diff --git a/nimbus/evm/evmc_api.nim b/nimbus/evm/evmc_api.nim index ae83fca7a..4a5c430da 100644 --- a/nimbus/evm/evmc_api.nim +++ b/nimbus/evm/evmc_api.nim @@ -19,16 +19,18 @@ type # directly if it's not involving stint computation # and we can reduce unecessary conversion further nimbus_tx_context* = object - tx_gas_price* : evmc_uint256be # The transaction gas price. - tx_origin* : EthAddress # The transaction origin account. - block_coinbase* : EthAddress # The miner of the block. - block_number* : int64 # The block number. - block_timestamp* : int64 # The block timestamp. - block_gas_limit* : int64 # The block gas limit. - block_prev_randao*: evmc_uint256be # The block difficulty. - chain_id* : evmc_uint256be # The blockchain's ChainID. - block_base_fee* : evmc_uint256be # The block base fee. - + tx_gas_price* : evmc_uint256be # The transaction gas price. + tx_origin* : EthAddress # The transaction origin account. + block_coinbase* : EthAddress # The miner of the block. + block_number* : int64 # The block number. + block_timestamp* : int64 # The block timestamp. + block_gas_limit* : int64 # The block gas limit. + block_prev_randao*: evmc_uint256be # The block difficulty. + chain_id* : evmc_uint256be # The blockchain's ChainID. + block_base_fee* : evmc_uint256be # The block base fee. + blob_hashes* : ptr evmc_bytes32 # The array of blob hashes (EIP-4844). + blob_hashes_count*: csize_t # The number of blob hashes (EIP-4844). + nimbus_message* = object kind* : evmc_call_kind flags* : uint32 diff --git a/nimbus/graphql/ethapi.nim b/nimbus/graphql/ethapi.nim index 7cd45f7da..a56223ab8 100644 --- a/nimbus/graphql/ethapi.nim +++ b/nimbus/graphql/ethapi.nim @@ -807,7 +807,7 @@ proc txMaxFeePerBlobGas(ud: RootRef, params: Args, parent: Node): RespResult {.a if tx.tx.txType < TxEIP4844: ok(respNull()) else: - longNode(tx.tx.maxFeePerDataGas) + longNode(tx.tx.maxFeePerBlobGas) proc txVersionedHashes(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let ctx = GraphqlContextRef(ud) @@ -1146,15 +1146,15 @@ proc blockWithdrawals(ud: RootRef, params: Args, parent: Node): RespResult {.api proc blockBlobGasUsed(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let h = HeaderNode(parent) - if h.header.dataGasUsed.isSome: - longNode(h.header.dataGasUsed.get) + if h.header.blobGasUsed.isSome: + longNode(h.header.blobGasUsed.get) else: ok(respNull()) proc blockexcessBlobGas(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let h = HeaderNode(parent) - if h.header.excessDataGas.isSome: - longNode(h.header.excessDataGas.get) + if h.header.excessBlobGas.isSome: + longNode(h.header.excessBlobGas.get) else: ok(respNull()) diff --git a/nimbus/transaction/call_common.nim b/nimbus/transaction/call_common.nim index a5851556f..b9378d74b 100644 --- a/nimbus/transaction/call_common.nim +++ b/nimbus/transaction/call_common.nim @@ -246,7 +246,7 @@ proc prepareToRunComputation(host: TransactionHost, call: CallParams) = # EIP-4844 if fork >= FkCancun: let blobFee = calcDataFee(call.versionedHashes.len, - vmState.parent.excessDataGas).GasInt + vmState.parent.excessBlobGas).GasInt db.subBalance(call.sender, blobFee.u256) proc calculateAndPossiblyRefundGas(host: TransactionHost, call: CallParams): GasInt = diff --git a/nimbus/transaction/host_call_nested.nim b/nimbus/transaction/host_call_nested.nim index 997172504..a40dbc2bd 100644 --- a/nimbus/transaction/host_call_nested.nim +++ b/nimbus/transaction/host_call_nested.nim @@ -10,7 +10,7 @@ import eth/common/eth_types, - stew/ranges/ptr_arith, + stew/ptrops, stint, ".."/[vm_types, vm_computation], ../utils/utils, diff --git a/nimbus/transaction/host_services.nim b/nimbus/transaction/host_services.nim index 468787909..a182a73bb 100644 --- a/nimbus/transaction/host_services.nim +++ b/nimbus/transaction/host_services.nim @@ -65,6 +65,15 @@ proc setupTxContext(host: TransactionHost) = host.txContext.chain_id = vmState.com.chainId.uint.u256.toEvmc host.txContext.block_base_fee = vmState.baseFee.toEvmc + if vmState.txVersionedHashes.len > 0: + type + BlobHashPtr = typeof host.txContext.blob_hashes + host.txContext.blob_hashes = cast[BlobHashPtr](vmState.txVersionedHashes[0].addr) + else: + host.txContext.blob_hashes = nil + + host.txContext.blob_hashes_count= vmState.txVersionedHashes.len.csize_t + # Most host functions do `flip256` in `evmc_host_glue`, but due to this # result being cached, it's better to do `flip256` when filling the cache. host.txContext.tx_gas_price = flip256(host.txContext.tx_gas_price) diff --git a/nimbus/transaction/host_trace.nim b/nimbus/transaction/host_trace.nim index 576a1d496..b9a0756c4 100644 --- a/nimbus/transaction/host_trace.nim +++ b/nimbus/transaction/host_trace.nim @@ -10,7 +10,7 @@ import macros, strformat, strutils, stint, chronicles, - stew/byteutils, stew/ranges/ptr_arith, + stew/byteutils, stew/ptrops, ./host_types # Set `true` or `false` to control host call tracing. diff --git a/nimbus/utils/debug.nim b/nimbus/utils/debug.nim index 443c1a287..141730af3 100644 --- a/nimbus/utils/debug.nim +++ b/nimbus/utils/debug.nim @@ -51,10 +51,10 @@ proc debug*(h: BlockHeader): string = result.add "fee : " & $h.fee.get() & "\n" if h.withdrawalsRoot.isSome: result.add "withdrawalsRoot: " & $h.withdrawalsRoot.get() & "\n" - if h.dataGasUsed.isSome: - result.add "dataGasUsed : " & $h.dataGasUsed.get() & "\n" - if h.excessDataGas.isSome: - result.add "excessDataGas : " & $h.excessDataGas.get() & "\n" + if h.blobGasUsed.isSome: + result.add "blobGasUsed : " & $h.blobGasUsed.get() & "\n" + if h.excessBlobGas.isSome: + result.add "excessBlobGas : " & $h.excessBlobGas.get() & "\n" result.add "blockHash : " & $blockHash(h) & "\n" proc dumpAccount(stateDB: AccountsCache, address: EthAddress): JsonNode = diff --git a/nimbus_verified_proxy/nimbus_verified_proxy_conf.nim b/nimbus_verified_proxy/nimbus_verified_proxy_conf.nim index 6f4c74612..edaabf3fe 100644 --- a/nimbus_verified_proxy/nimbus_verified_proxy_conf.nim +++ b/nimbus_verified_proxy/nimbus_verified_proxy_conf.nim @@ -167,7 +167,7 @@ type VerifiedProxyConf* = object proc parseCmdArg*( - T: type Web3Url, p: string): T {.raises: [ConfigurationError].} = + T: type Web3Url, p: string): T {.raises: [ValueError].} = let url = parseUri(p) normalizedScheme = url.scheme.toLowerAscii() @@ -178,7 +178,7 @@ proc parseCmdArg*( Web3Url(kind: WsUrl, web3Url: p) else: raise newException( - ConfigurationError, "Web3 url should have defined scheme (http/https/ws/wss)" + ValueError, "Web3 url should have defined scheme (http/https/ws/wss)" ) proc completeCmdArg*(T: type Web3Url, val: string): seq[string] = diff --git a/tests/replay/pp.nim b/tests/replay/pp.nim index 2d2718c11..7fe6486bf 100644 --- a/tests/replay/pp.nim +++ b/tests/replay/pp.nim @@ -56,8 +56,8 @@ proc pp*(h: BlockHeader; sep = " "): string = &"stateRoot={h.stateRoot.pp}{sep}" & &"baseFee={h.baseFee}{sep}" & &"withdrawalsRoot={h.withdrawalsRoot.get(EMPTY_ROOT_HASH)}{sep}" & - &"dataGasUsed={h.dataGasUsed.get(0'u64)}" & - &"excessDataGas={h.excessDataGas.get(0'u64)}" + &"blobGasUsed={h.blobGasUsed.get(0'u64)}" & + &"excessBlobGas={h.excessBlobGas.get(0'u64)}" proc pp*(g: Genesis; sep = " "): string = "" & diff --git a/tests/test_eip4844.nim b/tests/test_eip4844.nim index 4b312f9da..40c16d346 100644 --- a/tests/test_eip4844.nim +++ b/tests/test_eip4844.nim @@ -119,7 +119,7 @@ proc tx7(i: int): Transaction = maxFee: 10.GasInt, accessList: accesses, versionedHashes: @[digest], - maxFeePerDataGas: 10000000.GasInt, + maxFeePerBlobGas: 10000000.GasInt, ) proc tx8(i: int): Transaction = @@ -136,7 +136,7 @@ proc tx8(i: int): Transaction = maxFee: 10.GasInt, accessList: accesses, versionedHashes: @[digest], - maxFeePerDataGas: 10000000.GasInt, + maxFeePerBlobGas: 10000000.GasInt, ) proc privKey(keyHex: string): PrivateKey = diff --git a/tools/evmstate/helpers.nim b/tools/evmstate/helpers.nim index d4c7e1333..d26052a08 100644 --- a/tools/evmstate/helpers.nim +++ b/tools/evmstate/helpers.nim @@ -113,7 +113,9 @@ proc parseHeader*(n: JsonNode): BlockHeader = timestamp : required(EthTime, "currentTimestamp"), stateRoot : emptyRlpHash, mixDigest : omitZero(Hash256, "currentRandom"), - fee : optional(UInt256, "currentBaseFee") + fee : optional(UInt256, "currentBaseFee"), + excessBlobGas: optional(uint64, "excessBlobGas"), + blobGasUsed: optional(uint64, "blobGasUsed") ) proc parseTx*(n: JsonNode, dataIndex, gasIndex, valueIndex: int): Transaction = @@ -128,7 +130,7 @@ proc parseTx*(n: JsonNode, dataIndex, gasIndex, valueIndex: int): Transaction = maxFee : omitZero(GasInt, "maxFeePerGas"), accessList: omitZero(AccessList, "accessLists", dataIndex), maxPriorityFee: omitZero(GasInt, "maxPriorityFeePerGas"), - maxFeePerDataGas: omitZero(GasInt, "maxFeePerDataGas"), + maxFeePerBlobGas: omitZero(GasInt, "maxFeePerBlobGas"), versionedHashes: omitZero(VersionedHashes, "blobVersionedHashes") ) diff --git a/tools/t8n/helpers.nim b/tools/t8n/helpers.nim index 0a8369c97..2af9ed9c0 100644 --- a/tools/t8n/helpers.nim +++ b/tools/t8n/helpers.nim @@ -179,8 +179,10 @@ proc parseEnv*(ctx: var TransContext, n: JsonNode) = optional(ctx.env, UInt256, parentBaseFee) optional(ctx.env, GasInt, parentGasUsed) optional(ctx.env, GasInt, parentGasLimit) - optional(ctx.env, uint64, parentDataGasUsed) - optional(ctx.env, uint64, parentExcessDataGas) + optional(ctx.env, uint64, currentBlobGasUsed) + optional(ctx.env, uint64, currentExcessBlobGas) + optional(ctx.env, uint64, parentBlobGasUsed) + optional(ctx.env, uint64, parentExcessBlobGas) if n.hasKey("blockHashes"): let w = n["blockHashes"] @@ -234,7 +236,7 @@ proc parseTx(n: JsonNode, chainId: ChainID): Transaction = required(tx, GasInt, maxPriorityFeePerGas) required(tx, GasInt, maxFeePerGas) omitZero(tx, AccessList, accessList) - required(tx, GasInt, maxFeePerDataGas) + required(tx, GasInt, maxFeePerBlobGas) required(tx, VersionedHashes, blobVersionedHashes) var eip155 = true @@ -440,7 +442,7 @@ proc `@@`*(x: ExecutionResult): JsonNode = result["currentBaseFee"] = @@(x.currentBaseFee) if x.withdrawalsRoot.isSome: result["withdrawalsRoot"] = @@(x.withdrawalsRoot) - if x.dataGasUsed.isSome: - result["dataGasUsed"] = @@(x.dataGasUsed) - if x.excessDataGas.isSome: - result["excessDataGas"] = @@(x.excessDataGas) + if x.blobGasUsed.isSome: + result["blobGasUsed"] = @@(x.blobGasUsed) + if x.excessBlobGas.isSome: + result["excessBlobGas"] = @@(x.excessBlobGas) diff --git a/tools/t8n/testdata/00-517/env.json b/tools/t8n/testdata/00-517/env.json index b1f22a39b..b07d44f70 100644 --- a/tools/t8n/testdata/00-517/env.json +++ b/tools/t8n/testdata/00-517/env.json @@ -14,6 +14,6 @@ "amount": "0x2a" } ], - "parentDataGasUsed": "0x100", - "parentExcessDataGas": "0x100" + "parentBlobGasUsed": "0x100", + "parentExcessBlobGas": "0x100" } diff --git a/tools/t8n/testdata/00-517/exp.json b/tools/t8n/testdata/00-517/exp.json index 311609cb4..b27eabd64 100644 --- a/tools/t8n/testdata/00-517/exp.json +++ b/tools/t8n/testdata/00-517/exp.json @@ -16,7 +16,7 @@ "gasUsed": "0x0", "currentBaseFee": "0x500", "withdrawalsRoot": "0x4921c0162c359755b2ae714a0978a1dad2eb8edce7ff9b38b9b6fc4cbc547eb5", - "dataGasUsed": "0x0", - "excessDataGas": "0x0" + "blobGasUsed": "0x0", + "excessBlobGas": "0x0" } } diff --git a/tools/t8n/testdata/00-518/env.json b/tools/t8n/testdata/00-518/env.json index 8dd2e1b4d..acb30c5ad 100644 --- a/tools/t8n/testdata/00-518/env.json +++ b/tools/t8n/testdata/00-518/env.json @@ -6,8 +6,8 @@ "currentNumber" : "0x01", "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", "currentTimestamp" : "0x03e8", - "parentDataGasUsed" : "0x2000", - "parentExcessDataGas" : "0x1000", + "parentBlobGasUsed" : "0x2000", + "parentExcessBlobGas" : "0x1000", "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "withdrawals": [] } diff --git a/tools/t8n/testdata/00-518/exp.json b/tools/t8n/testdata/00-518/exp.json index 5c794271b..636aeae9d 100644 --- a/tools/t8n/testdata/00-518/exp.json +++ b/tools/t8n/testdata/00-518/exp.json @@ -25,7 +25,7 @@ ], "currentBaseFee": "0x7", "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "dataGasUsed": "0x0", - "excessDataGas": "0x0" + "blobGasUsed": "0x0", + "excessBlobGas": "0x0" } } diff --git a/tools/t8n/transition.nim b/tools/t8n/transition.nim index 6d0d60c01..77a124e49 100644 --- a/tools/t8n/transition.nim +++ b/tools/t8n/transition.nim @@ -99,7 +99,9 @@ proc envToHeader(env: EnvStruct): BlockHeader = timestamp : env.currentTimestamp, stateRoot : emptyRlpHash, fee : env.currentBaseFee, - withdrawalsRoot: env.withdrawals.calcWithdrawalsRoot() + withdrawalsRoot: env.withdrawals.calcWithdrawalsRoot(), + blobGasUsed: env.currentBlobGasUsed, + excessBlobGas: env.currentExcessBlobGas ) proc postState(db: AccountsCache, alloc: var GenesisAlloc) = @@ -213,7 +215,7 @@ proc exec(ctx: var TransContext, vmState.receipts = newSeqOfCap[Receipt](txList.len) vmState.cumulativeGasUsed = 0 - var dataGasUsed = 0'u64 + var blobGasUsed = 0'u64 for txIndex, txRes in txList: if txRes.isErr: rejected.add RejectedTx( @@ -253,7 +255,7 @@ proc exec(ctx: var TransContext, rec, tx, sender, txIndex, gasUsed ) includedTx.add tx - dataGasUsed += tx.getTotalDataGas + blobGasUsed += tx.getTotalBlobGas # Add mining reward? (-1 means rewards are disabled) if stateReward.isSome and stateReward.get >= 0: @@ -302,8 +304,8 @@ proc exec(ctx: var TransContext, ) if fork >= FkCancun: - result.result.dataGasUsed = some dataGasUsed - result.result.excessDataGas = some calcExcessDataGas(vmState.parent) + result.result.blobGasUsed = some blobGasUsed + result.result.excessBlobGas = some calcExcessBlobGas(vmState.parent) template wrapException(body: untyped) = when wrapExceptionEnabled: @@ -408,8 +410,8 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) = difficulty: ctx.env.parentDifficulty.get(0.u256), ommersHash: uncleHash, blockNumber: ctx.env.currentNumber - 1.toBlockNumber, - dataGasUsed: ctx.env.parentDataGasUsed, - excessDataGas: ctx.env.parentExcessDataGas + blobGasUsed: ctx.env.parentBlobGasUsed, + excessBlobGas: ctx.env.parentExcessBlobGas ) # Sanity check, to not `panic` in state_transition @@ -426,11 +428,11 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) = raise newError(ErrorConfig, "Shanghai config but missing 'withdrawals' in env section") if com.isCancunOrLater(ctx.env.currentTimestamp): - if ctx.env.parentDataGasUsed.isNone: - raise newError(ErrorConfig, "Cancun config but missing 'parentDataGasUsed' in env section") + if ctx.env.parentBlobGasUsed.isNone: + raise newError(ErrorConfig, "Cancun config but missing 'parentBlobGasUsed' in env section") - if ctx.env.parentExcessDataGas.isNone: - raise newError(ErrorConfig, "Cancun config but missing 'parentExcessDataGas' in env section") + if ctx.env.parentExcessBlobGas.isNone: + raise newError(ErrorConfig, "Cancun config but missing 'parentExcessBlobGas' in env section") let res = loadKzgTrustedSetup() if res.isErr: diff --git a/tools/t8n/types.nim b/tools/t8n/types.nim index f8feb55c5..48a127024 100644 --- a/tools/t8n/types.nim +++ b/tools/t8n/types.nim @@ -44,8 +44,10 @@ type parentGasUsed*: Option[GasInt] parentGasLimit*: Option[GasInt] withdrawals*: Option[seq[Withdrawal]] - parentDataGasUsed*: Option[uint64] - parentExcessDataGas*: Option[uint64] + currentBlobGasUsed*: Option[uint64] + currentExcessBlobGas*: Option[uint64] + parentBlobGasUsed*: Option[uint64] + parentExcessBlobGas*: Option[uint64] TxsType* = enum TxsNone @@ -94,8 +96,8 @@ type gasUsed*: GasInt currentBaseFee*: Option[UInt256] withdrawalsRoot*: Option[Hash256] - dataGasUsed*: Option[uint64] - excessDataGas*: Option[uint64] + blobGasUsed*: Option[uint64] + excessBlobGas*: Option[uint64] const ErrorEVM* = 2.T8NExitCode diff --git a/vendor/nim-blscurve b/vendor/nim-blscurve index d3920425c..81ed3ff37 160000 --- a/vendor/nim-blscurve +++ b/vendor/nim-blscurve @@ -1 +1 @@ -Subproject commit d3920425c5c02b0a7766045c064c888cd5b83e72 +Subproject commit 81ed3ff376e6549aead42e506861b3a6ef63b7fa diff --git a/vendor/nim-chronos b/vendor/nim-chronos index 0035f4fa6..c4b066a2c 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit 0035f4fa6692e85756aa192b4df84c21d3cacacb +Subproject commit c4b066a2c4faeedd564e8467a9416920bfb4b9a9 diff --git a/vendor/nim-confutils b/vendor/nim-confutils index 1f3acaf6e..dbe8d61f7 160000 --- a/vendor/nim-confutils +++ b/vendor/nim-confutils @@ -1 +1 @@ -Subproject commit 1f3acaf6e968ea8e4ec3eec177aebd50eef1040c +Subproject commit dbe8d61f7fbb1cb9d74b38f9012406c8071aa9e9 diff --git a/vendor/nim-eth b/vendor/nim-eth index 26ae53959..2ed8e991b 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 26ae539598e31efbaa016f6694b9a60ea08fc4b6 +Subproject commit 2ed8e991b543156dbf3faf0d000e1cfc168498d2 diff --git a/vendor/nim-evmc b/vendor/nim-evmc index 144b13e0c..78fb00187 160000 --- a/vendor/nim-evmc +++ b/vendor/nim-evmc @@ -1 +1 @@ -Subproject commit 144b13e0ccef229bc9118311e1735d0a23ac4dd5 +Subproject commit 78fb00187f19dd0306acab82a52f91ab40217f94 diff --git a/vendor/nim-faststreams b/vendor/nim-faststreams index 583974782..720fc5e5c 160000 --- a/vendor/nim-faststreams +++ b/vendor/nim-faststreams @@ -1 +1 @@ -Subproject commit 583974782f1d5487e16cc72289cd97e8897bc894 +Subproject commit 720fc5e5c8e428d9d0af618e1e27c44b42350309 diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc index 0bf2bcbe7..32200345f 160000 --- a/vendor/nim-json-rpc +++ b/vendor/nim-json-rpc @@ -1 +1 @@ -Subproject commit 0bf2bcbe74a18a3c7a709d57108bb7b51e748a92 +Subproject commit 32200345f80a3b5f72e15d1b4e9363363d95a1cd diff --git a/vendor/nim-snappy b/vendor/nim-snappy index 7cb2e57a5..ecbcee1d1 160000 --- a/vendor/nim-snappy +++ b/vendor/nim-snappy @@ -1 +1 @@ -Subproject commit 7cb2e57a58619a6ca2be94db94591467a41d8476 +Subproject commit ecbcee1d100140db6cb9c13d753d739fb5102fa3 diff --git a/vendor/nim-taskpools b/vendor/nim-taskpools index 17e8479a7..ffba69121 160000 --- a/vendor/nim-taskpools +++ b/vendor/nim-taskpools @@ -1 +1 @@ -Subproject commit 17e8479a7495ac96480485782c09b6d4f4bcfa12 +Subproject commit ffba69121689e14c0aa286c885d00b90889571e6 diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 1f9fa11d0..04f56c593 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 1f9fa11d0e63c16aa4ec30e1f7328ae61254d7d0 +Subproject commit 04f56c593a035af1b7bebdc726543a2a73826412 diff --git a/vendor/nimbus-eth2 b/vendor/nimbus-eth2 index 970f5dfc4..8f1849113 160000 --- a/vendor/nimbus-eth2 +++ b/vendor/nimbus-eth2 @@ -1 +1 @@ -Subproject commit 970f5dfc4e2df53d12ed71fc591e23ecc2bafb60 +Subproject commit 8f184911311d5b891fc2e83420f21206463d422b diff --git a/vendor/nimcrypto b/vendor/nimcrypto index 24e006df8..f62df96cf 160000 --- a/vendor/nimcrypto +++ b/vendor/nimcrypto @@ -1 +1 @@ -Subproject commit 24e006df85927f64916e60511620583b11403178 +Subproject commit f62df96cfc43f1e1c0acaf12807cfe99b3b45a9d