Skip to content

Conversation

@titasstank
Copy link
Collaborator

Implemented equivalent changes that can be seen with this commit: leanEthereum/leanSpec@094cb0b

Added tests for new code
All tests pass both old and new
Tested discovery just in case, works

JuliusMieliauskas and others added 28 commits December 19, 2025 00:46
Signature Aggregation Preparation (devnet 2)
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.

so probably all gossipsub code needs to be deleted. instead, you should implement only ethereum-specific logic on top of existing gossipsub protocol, like how eth2_libp2p is implemented

/// - Gossipsub v1.2: <https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md>
use serde::{Deserialize, Serialize};

use super::types::MessageId;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why there is whole gossipsub protocol reimplemented? Why libp2p::gossipsub doesn't fit there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, removed the implementation, used the existing one.

/// 20-byte array for message IDs (gossipsub message IDs)
/// Using transparent SSZ encoding - just the raw bytes
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Bytes20(pub [u8; 20]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

so I believe there is no need to create separate type Bytes20 - that is not really idiomatic in rust, since you already have fixed-size slices. It makes sense only if you encapsulate some logic in it (e.g., some additional validation for message ids), otherwise not worth to implement this.

If you want structs with proper ssz support, feel free to use H160 from ethereum_types crate - ssz traits are already implemented for these types: https://github.com/grandinetech/grandine/blob/db5ba01d3eaad36242409834fef1bacec33af0e1/ssz/src/arrays.rs#L52

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Used H160

Comment on lines +168 to +212
fn default_protocol_id() -> String {
"/meshsub/1.3.0".to_string()
}

fn default_d() -> usize {
8
}

fn default_d_low() -> usize {
6
}

fn default_d_high() -> usize {
12
}

fn default_d_lazy() -> usize {
6
}

fn default_heartbeat_interval_secs() -> f64 {
0.7
}

fn default_fanout_ttl_secs() -> u64 {
60
}

fn default_mcache_len() -> usize {
6
}

fn default_mcache_gossip() -> usize {
3
}

fn default_seen_ttl_secs() -> u64 {
let justification_lookback_slots: u64 = 3;
let seconds_per_slot: u64 = 12;
seconds_per_slot * justification_lookback_slots * 2
}

fn default_idontwant_threshold() -> usize {
1000
}
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 define each of those as separate functions - just put them into Default trait impl

Comment on lines +304 to +325
#[test]
fn test_default_parameters() {
let params = GossipsubParameters::default();

// Test Ethereum spec values
assert_eq!(params.d, 8);
assert_eq!(params.d_low, 6);
assert_eq!(params.d_high, 12);
assert_eq!(params.d_lazy, 6);
assert_eq!(params.heartbeat_interval_secs, 0.7);
assert_eq!(params.fanout_ttl_secs, 60);
assert_eq!(params.mcache_len, 6);
assert_eq!(params.mcache_gossip, 3);
assert_eq!(params.protocol_id, "/meshsub/1.3.0");
assert_eq!(params.idontwant_message_size_threshold, 1000);

// Test relationships
assert!(params.d_low < params.d);
assert!(params.d < params.d_high);
assert!(params.d_lazy <= params.d);
assert!(params.mcache_gossip <= params.mcache_len);
}
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 for this test, it doesn't test anything

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.

8 participants