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

[wip] FILL_COST take 2 #462

Draft
wants to merge 4 commits into
base: kaustinen-with-shapella
Choose a base branch
from
Draft

Conversation

gballet
Copy link
Owner

@gballet gballet commented Jul 18, 2024

Directly bypass the StateDB layer into the disk DB, in order to find out if a value exists. This will avoid a lot of caching bugs.

The obvious problem with this approach, is that reading a slot will require hashing. One workaround for this problem would be to have a DB with (key, values). All the insertions/tree updates are moved to the prefetcher/background threads. This would mean that the tree and values are stored at different locations - and that we need to rewrite the disk access layer in geth :| Let's see how bad the performance hit is, before we go for that one.

One thing to note is that there are really two things that cause this read:

  • SELFDESTRUCT is the use case for which the most checks need to happen. Note that this isn't implemented at the current state of this PR.
  • SSTORE is the other use case, and unfortunately it will come at a significant slowdown.

// The error needs to be checked because we want to be future-proof
// and not rely on the length of the encoding, in case 0-values are
// somehow compressed later.
return errors.Is(pebble.ErrNotFound, err)
Copy link
Owner Author

Choose a reason for hiding this comment

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

this only works with pebble, which is a problem because we don't know how much of the network still uses legacy dbs.

@@ -50,6 +51,7 @@ func NewAccessWitness(pointCache *utils.PointCache) *AccessWitness {
return &AccessWitness{
branches: make(map[branchAccessKey]mode),
chunks: make(map[chunkAccessKey]mode),
fills: make(map[chunkAccessKey]struct{}),
Copy link
Owner Author

Choose a reason for hiding this comment

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

note to self: this is a bug because it is reinitialized for each tx

Comment on lines +662 to +667
// check the proof for the last block
// err = trie.DeserializeAndVerifyVerkleProof(proofs[0], genesis.Root().Bytes(), chain[0].Root().Bytes(), keyvals[0])
// if err != nil {
// t.Fatal(err)
// }
// t.Log("verfied verkle proof")
Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: figure out why this is broken and fix it

// is now independent of the blockchain database.
gspec.MustCommit(gendb)

blockGasUsagesExpected := params.TxGas + 216 /* intrinsic gas */ + 3*vm.GasFastestStep + params.WitnessChunkReadCost + params.WitnessChunkWriteCost
Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO: get intrinsic gas from the function

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.

1 participant