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

Add TXCREATE transaction initcodes support - new approach #709

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions bindings/go/evmc/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func getTxContext(pCtx unsafe.Pointer) C.struct_evmc_tx_context {
evmcBytes32(txContext.BlobBaseFee),
nil, // TODO: Add support for blob hashes.
0,
nil, // TODO: Add support for transaction initcodes.
0,
}
}

Expand Down
2 changes: 2 additions & 0 deletions bindings/rust/evmc-vm/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ mod tests {
blob_base_fee: Uint256::default(),
blob_hashes: std::ptr::null(),
blob_hashes_count: 0,
initcodes: std::ptr::null(),
initcodes_count: 0,
}
}

Expand Down
2 changes: 2 additions & 0 deletions bindings/rust/evmc-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ mod tests {
blob_base_fee: Uint256::default(),
blob_hashes: std::ptr::null(),
blob_hashes_count: 0,
initcodes: std::ptr::null(),
initcodes_count: 0,
}
}

Expand Down
38 changes: 24 additions & 14 deletions include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ struct evmc_message
/**
* The optional value used in new contract address construction.
*
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2.
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2 or
* ::EVMC_EOFCREATE.
* Ignored in evmc_execute_fn().
*/
evmc_bytes32 create2_salt;
Expand All @@ -180,7 +181,7 @@ struct evmc_message
* For ::EVMC_CALLCODE or ::EVMC_DELEGATECALL this may be different from
* the evmc_message::recipient.
* Not required when invoking evmc_execute_fn(), only when invoking evmc_call_fn().
* Ignored if kind is ::EVMC_CREATE or ::EVMC_CREATE2.
* Ignored if kind is ::EVMC_CREATE, ::EVMC_CREATE2 or ::EVMC_EOFCREATE.
*
* In case of ::EVMC_CAPABILITY_PRECOMPILES implementation, this fields should be inspected
* to identify the requested precompile.
Expand All @@ -200,22 +201,31 @@ struct evmc_message
size_t code_size;
};

/** The hashed initcode used for TXCREATE instruction. */
typedef struct evmc_tx_initcode
{
evmc_bytes32 hash; /**< The initcode hash. */
const uint8_t* code; /**< The code. */
size_t code_size; /**< The length of the code. */
} evmc_tx_initcode;

/** The transaction and block data for execution. */
struct evmc_tx_context
{
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
evmc_address tx_origin; /**< The transaction origin account. */
evmc_address block_coinbase; /**< The miner of the block. */
int64_t block_number; /**< The block number. */
int64_t block_timestamp; /**< The block timestamp. */
int64_t block_gas_limit; /**< The block gas limit. */
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). */
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
evmc_address tx_origin; /**< The transaction origin account. */
evmc_address block_coinbase; /**< The miner of the block. */
int64_t block_number; /**< The block number. */
int64_t block_timestamp; /**< The block timestamp. */
int64_t block_gas_limit; /**< The block gas limit. */
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). */
const evmc_tx_initcode* initcodes; /**< The array of transaction initcodes (TXCREATE). */
size_t initcodes_count; /**< The number of transaction initcodes (TXCREATE). */
};

/**
Expand Down