Skip to content

state-sync handling in eth/69#28

Closed
marcello33 wants to merge 14 commits intomainfrom
mardizzone/ss-pos-3265
Closed

state-sync handling in eth/69#28
marcello33 wants to merge 14 commits intomainfrom
mardizzone/ss-pos-3265

Conversation

@marcello33
Copy link

In this PR, we implement the state-sync data handling in the new eth/69 protocol introduced by geth..
Now, nodes have the ability to send state-sync transaction receipts in eth/69 protocol, allowing them to persist the state-sync transaction receipts.

This PR reflects the Erigon's changes for this PR in bor:

@marcello33 marcello33 changed the title state-synch handling in eth/69 state-sync handling in eth/69 Sep 30, 2025
Copy link
Member

@manav2401 manav2401 left a comment

Choose a reason for hiding this comment

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

I was navigating the code on how requests are processed and thought of posting some things we need to ensure while testing.

If you follow the path of code on how GetReceipts p2p message is processed (starting from here), there are multiple places at which it tries to find receipts.

  1. It tries to fetch it from cache (this is a simple LRU cache). Ideally, I think bor receipts would be generally missing from cache but because there's not mechanism to know that, it would just return from that. We need to ensure that the cache surely contains bor receipts else it won't be included in the p2p packet. I think testing will let us know if this is true or not when we're running a live chain (on devnet or mainnet).

  2. It later goes into GetReceipts it uses another layer of cache (which is actually a kv db) making the call to ReadReceiptsCacheV2. We need to ensure that this db contains bor receipts. Again, testing should let us know about this.

  3. Worst case if not found, we process the whole block locally to generate receipts and return. I think this should never happen unless user disables a few things via flags. We need to ensure bor tx is also processed via state-sync events stored.

Overall, I think if bor receipts are correctly stored in db / cache, we should be good to go. Let's see how tests go.

Copy link
Member

Choose a reason for hiding this comment

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

We derive cumulative gas so it may not be zero going forward. It's better to have some different indicator for identifying state-sync transactions.

Copy link
Member

Choose a reason for hiding this comment

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

I think you can borrow the logic you're using in ReadStateSyncReceiptByHash function here to identify if a receipt is state-sync or not.

Copy link
Author

Choose a reason for hiding this comment

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

Done here ff196b6
Please double check
Thanks

@manav2401
Copy link
Member

This section of code only processes normal transactions. I think we'll need to generate bor receipts by borrowing some logic from here and then append it to the final response of receipts (and also ensure it's updated in cache).

@marcello33
Copy link
Author

This section of code only processes normal transactions. I think we'll need to generate bor receipts by borrowing some logic from here and then append it to the final response of receipts (and also ensure it's updated in cache).

Yeah I tried to avoid this in the first place given that the Generator needs a BorGenerator then, and we need to fetch the events again as we do from the jsornpc/API layer.
But I see your point, makes sense.
Addressed here ff196b6, please double check
Thanks

@marcello33
Copy link
Author

Closing in favour of #41

@marcello33 marcello33 closed this Oct 14, 2025
@kamuikatsurgi kamuikatsurgi deleted the mardizzone/ss-pos-3265 branch November 17, 2025 07:27
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

Comments