Skip to content

Commit 4ecc569

Browse files
authored
Expose origin and the addresses of contracts being constructed in precompile handle (#313)
1 parent e81732d commit 4ecc569

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
@@ -1582,6 +1582,11 @@ impl<'config, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
15821582
self.context
15831583
}
15841584

1585+
/// Retreive the address of the EOA that originated the transaction.
1586+
fn origin(&self) -> H160 {
1587+
self.executor.state.origin()
1588+
}
1589+
15851590
/// Is the precompile call is done statically.
15861591
fn is_static(&self) -> bool {
15871592
self.is_static
@@ -1591,4 +1596,9 @@ impl<'config, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
15911596
fn gas_limit(&self) -> Option<u64> {
15921597
self.gas_limit
15931598
}
1599+
1600+
/// Check if a given address is a contract being constructed
1601+
fn is_contract_being_constructed(&self, address: H160) -> bool {
1602+
self.executor.state.created(address)
1603+
}
15941604
}

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)