From fa0dadc9bd081e6cef66d4e77612f2d52a5a9363 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 27 Jan 2025 15:39:06 -0500 Subject: [PATCH] Rename Deployer bytecode to initcode --- processor/ethereum/deployer/src/lib.rs | 16 ++++++++-------- processor/ethereum/deployer/src/tests.rs | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/processor/ethereum/deployer/src/lib.rs b/processor/ethereum/deployer/src/lib.rs index 64ca0d2b..10140303 100644 --- a/processor/ethereum/deployer/src/lib.rs +++ b/processor/ethereum/deployer/src/lib.rs @@ -27,15 +27,15 @@ mod abi { alloy_sol_macro::sol!("contracts/Deployer.sol"); } -const BYTECODE: &[u8] = { - const BYTECODE_HEX: &[u8] = +const INITCODE: &[u8] = { + const INITCODE_HEX: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/serai-processor-ethereum-deployer/Deployer.bin")); - const BYTECODE: [u8; BYTECODE_HEX.len() / 2] = - match hex::const_decode_to_array::<{ BYTECODE_HEX.len() / 2 }>(BYTECODE_HEX) { - Ok(bytecode) => bytecode, + const INITCODE: [u8; INITCODE_HEX.len() / 2] = + match hex::const_decode_to_array::<{ INITCODE_HEX.len() / 2 }>(INITCODE_HEX) { + Ok(initcode) => initcode, Err(_) => panic!("Deployer.bin did not contain valid hex"), }; - &BYTECODE + &INITCODE }; /// The Deployer contract for the Serai Router contract. @@ -52,7 +52,7 @@ impl Deployer { /// funded for this transaction to be submitted. This account has no known private key to anyone /// so ETH sent can be neither misappropriated nor returned. pub fn deployment_tx() -> Signed { - let bytecode = Bytes::from_static(BYTECODE); + let initcode = Bytes::from_static(INITCODE); // Legacy transactions are used to ensure the widest possible degree of support across EVMs let tx = TxLegacy { @@ -87,7 +87,7 @@ impl Deployer { gas_limit: 300_698, to: TxKind::Create, value: U256::ZERO, - input: bytecode, + input: initcode, }; ethereum_primitives::deterministically_sign(tx) diff --git a/processor/ethereum/deployer/src/tests.rs b/processor/ethereum/deployer/src/tests.rs index ba1e75ae..6e4570ff 100644 --- a/processor/ethereum/deployer/src/tests.rs +++ b/processor/ethereum/deployer/src/tests.rs @@ -40,7 +40,7 @@ async fn test_deployer() { } // Deploy the deployer with the deployer - let mut deploy_tx = Deployer::deploy_tx(crate::BYTECODE.to_vec()); + let mut deploy_tx = Deployer::deploy_tx(crate::INITCODE.to_vec()); deploy_tx.gas_price = 100_000_000_000u128; deploy_tx.gas_limit = 1_000_000; { @@ -53,7 +53,7 @@ async fn test_deployer() { { let deployer = Deployer::new(provider.clone()).await.unwrap().unwrap(); let deployed_deployer = deployer - .find_deployment(ethereum_primitives::keccak256(crate::BYTECODE)) + .find_deployment(ethereum_primitives::keccak256(crate::INITCODE)) .await .unwrap() .unwrap();