Skip to content

Commit 092e1f5

Browse files
committed
Expose origin and the addresses of contracts being constructed in precompile handle
1 parent c80aec8 commit 092e1f5

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/executor/stack/executor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,11 @@ impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Pr
15951595
self.context
15961596
}
15971597

1598+
/// Retreive the address of the EOA that originated the transaction.
1599+
fn origin(&self) -> H160 {
1600+
self.executor.state.origin()
1601+
}
1602+
15981603
/// Is the precompile call is done statically.
15991604
fn is_static(&self) -> bool {
16001605
self.is_static
@@ -1604,4 +1609,9 @@ impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Pr
16041609
fn gas_limit(&self) -> Option<u64> {
16051610
self.gas_limit
16061611
}
1612+
1613+
/// Check if a given address is a contract being constructed
1614+
fn is_contract_being_constructed(&self, address: H160) -> bool {
1615+
self.executor.state.created(address)
1616+
}
16071617
}

src/executor/stack/precompile.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ pub trait PrecompileHandle {
7676
/// Retreive the context in which the precompile is executed.
7777
fn context(&self) -> &Context;
7878

79+
/// Retreive the address of the EOA that originated the transaction.
80+
fn origin(&self) -> H160;
81+
7982
/// Is the precompile call is done statically.
8083
fn is_static(&self) -> bool;
8184

8285
/// Retreive the gas limit of this call.
8386
fn gas_limit(&self) -> Option<u64>;
87+
88+
/// Check if a given address is a contract being constructed
89+
fn is_contract_being_constructed(&self, address: H160) -> bool;
8490
}
8591

8692
/// A set of precompiles.

0 commit comments

Comments
 (0)