Skip to content

Commit

Permalink
Extended tx_context with "blob base fee" (#696)
Browse files Browse the repository at this point in the history
Extended `tx_context` with
the [EIP-7516](https://eips.ethereum.org/EIPS/eip-7516) "blob base fee"
for the `BLOBBASEFEE` EVM instruction.
  • Loading branch information
chfast committed Sep 22, 2023
1 parent 4c12b57 commit 3d29144
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -9,8 +9,11 @@ and this project adheres to [Semantic Versioning].

### Added

- Extended `tx_context` with [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob hashes
- Extended `tx_context` with the [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob hashes
[#691](https://github.com/ethereum/evmc/pull/691)
- Extended `tx_context` with the [EIP-7516](https://eips.ethereum.org/EIPS/eip-7516) "blob base fee"
for the `BLOBBASEFEE` EVM instruction.
[#696](https://github.com/ethereum/evmc/pull/696)
- Added [EIP-1153](https://eips.ethereum.org/EIPS/eip-1153) transient storage support
[#693](https://github.com/ethereum/evmc/pull/693)

Expand Down
20 changes: 11 additions & 9 deletions bindings/go/evmc/host.go
Expand Up @@ -72,15 +72,16 @@ func goByteSlice(data *C.uint8_t, size C.size_t) []byte {

// TxContext contains information about current transaction and block.
type TxContext struct {
GasPrice Hash
Origin Address
Coinbase Address
Number int64
Timestamp int64
GasLimit int64
PrevRandao Hash
ChainID Hash
BaseFee Hash
GasPrice Hash
Origin Address
Coinbase Address
Number int64
Timestamp int64
GasLimit int64
PrevRandao Hash
ChainID Hash
BaseFee Hash
BlobBaseFee Hash
}

type HostContext interface {
Expand Down Expand Up @@ -181,6 +182,7 @@ func getTxContext(pCtx unsafe.Pointer) C.struct_evmc_tx_context {
evmcBytes32(txContext.PrevRandao),
evmcBytes32(txContext.ChainID),
evmcBytes32(txContext.BaseFee),
evmcBytes32(txContext.BlobBaseFee),
nil, // TODO: Add support for blob hashes.
0,
}
Expand Down
Expand Up @@ -63,7 +63,7 @@ public ByteBuffer call(ByteBuffer msg) {

@Override
public ByteBuffer getTxContext() {
return ByteBuffer.allocateDirect(208).put(new byte[208]);
return ByteBuffer.allocateDirect(240).put(new byte[240]);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions bindings/rust/evmc-vm/src/container.rs
Expand Up @@ -102,6 +102,7 @@ mod tests {
block_prev_randao: Uint256::default(),
chain_id: Uint256::default(),
block_base_fee: Uint256::default(),
blob_base_fee: Uint256::default(),
blob_hashes: std::ptr::null(),
blob_hashes_count: 0,
}
Expand Down
1 change: 1 addition & 0 deletions bindings/rust/evmc-vm/src/lib.rs
Expand Up @@ -806,6 +806,7 @@ mod tests {
block_prev_randao: Uint256 { bytes: [0xaa; 32] },
chain_id: Uint256::default(),
block_base_fee: Uint256::default(),
blob_base_fee: Uint256::default(),
blob_hashes: std::ptr::null(),
blob_hashes_count: 0,
}
Expand Down
1 change: 1 addition & 0 deletions include/evmc/evmc.h
Expand Up @@ -202,6 +202,7 @@ struct evmc_tx_context
evmc_uint256be block_prev_randao; /**< The block previous RANDAO (EIP-4399). */
evmc_uint256be chain_id; /**< The blockchain's ChainID. */
evmc_uint256be block_base_fee; /**< The block base fee per gas (EIP-1559, EIP-3198). */
evmc_uint256be blob_base_fee; /**< The blob base fee (EIP-7516). */
const evmc_bytes32* blob_hashes; /**< The array of blob hashes (EIP-4844). */
size_t blob_hashes_count; /**< The number of blob hashes (EIP-4844). */
};
Expand Down

0 comments on commit 3d29144

Please sign in to comment.