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

Restore stateless client prototype (without semi-stateless) #112

Merged
merged 33 commits into from
Oct 21, 2019

Conversation

AlexeyAkhunov
Copy link
Contributor

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).

// 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) {
Copy link
Contributor Author

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

if err := tds.ResolveStateTrie(); err != nil {
return nil, err
}
roots, err := tds.computeTrieRoots(true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename to updateStateTrie

}
}

func (tds *TrieDbState) ExtractTouches() [][]byte {
func (tds *TrieDbState) ExtractTouches() ([][]byte, [][]byte) {
Copy link
Contributor Author

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


// 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename to updateStateTrie

// 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)
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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()
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comments and constants

Copy link
Contributor

@JekaMas JekaMas left a comment

Choose a reason for hiding this comment

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

Computer says 'yes'

@AlexeyAkhunov AlexeyAkhunov merged commit 4911101 into master Oct 21, 2019
@AlexeyAkhunov AlexeyAkhunov deleted the block_witness branch October 31, 2019 21:44
BlinkyStitt pushed a commit to llamanodes/erigon that referenced this pull request Jun 8, 2023
* support step-by-step stage sync

* update sync logic
battlmonstr pushed a commit that referenced this pull request Sep 14, 2023
cffls pushed a commit to cffls/erigon that referenced this pull request Feb 14, 2024
* 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
wtdcode pushed a commit to wtdcode/erigon that referenced this pull request May 27, 2024
taratorio pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Michele Modolo <[email protected]>
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