Skip to content

Conversation

@LiudasBaronas1
Copy link
Collaborator

@LiudasBaronas1 LiudasBaronas1 commented Jan 13, 2026

Overview

This PR completes the refactoring of the configuration system, addressing both #25 and #26. It removes redundancy by eliminating global constants and merging configuration structures into a single source of truth.

Changes

  • Unified Config: Merged GenesisConfig and Config into a single Config struct.
  • Removed Global Constants: Deleted SECONDS_PER_SLOT, INTERVALS_PER_SLOT, and SECONDS_PER_INTERVAL. Components now fetch these values from store.config.
  • Improved Encapsulation: Refactored chain/src/lib.rs to export ChainConfig directly via pub use.
  • Backward Compatibility: Applied camelCase renaming and default values to Config to maintain compatibility with existing JSON test vectors.
  • Test Updates: Updated unit tests and test vectors to initialize the new structure.

Related Issues

Merged GenesisConfig into Config, removed redundant constants and wrapper structs. Closes #25, Closes #26
Copy link
Collaborator

@ArtiomTr ArtiomTr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, although few things need to be fixed


// Type-level number for 3112 bytes
pub type U3112 = Sum<U3100, U12>;
pub type U3112 = Sum<Prod<U31, U100>, U12>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to keep / export this type

Comment on lines +16 to +18
pub fn verify(&self) -> bool {
true
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably should be replaced with actual implementation

Comment on lines 26 to 31
type Error = String;
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
ByteVector::<U3112>::try_from(bytes)
.map(Signature)
.map_err(|e| format!("{:?}", e))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why changing error type to string? you can just use the error type that ByteVector's try from provides for you

pub genesis_time: u64,
}

#[serde(default = "default_seconds_per_slot")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is no need to define function here, as you can just use constant. Also, because this is declared in one place, you can just directly hardcode value here, without additional functions/constants

use std::path::Path;

#[derive(Clone, Debug, PartialEq, Eq, Ssz, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, Ssz)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is config should really be ssz-serializable?

pub genesis_validators: Vec<String>,
#[ssz(skip)]
#[serde(default)]
pub genesis_validators: Vec<serde_json::Value>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be more concrete type, not array of any values

Comment on lines 3 to 4
pub type Bytes32 = H256;
pub type Uint64 = u64;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these aren't necessary anymore I think

_ => return curr,
};

// Choose best child: most attestations, then lexicographically highest hash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why so many comments removed? I wouldn't say those were unnecessary. Better to have some explanation

pub fn new() -> Self {
let justification_lookback_slots: u64 = 3;
let seconds_per_slot: u64 = 12;
let seconds_per_slot: u64 = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be taken from config?

source_slot = store.latest_justified.slot.0,
"Created attestation with zero signature"
);
Signature::default()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think this is correct. but anyway - removing this info! is not correct, as it was signalling that something gone wrong. I would change this info! to warn! at least, but not remove it

@ArtiomTr
Copy link
Collaborator

looks like this needs some rebasing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants