Skip to content

Commit

Permalink
remove minimal spec
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Jan 18, 2024
1 parent ee66175 commit 13b618b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 42 deletions.
37 changes: 2 additions & 35 deletions parachain/pallets/ethereum-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,8 @@ pub mod pallet {
/// Submits a new finalized beacon header update. The update may contain the next
/// sync committee.
pub fn submit(origin: OriginFor<T>, update: Box<Update>) -> DispatchResult {
log::info!(target: LOG_TARGET,"💫 submitted finalized header.");
ensure_signed(origin)?;
log::info!(target: LOG_TARGET,"💫 is signed.");
ensure!(!Self::operating_mode().is_halted(), Error::<T>::Halted);
log::info!(target: LOG_TARGET,"💫 bridge not halted.");
Self::process_update(&update)?;
Ok(())
}
Expand Down Expand Up @@ -334,11 +331,8 @@ pub mod pallet {

pub(crate) fn process_update(update: &Update) -> DispatchResult {
Self::cross_check_execution_state()?;
log::info!(target: LOG_TARGET,"💫 cross checked execution state.");
Self::verify_update(update)?;
log::info!(target: LOG_TARGET,"💫 verified update.");
Self::apply_update(update)?;
log::info!(target: LOG_TARGET,"💫 applied update.");
Ok(())
}

Expand Down Expand Up @@ -372,17 +366,12 @@ pub mod pallet {
decompress_sync_committee_bits(update.sync_aggregate.sync_committee_bits);
Self::sync_committee_participation_is_supermajority(&participation)?;

log::info!(target: LOG_TARGET,"💫 sync committee is a supermajority.");

// Verify update does not skip a sync committee period.
ensure!(
update.signature_slot > update.attested_header.slot &&
update.attested_header.slot >= update.finalized_header.slot,
Error::<T>::InvalidUpdateSlot
);

log::info!(target: LOG_TARGET,"💫 update does not skip a sync committee period.");

// Retrieve latest finalized state.
let latest_finalized_state =
FinalizedBeaconState::<T>::get(LatestFinalizedBlockRoot::<T>::get())
Expand All @@ -398,8 +387,6 @@ pub mod pallet {
ensure!(signature_period == store_period, Error::<T>::SkippedSyncCommitteePeriod)
}

log::info!(target: LOG_TARGET,"💫 next sync committee checks.");

// Verify update is relevant.
let update_attested_period = compute_period(update.attested_header.slot);
let update_has_next_sync_committee = !<NextSyncCommittee<T>>::exists() &&
Expand All @@ -411,8 +398,6 @@ pub mod pallet {
Error::<T>::IrrelevantUpdate
);

log::info!(target: LOG_TARGET,"💫 update is relevant.");

// Verify that the `finality_branch`, if present, confirms `finalized_header` to match
// the finalized checkpoint root saved in the state of `attested_header`.
let finalized_block_root: H256 = update
Expand All @@ -430,8 +415,6 @@ pub mod pallet {
Error::<T>::InvalidHeaderMerkleProof
);

log::info!(target: LOG_TARGET,"💫 finalized block header merkle proof passed.");

// Though following check does not belong to ALC spec we verify block_roots_root to
// match the finalized checkpoint root saved in the state of `finalized_header` so to
// cache it for later use in `verify_ancestry_proof`.
Expand All @@ -446,12 +429,9 @@ pub mod pallet {
Error::<T>::InvalidBlockRootsRootMerkleProof
);

log::info!(target: LOG_TARGET,"💫 ancestry proof passed.");

// Verify that the `next_sync_committee`, if present, actually is the next sync
// committee saved in the state of the `attested_header`.
if let Some(next_sync_committee_update) = &update.next_sync_committee_update {
log::info!(target: LOG_TARGET,"💫 sync committee is present.");
let sync_committee_root = next_sync_committee_update
.next_sync_committee
.hash_tree_root()
Expand All @@ -463,7 +443,6 @@ pub mod pallet {
Error::<T>::InvalidSyncCommitteeUpdate
);
}
log::info!(target: LOG_TARGET,"💫 checked sync committee periods.");
ensure!(
verify_merkle_branch(
sync_committee_root,
Expand All @@ -474,7 +453,6 @@ pub mod pallet {
),
Error::<T>::InvalidSyncCommitteeMerkleProof
);
log::info!(target: LOG_TARGET,"💫 sync committee merkle proof passed.");
}

// Verify sync committee aggregate signature.
Expand All @@ -483,15 +461,13 @@ pub mod pallet {
} else {
<NextSyncCommittee<T>>::get()
};
log::info!(target: LOG_TARGET,"💫 verifying signature.");
let absent_pubkeys =
Self::find_pubkeys(&participation, (*sync_committee.pubkeys).as_ref(), false);
let signing_root = Self::signing_root(
&update.attested_header,
Self::validators_root(),
update.signature_slot,
)?;
log::info!(target: LOG_TARGET,"💫 fast_aggregate_verify.");
// Improvement here per <https://eth2book.info/capella/part2/building_blocks/signatures/#sync-aggregates>
// suggested start from the full set aggregate_pubkey then subtracting the absolute
// minority that did not participate.
Expand All @@ -501,17 +477,8 @@ pub mod pallet {
signing_root,
&update.sync_aggregate.sync_committee_signature,
)
.map_err(|e| {
match e {
BlsError::InvalidSignature => log::error!(target: LOG_TARGET,"💫 InvalidSignature"),
BlsError::InvalidPublicKey=> log::error!(target: LOG_TARGET,"💫 InvalidPublicKey"),
BlsError::InvalidAggregatePublicKeys=> log::error!(target: LOG_TARGET,"💫 InvalidAggregatePublicKeys"),
BlsError::SignatureVerificationFailed=> log::error!(target: LOG_TARGET,"💫 SignatureVerificationFailed"),
}
log::error!(target: LOG_TARGET,"💫 BLSVerificationFailed: {:?}.", e);
Error::<T>::BLSVerificationFailed(e)
})?;
log::info!(target: LOG_TARGET,"💫 verified signature.");
.map_err(|e| Error::<T>::BLSVerificationFailed(e))?;

Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion web/packages/test/scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build_binaries() {
pushd $root_dir/polkadot-sdk

local features=''
if [[ "$active_spec" == "minimal" ]]; then
if [ "$eth_network" == "localhost" ]; then
features="--features fast-runtime"
fi

Expand Down
18 changes: 12 additions & 6 deletions web/packages/test/scripts/deploy-ethereum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ start_lodestar() {
fi
}

hack_beacon_client() {
set_slot_time() {
local old_value=$1
local new_value=$2
echo "Hack lodestar for faster slot time"
local preset_minimal_config_file="$web_dir/node_modules/.pnpm/@lodestar+config@$lodestar_version/node_modules/@lodestar/config/lib/chainConfig/presets/minimal.js"
local preset_mainnet_config_file="$web_dir/node_modules/.pnpm/@lodestar+config@$lodestar_version/node_modules/@lodestar/config/lib/chainConfig/presets/mainnet.js"
if [[ "$(uname)" == "Darwin" && -z "${IN_NIX_SHELL:-}" ]]; then
gsed -i "s/SECONDS_PER_SLOT: 6/SECONDS_PER_SLOT: 2/g" $preset_minimal_config_file
gsed -i "s/SECONDS_PER_SLOT: $old_value/SECONDS_PER_SLOT: $new_value/g" $preset_mainnet_config_file
else
sed -i "s/SECONDS_PER_SLOT: 6/SECONDS_PER_SLOT: 2/g" $preset_minimal_config_file
sed -i "s/SECONDS_PER_SLOT: $old_value/SECONDS_PER_SLOT: $new_value/g" $preset_mainnet_config_file
fi
}

Expand All @@ -89,8 +91,12 @@ deploy_local() {
echo "Waiting for geth API to be ready"
sleep 3

if [ "$eth_fast_mode" == "true" ]; then
hack_beacon_client
# if were are running locally speed up the seconds per slot from 12 seconds to 2 seconds. if we are not
# running locally, revert
if [ "$eth_network" == "localhost" ]; then
set_slot_time 12 2
else
set_slot_time 2 12
fi

# 2. deploy consensus client
Expand Down

0 comments on commit 13b618b

Please sign in to comment.