-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Restore stateless client prototype (without semi-stateless) #112
Conversation
// TestCopy tests that copying a statedb object indeed makes the original and | ||
// the copy independent of each other. This test is a regression test against | ||
// https://github.com/ethereum/go-ethereum/pull/15549. | ||
func TestCopy(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this test because it is the only place that uses tries concurrently, and therefore requires locking in trie_pruning.go
, at a great performance cost
core/state/database.go
Outdated
if err := tds.ResolveStateTrie(); err != nil { | ||
return nil, err | ||
} | ||
roots, err := tds.computeTrieRoots(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to updateStateTrie
core/state/database.go
Outdated
} | ||
} | ||
|
||
func (tds *TrieDbState) ExtractTouches() [][]byte { | ||
func (tds *TrieDbState) ExtractTouches() ([][]byte, [][]byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add names of the return values + comment
core/state/database.go
Outdated
|
||
// forward is `true` if the function is used to progress the state forward (by adding blocks) | ||
// forward is `false` if the function is used to rewind the state (for reorgs, for example) | ||
func (tds *TrieDbState) computeTrieRoots(forward bool) ([]common.Hash, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to updateStateTrie
trie/proof_generator.go
Outdated
// BlockWitnessBuilder accumulates data that can later be turned into a serialised | ||
// version of the block witness | ||
// All buffers are streams of CBOR-encoded items (not a CBOR array, but individual items back-to-back) | ||
// `Keys` are binary strings | ||
// `Values` are either binary strings or arrays of structures | ||
// `Values` are either binary strings or integers (nonce) or big integers (balance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix - nonces and balances now have their own tapes
@@ -67,18 +65,13 @@ func runBlock(tds *state.TrieDbState, dbstate *state.Stateless, chainConfig *par | |||
if err := statedb.CommitBlock(ctx, dbstate); err != nil { | |||
return fmt.Errorf("commiting block %d failed: %v", block.NumberU64(), err) | |||
} | |||
if err := dbstate.CheckRoot(header.Root, checkRoot); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove tds
from the parameters of the runBlock
function, it is not needed anymore
if err := decoder.Decode(&lens); err != nil { | ||
return nil, nil, err | ||
} | ||
hb := NewHashBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment about importance of order
trie/resolver.go
Outdated
tr.a.EncodeForHashing(buf.B) | ||
tr.hb.setKeyValue(skip, k, buf) | ||
if tr.a.IsEmptyCodeHash() && tr.a.IsEmptyRoot() { | ||
tr.fieldSet = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments and constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Computer says 'yes'
* support step-by-step stage sync * update sync logic
* fixes for handling scalable contract and block gas limit * allow a network with no L1 verifications to still be synced by another node * fixes to the datastream allowing another erigon node to sync
Co-authored-by: Michele Modolo <[email protected]>
Added necessary code to generate block witnesses in the new format (based on the stack machine with tapes).
Modified the prototype in
cmd/state/stateless.go
to use the new format.Has not yet fixed writing out the stats (size of the witnesses and their components).