Skip to content

Commit

Permalink
feat(tracing): js-tracer add coinbase into context (#223)
Browse files Browse the repository at this point in the history
add `coinbase` into js-tracer's context, backport
ethereum/go-ethereum#30231

---------

Signed-off-by: jsvisa <delweng@gmail.com>
  • Loading branch information
jsvisa authored Oct 15, 2024
1 parent d55d3c1 commit c16d1b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tracing/js/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ pub(crate) struct JsEvmContext {
pub(crate) value: U256,
/// Number, block number
pub(crate) block: u64,
/// Address, miner of the block
pub(crate) coinbase: Address,
pub(crate) output: Bytes,
/// Number, block timestamp
pub(crate) time: String,
Expand All @@ -692,6 +694,7 @@ impl JsEvmContext {
intrinsic_gas,
value,
block,
coinbase,
output,
time,
transaction_ctx,
Expand All @@ -716,6 +719,7 @@ impl JsEvmContext {
obj.set(js_string!("intrinsicGas"), intrinsic_gas, false, ctx)?;
obj.set(js_string!("value"), to_bigint(value, ctx)?, false, ctx)?;
obj.set(js_string!("block"), block, false, ctx)?;
obj.set(js_string!("coinbase"), address_to_byte_array(coinbase, ctx)?, false, ctx)?;
obj.set(js_string!("output"), to_byte_array(output, ctx)?, false, ctx)?;
obj.set(js_string!("time"), js_string!(time), false, ctx)?;
if let Some(block_hash) = transaction_ctx.block_hash {
Expand Down
1 change: 1 addition & 0 deletions src/tracing/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ impl JsInspector {
gas_price: env.tx.gas_price.try_into().unwrap_or(u64::MAX),
value: env.tx.value,
block: env.block.number.try_into().unwrap_or(u64::MAX),
coinbase: env.block.coinbase,
output: output_bytes.unwrap_or_default(),
time: env.block.timestamp.to_string(),
intrinsic_gas: 0,
Expand Down

0 comments on commit c16d1b8

Please sign in to comment.