Skip to content

imp(ethereum): remove deneb support #530

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/e2e-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
id: get-matrix
uses: ./.github/actions/e2e-matrix
with:
skip-tests: TestWithRelayerTestSuite/Test_2_ConcurrentRecvPacketToEth,TestWithRelayerTestSuite/Test_MultiPeriodClientUpdateToCosmos,TestWithRelayerTestSuite/Test_Electra_Fork
skip-tests: TestWithRelayerTestSuite/Test_2_ConcurrentRecvPacketToEth,TestWithRelayerTestSuite/Test_MultiPeriodClientUpdateToCosmos

e2e:
needs: generate-matrix
Expand Down
39 changes: 0 additions & 39 deletions e2e/interchaintestv8/relayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/cosmos/solidity-ibc-eureka/packages/go-abigen/ibcerc20"
"github.com/cosmos/solidity-ibc-eureka/packages/go-abigen/ics20transfer"

"github.com/srdtrk/solidity-ibc-eureka/e2e/v8/chainconfig"
"github.com/srdtrk/solidity-ibc-eureka/e2e/v8/e2esuite"
"github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues"
"github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types"
Expand Down Expand Up @@ -844,44 +843,6 @@ func (s *IbcEurekaTestSuite) ICS20FinalizedTimeoutPacketFromEthTest(
}))
}

func (s *RelayerTestSuite) Test_Electra_Fork() {
if os.Getenv(testvalues.EnvKeyEthTestnetType) != testvalues.EthTestnetTypePoS {
s.T().Skip("Test is only relevant for PoS networks")
}

ctx := context.Background()
proofType := types.GetEnvProofType()

electraForkEpoch := 12
chainconfig.KurtosisConfig.NetworkParams.ElectraForkEpoch = uint64(electraForkEpoch)

s.SetupSuite(ctx, proofType)

s.FilteredRecvPacketToCosmosTest(ctx, 1, big.NewInt(testvalues.TransferAmount), nil)

spec, err := s.EthChain.BeaconAPIClient.GetSpec()
s.Require().NoError(err)
err = testutil.WaitForCondition(time.Minute*30, time.Second*30, func() (bool, error) {
finalityUpdate, err := s.EthChain.BeaconAPIClient.GetFinalityUpdate()
if err != nil {
return false, err
}

finalitySlot, err := strconv.Atoi(finalityUpdate.Data.FinalizedHeader.Beacon.Slot)
if err != nil {
return false, err
}

latestFinalityEpoch := uint64(finalitySlot) / spec.SlotsPerEpoch

fmt.Printf("Waiting for epoch %d, current epoch: %d\n", electraForkEpoch, latestFinalityEpoch)
return latestFinalityEpoch >= uint64(electraForkEpoch), nil
})
s.Require().NoError(err)

s.FilteredRecvPacketToCosmosTest(ctx, 1, big.NewInt(testvalues.TransferAmount), nil)
}

