Skip to content

Conversation

shane-moore
Copy link
Contributor

Changes

  • added how full sync and snap sync function

Note

  • this should probably go in the devp2p section. I'm thinking we make a gh issue to stating to move this context over there once the open devp2p PR's are closed out

Copy link

github-actions bot commented May 6, 2025

Hi @shane-moore,

⚠️ Potential typos found in your pull request:

  • 📄 ./docs/wiki/EL/el-architecture.md (line(s) 187):
    1. ❌ trie’s
  • 📄 ./docs/wiki/EL/el-architecture.md (line(s) 324):
    1. ❌ Taverna
  • 📄 ./docs/wiki/EL/el-architecture.md (line(s) 324):
    1. ❌ Synchronising
  • 📄 ./docs/wiki/pectra-faq.md (line(s) 152):
    1. ❌ consolidatations
  • 📄 ./docs/wiki/pectra-faq.md (line(s) 152):
    1. ❌ BBdDc
  • 📄 ./docs/wiki/pectra-faq.md (line(s) 152):
    1. ❌ fb
  • 📄 ./docs/wiki/pectra-faq.md (line(s) 198):
    1. ❌ maxmium

ℹ️ How to fix this error:

  1. If these are actual typos:

    • Open the files at the specified line numbers and fix them
  2. If these are names or one-off nouns:

    • Wrap them in <name> tags
    • Example: <name>Alex Pereira</name>
    • Use this for people's names or unique terms that appear rarely
  3. If these are valid terms:

    • Add them to wordlist.txt (one word per line)
    • Terms must be plain text without spaces/special chars
    • The list is case-insensitive
  4. If these are code terms:

    • Wrap them in backticks (`) in your markdown

ℹ️ Checking for typos locally

  1. Install aspell for your platform
  2. Navigate to project root and run:
for f in **/*.md ; do echo $f ; aspell --lang=en_US --mode=markdown --home-dir=. --personal=wordlist.txt --ignore-case=true --camel-case --add-sgml-skip nospellcheck list < $f | sort | uniq -c ; done

Learn more about wordlist format

@shane-moore shane-moore force-pushed the chore/sync-strategies branch from 5c398ed to 3bdda2b Compare May 6, 2025 04:26
Copy link

github-actions bot commented May 6, 2025

Hi @shane-moore,

⚠️ Potential typos found in your pull request:

  • 📄 ./docs/wiki/pectra-faq.md (line(s) 152):
    1. ❌ BBdDc
  • 📄 ./docs/wiki/pectra-faq.md (line(s) 152):
    1. ❌ fb

ℹ️ How to fix this error:

  1. If these are actual typos:

    • Open the files at the specified line numbers and fix them
  2. If these are names or one-off nouns:

    • Wrap them in <name> tags
    • Example: <name>Alex Pereira</name>
    • Use this for people's names or unique terms that appear rarely
  3. If these are valid terms:

    • Add them to wordlist.txt (one word per line)
    • Terms must be plain text without spaces/special chars
    • The list is case-insensitive
  4. If these are code terms:

    • Wrap them in backticks (`) in your markdown

ℹ️ Checking for typos locally

  1. Install aspell for your platform
  2. Navigate to project root and run:
for f in **/*.md ; do echo $f ; aspell --lang=en_US --mode=markdown --home-dir=. --personal=wordlist.txt --ignore-case=true --camel-case --add-sgml-skip nospellcheck list < $f | sort | uniq -c ; done

Learn more about wordlist format

@shane-moore
Copy link
Contributor Author

@taxmeifyoucan @raxhvl, this PR is ready for review whenever you get a chance. I recall from the wiki contributors call a couple weeks ago that we wanted to split up PR reviewers by categories, but I don't remember who was assigned to which category, i.e. EL like for this PR

Copy link
Contributor

@taxmeifyoucan taxmeifyoucan left a comment

Choose a reason for hiding this comment

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

Thanks Shane!

Let's look at how the flows of both **full sync** and **snap sync** work.

### Full Sync
Full Sync trades absolute trustlessness for time and resources. You replay every block and transaction from genesis to tip, rebuilding the state trie step by step:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Full Sync trades absolute trustlessness for time and resources. You replay every block and transaction from genesis to tip, rebuilding the state trie step by step:
Full Sync trades absolute trustlessness for time and resources. The client replays every block and transaction from genesis to tip, rebuilding the state trie step by step:

Copy link
Contributor

Choose a reason for hiding this comment

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

I would maybe add that full sync is the default naive strategy and because it's starting from genesis, it's not sustainable for the future (4444)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

solid point! added 4444 context in latest commit 2bde312

Other thoughts I didn't include in the PR:
On top of 4444, once we get statelessness, syncing should be significantly sped up, since each block will have execution witnesses, containing each account and storage slots accessed, and block validation can just run txs against an in-memory state trie created from those accessed accounts and storage slots.
^^ maybe too early to add this context to the sync wiki section but def going to be a game changer

5. Send `GetByteCodes` for every code hash found in the account bodies to get back the contract code for that account
6. Locally insert every fetched leaf into a fresh trie, verifying each batch against the pivot root via Merkle proofs.

After step 6, we have a snapshot of the pivot block's state. However, the blockchain is also progressing at the same time and invalidating some of the regenerated state data. This means it is also necessary to have a healing phase where errors in the state are fixed. During healing, the client walks the reconstructed trie and verifies that it hashes to the pivot block’s stateRoot. Any missing or inconsistent trie nodes or bytecode blobs are fetched using targeted snap requests. Healing ensures the final state is complete and cryptographically valid, even if parts of the snapshot were stale, incomplete, or assembled from mixed sources.
Copy link
Contributor

@taxmeifyoucan taxmeifyoucan May 6, 2025

Choose a reason for hiding this comment

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

One small thing I would highlight here is that snapshot has a specific database like format, different from state merkle so it needs to be converted

Copy link
Contributor Author

@shane-moore shane-moore May 7, 2025

Choose a reason for hiding this comment

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

no doubt @taxmeifyoucan, added this context in 2bde312

- [Engine Api Spec](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#payload-validation)[archived](https://web.archive.org/web/20250318111700/https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#payload-validation)
- [Engine API: A Visual Guide](https://hackmd.io/@danielrachi/engine_api)[archived](https://web.archive.org/web/20241006232802/https://hackmd.io/@danielrachi/engine_api)
- [Engine API | Mikhail | Lecture 21](https://youtu.be/fR7LBXAMH7g)
- ["Snapping Snap Sync: Practical Attacks on Go Ethereum Synchronising Nodes" (ETH Zurich)](https://appliedcrypto.ethz.ch/content/dam/ethz/special-interest/infk/inst-infsec/appliedcrypto/research/TavernaPaterson-SnappingSnapSync.pdf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice source, added as well 2bde312

@shane-moore shane-moore force-pushed the chore/sync-strategies branch from 3bdda2b to f169c17 Compare May 7, 2025 17:22
@taxmeifyoucan taxmeifyoucan merged commit 69c2502 into eth-protocol-fellows:main May 16, 2025
2 checks passed
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