Skip to content
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

feat: Add gossip and eviction to the mempool #200

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

FrederikBolding
Copy link
Contributor

This PR adds a basic implementation of the gossipped mempool described in #180.

Opening in draft as I am looking for feedback on the direction before proceeding.

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/mempool/mempool.rs Outdated Show resolved Hide resolved
src/storage/store/engine.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/node/snapchain_node.rs Outdated Show resolved Hide resolved
src/proto/blocks.proto Outdated Show resolved Hide resolved
@FrederikBolding FrederikBolding changed the title feat: Implement basic gossipped mempool feat: Add gossip and eviction to the mempool Jan 10, 2025
Copy link
Contributor

@sanjayprabhu sanjayprabhu left a comment

Choose a reason for hiding this comment

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

Nice, generally looks good. Please add some tests for:

  • Messages being evicted from the mempool on confirmation
  • Messages submitted to one node is gossiped to another node.


pub fn mempool_key(&self) -> MempoolKey {
if let Some(data) = &self.data {
return MempoolKey::new(data.timestamp as u64, self.hex_hash());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function should live inside the mempool. I would add a trait in the mempool for this, and implement the trait for the structs in there. Rest of the code doesn't have to care about this.

@@ -287,6 +313,15 @@ impl SnapchainGossip {
let encoded_message = gossip_message.encode_to_vec();
self.publish(encoded_message);
},
Some(GossipEvent::BroadcastMempoolMessage(message)) => {
debug!("Broadcasting mempool message");
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove the debug logs

@@ -149,6 +170,43 @@ impl Mempool {
return true;
}

async fn insert(&mut self, message: MempoolMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's emit some stats here, number of inserts tagged by success/failure and message type, and a guage for the current size of the mempool by shard.

Some(messages) => {
messages.insert(MempoolKey { inserted_at: Instant::now()}, message.clone());
for system_message in transaction.system_messages {
mempool.remove(&system_message.mempool_key());
Copy link
Contributor

Choose a reason for hiding this comment

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

We should record the same stats as above when removing from the mempool as well

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.

2 participants