Skip to content

Commit 41ba135

Browse files
Move deposit contract artifacts to /target (#8518)
Alternative to: - #8488 Refactors deposit_contract crate to comply with Rust build conventions by placing generated artifacts in the build output directory. Co-Authored-By: Michael Sproul <[email protected]>
1 parent 0bccc70 commit 41ba135

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

common/deposit_contract/build.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,13 @@ fn verify_checksum(bytes: &[u8], expected_checksum: &str) {
153153

154154
/// Returns the directory that will be used to store the deposit contract ABI.
155155
fn abi_dir() -> PathBuf {
156-
let base = env::var("CARGO_MANIFEST_DIR")
157-
.expect("should know manifest dir")
156+
let base = env::var("OUT_DIR")
157+
.expect("should know out dir")
158158
.parse::<PathBuf>()
159-
.expect("should parse manifest dir as path")
160-
.join("contracts");
159+
.expect("should parse out dir as path");
161160

162161
std::fs::create_dir_all(base.clone())
163-
.expect("should be able to create abi directory in manifest");
162+
.expect("should be able to create abi directory in out dir");
164163

165164
base
166165
}

common/deposit_contract/src/lib.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,25 @@ impl From<SszDecodeError> for Error {
4444

4545
pub const CONTRACT_DEPLOY_GAS: usize = 4_000_000;
4646
pub const DEPOSIT_GAS: usize = 400_000;
47-
pub const ABI: &[u8] = include_bytes!("../contracts/v0.12.1_validator_registration.json");
48-
pub const BYTECODE: &[u8] = include_bytes!("../contracts/v0.12.1_validator_registration.bytecode");
47+
pub const ABI: &[u8] = include_bytes!(concat!(
48+
env!("OUT_DIR"),
49+
"/v0.12.1_validator_registration.json"
50+
));
51+
pub const BYTECODE: &[u8] = include_bytes!(concat!(
52+
env!("OUT_DIR"),
53+
"/v0.12.1_validator_registration.bytecode"
54+
));
4955
pub const DEPOSIT_DATA_LEN: usize = 420; // lol
5056

5157
pub mod testnet {
52-
pub const ABI: &[u8] =
53-
include_bytes!("../contracts/v0.12.1_testnet_validator_registration.json");
54-
pub const BYTECODE: &[u8] =
55-
include_bytes!("../contracts/v0.12.1_testnet_validator_registration.bytecode");
58+
pub const ABI: &[u8] = include_bytes!(concat!(
59+
env!("OUT_DIR"),
60+
"/v0.12.1_testnet_validator_registration.json"
61+
));
62+
pub const BYTECODE: &[u8] = include_bytes!(concat!(
63+
env!("OUT_DIR"),
64+
"/v0.12.1_testnet_validator_registration.bytecode"
65+
));
5666
}
5767

5868
pub fn encode_eth1_tx_data(deposit_data: &DepositData) -> Result<Vec<u8>, Error> {

0 commit comments

Comments
 (0)