func (s *RelayerTestSuite) Test_10_RecvPacketToCosmos() {
ctx := context.Background()
proofType := types.GetEnvProofType()
Expand Down
Binary file modified e2e/interchaintestv8/wasm/cw_ics08_wasm_eth.wasm.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/ethereum/light-client/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl ClientState {
/// # Errors
/// Returns an error if the slot is not supported.
pub const fn verify_supported_fork_at_epoch(&self, epoch: u64) -> Result<(), EthereumIBCError> {
if epoch < self.fork_parameters.deneb.epoch {
return Err(EthereumIBCError::MustBeDenebOrLater);
if epoch < self.fork_parameters.electra.epoch {
return Err(EthereumIBCError::MustBeElectraOrLater);
}

Ok(())
Expand Down
7 changes: 2 additions & 5 deletions packages/ethereum/light-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub enum EthereumIBCError {
#[error("insufficient number of sync committee addresses ({found}) but expected ({expected})")]
InsufficientSyncCommitteeLength { expected: u64, found: u64 },

#[error("unsupported fork version, must be deneb or later")]
MustBeDenebOrLater,
#[error("unsupported fork version, must be electra or later")]
MustBeElectraOrLater,

#[error(
"execution payload header must have blob_gas_used and excess_blog_gas set after deneb"
Expand All @@ -50,9 +50,6 @@ pub enum EthereumIBCError {
normalized_branch: Vec<B256>,
},

#[error("invalid light client update branch depths for slot {0} (next sync committee branch depth: {1}), finality branch depth: {2}")]
InvalidBranchDepths(u64, usize, usize),

#[error("finalized slot cannot be the genesis slot")]
FinalizedSlotIsGenesis,

Expand Down
31 changes: 6 additions & 25 deletions packages/ethereum/light-client/src/sync_protocol_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use alloy_primitives::B256;
use ethereum_types::consensus::{
light_client_header::LightClientHeader,
merkle::{
floorlog2, CURRENT_SYNC_COMMITTEE_GINDEX, CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA,
EXECUTION_PAYLOAD_GINDEX, FINALIZED_ROOT_GINDEX, FINALIZED_ROOT_GINDEX_ELECTRA,
NEXT_SYNC_COMMITTEE_GINDEX, NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA,
floorlog2, CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA, EXECUTION_PAYLOAD_GINDEX,
FINALIZED_ROOT_GINDEX_ELECTRA, NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA,
},
};
use tree_hash::TreeHash;
Expand All @@ -22,14 +21,9 @@ pub fn finalized_root_gindex_at_slot(
slot: u64,
) -> Result<u64, EthereumIBCError> {
let epoch = client_state.compute_epoch_at_slot(slot);

client_state.verify_supported_fork_at_epoch(epoch)?;

if epoch >= client_state.fork_parameters.electra.epoch {
return Ok(FINALIZED_ROOT_GINDEX_ELECTRA);
}

Ok(FINALIZED_ROOT_GINDEX)
Ok(FINALIZED_ROOT_GINDEX_ELECTRA)
}

// See spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/light-client/sync-protocol.md#modified-current_sync_committee_gindex_at_slot
Expand All @@ -41,14 +35,9 @@ pub fn current_sync_committee_gindex_at_slot(
slot: u64,
) -> Result<u64, EthereumIBCError> {
let epoch = client_state.compute_epoch_at_slot(slot);

client_state.verify_supported_fork_at_epoch(epoch)?;

if epoch >= client_state.fork_parameters.electra.epoch {
return Ok(CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA);
}

Ok(CURRENT_SYNC_COMMITTEE_GINDEX)
Ok(CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA)
}

// See spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/light-client/sync-protocol.md#modified-next_sync_committee_gindex_at_slot
Expand All @@ -60,30 +49,22 @@ pub fn next_sync_committee_gindex_at_slot(
slot: u64,
) -> Result<u64, EthereumIBCError> {
let epoch = client_state.compute_epoch_at_slot(slot);

client_state.verify_supported_fork_at_epoch(epoch)?;

if epoch >= client_state.fork_parameters.electra.epoch {
return Ok(NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA);
}

Ok(NEXT_SYNC_COMMITTEE_GINDEX)
Ok(NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA)
}

// See spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/light-client/sync-protocol.md#modified-get_lc_execution_root
/// Returns the execution root of the light client header.
/// # Errors
/// Returns an error if the epoch is less than the Deneb epoch.
/// Returns an error if the epoch is in a non-supported fork.
pub fn get_lc_execution_root(
client_state: &ClientState,
header: &LightClientHeader,
) -> Result<B256, EthereumIBCError> {
let epoch = client_state.compute_epoch_at_slot(header.beacon.slot);

client_state.verify_supported_fork_at_epoch(epoch)?;

// Deneb and electra have the same execution payload header structure, so no need to check or
// convert the execution payload header.
Ok(header.execution.tree_hash_root())
}

Expand Down

This file was deleted.

24 changes: 1 addition & 23 deletions packages/ethereum/light-client/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use ethereum_types::consensus::{
bls::{BlsPublicKey, BlsSignature},
domain::{compute_domain, DomainType},
light_client_header::LightClientUpdate,
merkle::floorlog2,
signing_data::compute_signing_root,
};
use tree_hash::TreeHash;
Expand Down Expand Up @@ -156,27 +155,6 @@ pub fn validate_light_client_update<V: BlsVerify>(
current_slot: u64,
bls_verifier: &V,
) -> Result<(), EthereumIBCError> {
// TODO: Remove this check after type safety is added back (#440)
let expected_next_sync_committee_branch_depth = floorlog2(next_sync_committee_gindex_at_slot(
client_state,
update.attested_header.beacon.slot,
)?);
let expected_finality_branch_depth = floorlog2(finalized_root_gindex_at_slot(
client_state,
update.attested_header.beacon.slot,
)?);
ensure!(
update.is_valid_branch_depths(
expected_next_sync_committee_branch_depth,
expected_finality_branch_depth,
),
EthereumIBCError::InvalidBranchDepths(
update.attested_header.beacon.slot,
expected_next_sync_committee_branch_depth,
expected_finality_branch_depth
)
);

// Verify sync committee has sufficient participants
ensure!(
update
Expand Down Expand Up @@ -321,7 +299,7 @@ pub fn validate_light_client_update<V: BlsVerify>(
.unwrap()
.tree_hash_root(),
&normalize_merkle_branch(
&update.next_sync_committee_branch.clone().unwrap(),
update.next_sync_committee_branch.as_ref().unwrap(),
next_sync_committee_gindex,
),
next_sync_committee_gindex,
Expand Down
9 changes: 6 additions & 3 deletions packages/ethereum/types/src/consensus/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ use alloy_primitives::B256;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use super::{light_client_header::LightClientHeader, sync_committee::SyncCommittee};
use super::{
light_client_header::LightClientHeader,
merkle::{floorlog2, CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA},
sync_committee::SyncCommittee,
};

/// The light client bootstrap
#[serde_as]
Expand All @@ -16,6 +20,5 @@ pub struct LightClientBootstrap {
/// The current sync committee
pub current_sync_committee: SyncCommittee,
/// The branch of the current sync committee
// TODO: Add back type safety after Deneb support is removed (#440)
pub current_sync_committee_branch: Vec<B256>,
pub current_sync_committee_branch: [B256; floorlog2(CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA)],
}
33 changes: 7 additions & 26 deletions packages/ethereum/types/src/consensus/light_client_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use serde_with::{serde_as, DisplayFromStr};
use tree_hash_derive::TreeHash;

use super::{
merkle::{floorlog2, EXECUTION_PAYLOAD_GINDEX},
merkle::{
floorlog2, EXECUTION_PAYLOAD_GINDEX, FINALIZED_ROOT_GINDEX_ELECTRA,
NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA,
},
sync_committee::{SyncAggregate, SyncCommittee},
};

Expand All @@ -21,15 +24,13 @@ pub struct LightClientUpdate {
/// Next sync committee corresponding to `attested_header.state_root`
pub next_sync_committee: Option<SyncCommittee>,
/// The branch of the next sync committee
// TODO: Add back type safety after Deneb support is removed (#440)
#[schemars(with = "Vec<String>")]
pub next_sync_committee_branch: Option<Vec<B256>>,
pub next_sync_committee_branch: Option<[B256; floorlog2(NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA)]>,
/// Finalized header corresponding to `attested_header.state_root`
pub finalized_header: LightClientHeader,
/// Branch of the finalized header
// TODO: Add back type safety after Deneb support is removed (#440)
#[schemars(with = "Vec<String>")]
pub finality_branch: Vec<B256>,
pub finality_branch: [B256; floorlog2(FINALIZED_ROOT_GINDEX_ELECTRA)],
/// Sync committee aggregate signature
pub sync_aggregate: SyncAggregate,
/// Slot at which the aggregate signature was created (untrusted)
Expand All @@ -38,25 +39,6 @@ pub struct LightClientUpdate {
pub signature_slot: u64,
}

impl LightClientUpdate {
/// Validates that the branch depths are correct
// TODO: Remove this function after type safety is added back (#440)
// TODO: Use is_none_or after cosmwasm supports rust 1.85 (https://github.com/CosmWasm/cosmwasm/issues/2292)
#[allow(clippy::unnecessary_map_or)]
pub fn is_valid_branch_depths(
&self,
expected_next_sync_committee_branch_depth: usize,
expected_finality_branch_depth: usize,
) -> bool {
self.next_sync_committee_branch
.as_ref()
.map_or(true, |branch| {
branch.len() == expected_next_sync_committee_branch_depth
})
&& self.finality_branch.len() == expected_finality_branch_depth
}
}

/// A light client finality update
#[serde_as]
#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug, Default)]
Expand All @@ -67,9 +49,8 @@ pub struct LightClientFinalityUpdate {
/// Finalized header corresponding to `attested_header.state_root`
pub finalized_header: LightClientHeader,
/// Branch of the finalized header
// TODO: Add back type safety after Deneb support is removed (#440)
#[schemars(with = "Vec<String>")]
pub finality_branch: Vec<B256>,
pub finality_branch: [B256; floorlog2(FINALIZED_ROOT_GINDEX_ELECTRA)],
/// Sync committee aggregate signature
pub sync_aggregate: SyncAggregate,
/// Slot at which the aggregate signature was created (untrusted)
Expand Down
9 changes: 0 additions & 9 deletions packages/ethereum/types/src/consensus/merkle.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
//! This module defines constants related to merkle trees in the Ethereum consensus.

// https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/light-client/sync-protocol.md#constants
// Existing GeneralizedIndex constants are frozen at their Altair values.
/// `get_generalized_index(altair.BeaconState, 'finalized_checkpoint', 'root')` (= 105)
pub const FINALIZED_ROOT_GINDEX: u64 = 105;
/// `get_generalized_index(altair.BeaconState, 'current_sync_committee')` (= 54)
pub const CURRENT_SYNC_COMMITTEE_GINDEX: u64 = 54;
/// `get_generalized_index(altair.BeaconState, 'next_sync_committee')` (= 55)
pub const NEXT_SYNC_COMMITTEE_GINDEX: u64 = 55;

// New constants
/// `get_generalized_index(BeaconState, 'finalized_checkpoint', 'root')` (= 169)
pub const FINALIZED_ROOT_GINDEX_ELECTRA: u64 = 169;
Expand Down
Loading
Loading