Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename data gas to blob gas #1659

Merged
merged 8 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
extend evmc tx_context with EIP-4844 blob_hashes
  • Loading branch information
jangko committed Aug 4, 2023
commit 279759e8a3712e82371d8b626f71bf57f722f2ef
10 changes: 4 additions & 6 deletions nimbus/evm/computation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
22 changes: 12 additions & 10 deletions nimbus/evm/evmc_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nimbus/transaction/host_call_nested.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import
eth/common/eth_types,
stew/ranges/ptr_arith,
stew/ptrops,
stint,
".."/[vm_types, vm_computation],
../utils/utils,
Expand Down
9 changes: 9 additions & 0 deletions nimbus/transaction/host_services.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion nimbus/transaction/host_trace.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion vendor/nim-evmc