Skip to content

Commit

Permalink
refactor: remove common as dep of consensus-core (#367)
Browse files Browse the repository at this point in the history
* refactor: remove common as dep of consensus-core

* fix imports
  • Loading branch information
ncitron authored Sep 10, 2024
1 parent 8f9cb69 commit 537697a
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 178 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions common/src/config/types.rs

This file was deleted.

4 changes: 0 additions & 4 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
pub mod errors;
pub mod types;

pub mod config {
pub mod types;
}
2 changes: 1 addition & 1 deletion config/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use alloy::primitives::B256;
use serde::Serialize;

use crate::types::ChainConfig;
use common::config::types::Forks;
use consensus_core::types::Forks;

/// The base configuration for a network.
#[derive(Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use figment::{
};
use serde::Deserialize;

use common::config::types::Forks;
use consensus_core::types::Forks;

use crate::base::BaseConfig;
use crate::cli::CliConfig;
Expand Down
2 changes: 1 addition & 1 deletion config/src/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use eyre::Result;
use serde::{Deserialize, Serialize};
use strum::EnumIter;

use common::config::types::{Fork, Forks};
use consensus_core::types::{Fork, Forks};

use crate::base::BaseConfig;
use crate::types::ChainConfig;
Expand Down
2 changes: 0 additions & 2 deletions consensus-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ superstruct.workspace = true
thiserror.workspace = true
tracing.workspace = true
zduny-wasm-timer.workspace = true

common = { path = "../common" }
5 changes: 2 additions & 3 deletions consensus-core/src/consensus_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ use tracing::{info, warn};
use tree_hash::TreeHash;
use zduny_wasm_timer::{SystemTime, UNIX_EPOCH};

use common::config::types::Forks;

use crate::errors::ConsensusError;
use crate::proof::{
is_current_committee_proof_valid, is_finality_proof_valid, is_next_committee_proof_valid,
};
use crate::types::bls::{PublicKey, Signature};
use crate::types::{
Bootstrap, FinalityUpdate, GenericUpdate, Header, LightClientStore, OptimisticUpdate, Update,
Bootstrap, FinalityUpdate, Forks, GenericUpdate, Header, LightClientStore, OptimisticUpdate,
Update,
};
use crate::utils::{
calculate_fork_version, compute_committee_sign_root, compute_fork_data_root,
Expand Down
18 changes: 16 additions & 2 deletions consensus-core/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy::primitives::{Address, B256, U256};
use alloy::primitives::{Address, FixedBytes, B256, U256};
use eyre::Result;
use serde::{Deserialize, Serialize};
use ssz_derive::Encode;
Expand All @@ -14,7 +14,6 @@ use self::{
pub mod bls;
pub mod bytes;
mod serde_utils;
mod utils;

pub type LogsBloom = ByteVector<typenum::U256>;
pub type KZGCommitment = ByteVector<typenum::U48>;
Expand Down Expand Up @@ -312,6 +311,21 @@ pub struct SyncAggregate {
pub sync_committee_signature: Signature,
}

#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct Forks {
pub genesis: Fork,
pub altair: Fork,
pub bellatrix: Fork,
pub capella: Fork,
pub deneb: Fork,
}

#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct Fork {
pub epoch: u64,
pub fork_version: FixedBytes<4>,
}

pub struct GenericUpdate {
pub attested_header: Header,
pub sync_aggregate: SyncAggregate,
Expand Down
139 changes: 0 additions & 139 deletions consensus-core/src/types/utils.rs

This file was deleted.

3 changes: 1 addition & 2 deletions consensus-core/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use alloy::primitives::B256;
use common::config::types::Forks;
use eyre::Result;
use ssz_types::{BitVector, FixedVector};
use tree_hash::TreeHash;
use tree_hash_derive::TreeHash;

use crate::types::{bls::PublicKey, SyncCommittee};
use crate::types::{bls::PublicKey, Forks, SyncCommittee};

pub fn compute_committee_sign_root(header: B256, fork_data_root: B256) -> B256 {
let domain_type = [7, 00, 00, 00];
Expand Down
Loading

0 comments on commit 537697a

Please sign in to comment.