Skip to content

Commit d68466a

Browse files
authored
Fetch bytecode hash from contract and more logs (#103)
1 parent 2bef7ee commit d68466a

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

auction-server/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

auction-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "auction-server"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
edition = "2021"
55
license-file = "license.txt"
66

auction-server/src/auction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use {
3434
abigen,
3535
ContractError,
3636
ContractRevert,
37-
EthError,
3837
EthEvent,
3938
FunctionCall,
4039
},

auction-server/src/opportunity_adapter.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use {
6363
Signature,
6464
U256,
6565
},
66-
utils::get_create2_address,
66+
utils::get_create2_address_from_hash,
6767
},
6868
rand::Rng,
6969
serde::{
@@ -115,6 +115,18 @@ pub async fn get_weth_address(
115115
.map_err(|e| anyhow!("Error getting WETH address from adapter: {:?}", e))
116116
}
117117

118+
pub async fn get_adapter_bytecode_hash(
119+
adapter_contract: Address,
120+
provider: Provider<TracedClient>,
121+
) -> Result<[u8; 32]> {
122+
let adapter = AdapterFactory::new(adapter_contract, Arc::new(provider));
123+
adapter
124+
.get_opportunity_adapter_creation_code_hash()
125+
.call()
126+
.await
127+
.map_err(|e| anyhow!("Error getting adapter code hash from adapter: {:?}", e))
128+
}
129+
118130
pub async fn get_permit2_address(
119131
adapter_contract: Address,
120132
provider: Provider<TracedClient>,
@@ -248,7 +260,14 @@ pub async fn verify_opportunity(
248260
match MulticallReturn::decode(&result) {
249261
Ok(result) => {
250262
if !result.multicall_statuses[0].external_success {
251-
return Err(anyhow!("Express Relay Simulation failed"));
263+
tracing::info!(
264+
"Opportunity simulation failed: {:?}",
265+
result.multicall_statuses[0]
266+
);
267+
return Err(anyhow!(
268+
"Express Relay Simulation failed: {:?}",
269+
result.multicall_statuses[0].external_result
270+
));
252271
}
253272
}
254273
Err(e) => return Err(anyhow!(format!("Error decoding multicall result: {:?}", e))),
@@ -403,10 +422,10 @@ pub fn make_opportunity_execution_params(
403422
) -> ExecutionParamsWithSignature {
404423
let mut salt = [0u8; 32];
405424
salt[12..32].copy_from_slice(bid.executor.as_bytes());
406-
let executor_adapter_address = get_create2_address(
425+
let executor_adapter_address = get_create2_address_from_hash(
407426
chain_store.config.adapter_factory_contract,
408427
salt,
409-
&OPPORTUNITYADAPTER_BYTECODE,
428+
chain_store.adapter_bytecode_hash,
410429
);
411430
let eip_712_domain = EIP712Domain {
412431
name: Some("Permit2".to_string()),

auction-server/src/server.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use {
1717
},
1818
models,
1919
opportunity_adapter::{
20+
get_adapter_bytecode_hash,
2021
get_permit2_address,
2122
get_weth_address,
2223
run_verification_loop,
@@ -182,6 +183,11 @@ pub async fn start_server(run_options: RunOptions) -> anyhow::Result<()> {
182183
let weth =
183184
get_weth_address(chain_config.adapter_factory_contract, provider.clone())
184185
.await?;
186+
let adapter_bytecode_hash = get_adapter_bytecode_hash(
187+
chain_config.adapter_factory_contract,
188+
provider.clone(),
189+
)
190+
.await?;
185191

186192
Ok((
187193
chain_id.clone(),
@@ -193,6 +199,7 @@ pub async fn start_server(run_options: RunOptions) -> anyhow::Result<()> {
193199
config: chain_config.clone(),
194200
permit2,
195201
weth,
202+
adapter_bytecode_hash,
196203
express_relay_contract: Arc::new(express_relay_contract),
197204
block_gas_limit: block.gas_limit,
198205
},

auction-server/src/state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ pub struct ChainStore {
190190
pub network_id: u64,
191191
pub config: EthereumConfig,
192192
pub permit2: Address,
193+
pub adapter_bytecode_hash: [u8; 32],
193194
pub weth: Address,
194195
pub token_spoof_info: RwLock<HashMap<Address, SpoofInfo>>,
195196
pub express_relay_contract: Arc<SignableExpressRelayContract>,

0 commit comments

Comments
 (0)