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

Implementation of Fluffy state network gossip. #2210

Merged
merged 5 commits into from
May 24, 2024

Conversation

web3-developer
Copy link
Contributor

@web3-developer web3-developer commented May 23, 2024

Summary of changes:

  • Implemented getParent helper functions to calculate the parent path and proof for recursive gossip.
  • We now handle cases where multiple nibbles should be removed when calculating the parent path for recursive gossip.
  • Fixed/re-implemented recursive gossip for account trie proof offers.
  • Implemented recursive gossip for contract trie proof offers.
  • Now always gossip the received offer after validation.
  • Some other minor refactors/cleanups.
  • Moved some helper functions to state_utils.nim
  • Implemented typed lookups for getting state network content: getAccountTrieNode, getContractTrieNode and getContractCode

Tests still in progress.

@web3-developer web3-developer requested a review from kdeme May 23, 2024 08:40
Copy link
Contributor

@kdeme kdeme left a comment

Choose a reason for hiding this comment

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

lgtm, fine with adding tests in follow-up PR also. As you see fit.

ContractTrieNodeOffer.init(parentProof, offer.accountProof, offer.blockHash)

(parentKey, parentOffer)

proc gossipOffer*(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kdeme By the way I opted to leave the name as gossipOffer because in the case of bytecode there is no recursive gossip. The more generic name makes sense to me for this reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's fine. The call is practically also doing more than just the recursive gossip as it also does the regular gossip.

) {.async.} =
asyncSpawn p.neighborhoodGossipDiscardPeers(
srcNodeId, ContentKeysList.init(@[keyBytes]), @[offerBytes]
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kdeme In this code I'm gossiping out the offer without await and then gossiping the parent offer below. Is there reason that you can think of to try and enforce the order of gossip by using an await here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure. They will both end up in the offerQueue, so that's fine.

But eventually we might have to think about the effects when the offerQueue is full.
E.g. In case of a lot of gossip started from a bridge, there can come a build-up futures that are being awaited to add to the queue. And there wouldn't be a "feedback" of this possible due to the asyncSpawn afaik.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll leave it for now and review later if and when needed once we have the state network up and running.

@web3-developer web3-developer marked this pull request as ready for review May 24, 2024 06:55
Comment on lines +90 to +94
let (parentKey, parentOffer) = getParent(key, offer)
asyncSpawn p.neighborhoodGossipDiscardPeers(
srcNodeId,
ContentKeysList.init(@[parentKey.toContentKey().encode()]),
@[parentOffer.encode()],
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a little comment in front here that indicates that this is the recursive gossip part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do

@web3-developer web3-developer merged commit 771d6fd into master May 24, 2024
12 checks passed
@web3-developer web3-developer deleted the fluffy-state-gossip branch May 24, 2024 07:49
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.

None yet

2 participants