Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support base payload, testnet and mainnet feature flags #29

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion parachain/modules/consensus/sync-committee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ std = [
"pallet-ismp/std",
]

testnet = []
goerli = ["sync-committee-verifier/testnet", "sync-committee-primitives/testnet"]
mainnet = ["sync-committee-verifier/mainnet", "sync-committee-primitives/mainnet"]
40 changes: 21 additions & 19 deletions parachain/modules/consensus/sync-committee/src/beacon_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<H: IsmpHost + Send + Sync + Default + 'static> ConsensusClient
trusted_consensus_state: Vec<u8>,
consensus_proof: Vec<u8>,
) -> Result<(Vec<u8>, VerifiedCommitments), Error> {
let BeaconClientUpdate { optimism_payload, consensus_update, arbitrum_payload } =
let BeaconClientUpdate { mut op_stack_payload, consensus_update, arbitrum_payload } =
BeaconClientUpdate::decode(&mut &consensus_proof[..]).map_err(|_| {
Error::ImplementationSpecific("Cannot decode beacon client update".to_string())
})?;
Expand Down Expand Up @@ -81,27 +81,29 @@ impl<H: IsmpHost + Send + Sync + Default + 'static> ConsensusClient

state_machine_map
.insert(StateMachine::Ethereum(Ethereum::ExecutionLayer), state_commitment_vec);
if let Some(optimism_payload) = optimism_payload {
let state = verify_optimism_payload::<H>(
optimism_payload,
&state_root[..],
*consensus_state
.l2_oracle_address
.get(&StateMachine::Ethereum(Ethereum::Optimism))
.ok_or_else(|| {
Error::ImplementationSpecific(
"Optimism l2 oracle address was not set".into(),
)

let op_stack =
[StateMachine::Ethereum(Ethereum::Base), StateMachine::Ethereum(Ethereum::Optimism)];

for state_machine_id in op_stack {
if let Some(payload) = op_stack_payload.remove(&state_machine_id) {
let state = verify_optimism_payload::<H>(
payload,
&state_root[..],
*consensus_state.l2_oracle_address.get(&state_machine_id).ok_or_else(|| {
Error::ImplementationSpecific("l2 oracle address was not set".into())
})?,
)?;
)?;

let optimism_state_commitment_height =
StateCommitmentHeight { commitment: state.commitment, height: state.height.height };
let state_commitment_height = StateCommitmentHeight {
commitment: state.commitment,
height: state.height.height,
};

let mut state_commitment_vec: Vec<StateCommitmentHeight> = Vec::new();
state_commitment_vec.push(optimism_state_commitment_height);
state_machine_map
.insert(StateMachine::Ethereum(Ethereum::Optimism), state_commitment_vec);
let mut state_commitment_vec: Vec<StateCommitmentHeight> = Vec::new();
state_commitment_vec.push(state_commitment_height);
state_machine_map.insert(state_machine_id, state_commitment_vec);
}
}

if let Some(arbitrum_payload) = arbitrum_payload {
Expand Down
2 changes: 1 addition & 1 deletion parachain/modules/consensus/sync-committee/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct ConsensusState {
#[derive(Encode, Decode)]
pub struct BeaconClientUpdate {
pub consensus_update: LightClientUpdate,
pub optimism_payload: Option<OptimismPayloadProof>,
pub op_stack_payload: BTreeMap<StateMachine, OptimismPayloadProof>,
pub arbitrum_payload: Option<ArbitrumPayloadProof>,
}

Expand Down
2 changes: 2 additions & 0 deletions parachain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ try-runtime = [
"try-runtime-cli/try-runtime",
"hyperbridge-runtime/try-runtime"
]
goerli = ["hyperbridge-runtime/goerli"]
mainnet = ["hyperbridge-runtime/mainnet"]
3 changes: 3 additions & 0 deletions parachain/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,6 @@ try-runtime = [
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
]

goerli = ["ismp-sync-committee/goerli"]
mainnet = ["ismp-sync-committee/mainnet"]
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM paritytech/ci-linux:production

COPY ./ ./

RUN RUSTFLAGS="-C link-args=-Wl,--allow-multiple-definition" cargo build --release -p hyperbridge
RUN RUSTFLAGS="-C link-args=-Wl,--allow-multiple-definition" cargo build --release -p hyperbridge --features goerli

ENTRYPOINT ["./target/release/hyperbridge"]
Loading