Skip to content

Commit ba240c8

Browse files
committed
Expose origin and the addresses of contracts being constructed in precompile handle
1 parent 801557d commit ba240c8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/executor/stack/executor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,11 @@ impl<'config, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
15891589
self.context
15901590
}
15911591

1592+
/// Retreive the address of the EOA that originated the transaction.
1593+
fn origin(&self) -> H160 {
1594+
self.executor.state.origin()
1595+
}
1596+
15921597
/// Is the precompile call is done statically.
15931598
fn is_static(&self) -> bool {
15941599
self.is_static
@@ -1598,4 +1603,9 @@ impl<'config, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
15981603
fn gas_limit(&self) -> Option<u64> {
15991604
self.gas_limit
16001605
}
1606+
1607+
/// Check if a given address is a contract being constructed
1608+
fn is_contract_being_constructed(&self, address: H160) -> bool {
1609+
self.executor.state.created(address)
1610+
}
16011611
}

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)