Skip to content

Conversation

@weiihann
Copy link
Contributor

@weiihann weiihann commented Dec 26, 2025

Description

Add a new OnStateUpdate hook which gets invoked after state is committed.

Rationale

For our particular use case, we need to obtain the state size metrics at every single block when fuly syncing from genesis. With the current state sizer, whenever the node is stopped, the background process must be freshly initialized. During this re-initialization, it can skip some blocks while the node continues executing blocks, causing gaps in the recorded metrics.

Using this state update hook allows us to customize our own data persistence logic, and we would never skip blocks upon node restart.

The statesize tracer shows how the hook is used. Will remove once this PR is ready for merging.

@weiihann weiihann force-pushed the feat/state-update-hook branch from 672b701 to 752e16a Compare December 26, 2025 07:44
@weiihann weiihann changed the title Feat/state update hook Dec 26, 2025
@weiihann weiihann force-pushed the feat/state-update-hook branch 4 times, most recently from 7df337b to 1d415b4 Compare December 26, 2025 08:06
add statesize tracer

create file

debug log

deal with genesis

debug logs

fix storage bytes

fix storage

fix storage 2

Revert "fix storage 2"

This reverts commit cfbefaa.

Revert "fix storage"

This reverts commit 62a4189.

Revert "fix storage bytes"

This reverts commit 1b42707.

fix storage 3

remove debug logs

remove lint

lint

chore

revert lint

fix lint

fix nil

add depth count

debug depth

created and deleted nodes
@weiihann weiihann force-pushed the feat/state-update-hook branch from ab2f926 to abbe71b Compare December 26, 2025 10:01
type CodeChange struct {
Hash common.Hash
Code []byte
Exists bool // true if the code already deployed before
Copy link
Member

Choose a reason for hiding this comment

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

We should may be also expose the original value of the deployed code.

Originally the code is immutable and will never be changed since the deployment. With EIP-7702, it's possible to re-deploy the delegation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@weiihann
Copy link
Contributor Author

Maybe I wasn't being clear. The statesize tracer was meant to show how this hook is used and shouldn't be merged into geth. I've removed the relevant files. Sorry for the time wasted 🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants