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

Merge/foundation master 20201111 #230

Merged
merged 87 commits into from
Dec 24, 2020

Conversation

meowsbits
Copy link
Member

@meowsbits meowsbits commented Nov 11, 2020

There are a lot of changes related to YoloV2 including some additional EIPs, see

fjl and others added 30 commits October 15, 2020 12:30
* core/vm: marshall returnData as hexstring in trace logs

* core/vm: marshall returnData as hexstring in trace logs
* add interrupt counter

* remove interrupt counter, allow ctrl-C to clear ONLY, ctrl-D will terminate console, stop node

* format

* add instructions to exit

* fix tests
* core: add background indexer to waitgroup

* core: make indexer stopable

* core/rawdb: add unit tests

* core/rawdb: fix lint

* core/rawdb: fix tests

* core/rawdb: fix linter
* Fix potential nil pointer error when neither block number nor hash is specified to accountRange

* Update error description
* les: move NodeStateMachine from clientPool to LesServer

* les: new header broadcaster

* les: peerCommons.headInfo always contains last announced head

* les: remove clientPeerSet and serverSet

* les: fixed panic

* les: fixed --nodiscover option

* les: disconnect all peers at ns.Stop()

* les: added comments and fixed signed broadcasts

* les: removed unused parameter, fixed tests
The version check logic did not take into account the second digit (i.e. the '4' in v1.4.0) - this one line patch corrects this.
… + yolo-v2 (#21509)

* core/vm, core/state: implement EIP-2929 + YOLOv2

* core/state, core/vm: fix some review concerns

* core/state, core/vm: address review concerns

* core/vm: address review concerns

* core/vm: better documentation

* core/vm: unify sload cost as fully dynamic

* core/vm: fix typo

* core/vm/runtime: fix compilation flaw

* core/vm/runtime: fix renaming-err leftovers

* core/vm: renaming

* params/config: use correct yolov2 chainid for config

* core, params: use a proper new genesis for yolov2

* core/state/tests: golinter nitpicks
The old one was wrong in two ways: the first block in chain.rlp was the
genesis block, and the genesis difficulty was below minimum difficulty.

This also contains some other fixes to the test.
params: update yolov2 bootnode with elastic ip
* accounts/abi/bind: restore error functionality

* Update accounts/abi/bind/base.go

Co-authored-by: Guillaume Ballet <gballet@gmail.com>

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
* core/state: maintain one more diff layer

* core/state: address comment
…(#21682)

* core/state/snapshot: add diskRoot function

* core/state/snapshot: disable iteration if the snapshot is generating

* core/state/snapshot: simplify the function

* core/state: panic for undefined layer
* core/state/snapshot: introduce snapshot journal version

* core: update the disk layer in an atomic way

* core: persist the disk layer generator periodically

* core/state/snapshot: improve logging

* core/state/snapshot: forcibly ensure the legacy snapshot is matched

* core/state/snapshot: add debug logs

* core, tests: fix tests and special recovery case

* core: polish

* core: add more blockchain tests for snapshot recovery

* core/state: fix comment

* core: add recovery flag for snapshot

* core: add restart after start-after-crash tests

* core/rawdb: fix imports

* core: fix tests

* core: remove log

* core/state/snapshot: fix snapshot

* core: avoid callbacks in SetHead

* core: fix setHead cornercase where the threshold root has state

* core: small docs for the test cases

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
…(#21761)

This adds a few tiny fixes for les and the p2p simulation framework:

LES Parts

- Keep the LES-SERVER connection even it's non-synced

  We had this idea to reject the connections in LES protocol if the les-server itself is
  not synced. However, in LES protocol we will also receive the connection from another
  les-server. In this case even the local node is not synced yet, we should keep the tcp
  connection for other protocols(e.g. eth protocol).

- Don't count "invalid message" for non-existing GetBlockHeadersMsg request

  In the eth syncing mechanism (full sync, fast sync, light sync), it will try to fetch
  some non-existent blocks or headers(to ensure we indeed download all the missing chain).
  In this case, it's possible that the les-server will receive the request for
  non-existent headers. So don't count it as the "invalid message" for scheduling
  dropping.

- Copy the announce object in the closure

  Before the les-server pushes the latest headers to all connected clients, it will create
  a closure and queue it in the underlying request scheduler. In some scenarios it's
  problematic. E.g, in private networks, the block can be mined very fast. So before the
  first closure is executed, we may already update the latest_announce object. So actually
  the "announce" object we want to send is replaced.

  The downsize is the client will receive two announces with the same td and then drop the
  server.

P2P Simulation Framework

- Don't double register the protocol services in p2p-simulation "Start".

  The protocols upon the devp2p are registered in the "New node stage". So don't reigster
  them again when starting a node in the p2p simulation framework

- Add one more new config field "ExternalSigner", in order to use clef service in the
  framework.
ToHex was deprecated a couple years ago. The last remaining use
was in ToHexArray, which itself only had a single call site.

This just moves ToHexArray near its only remaining call site and
implements it using hexutil.Encode. This changes the default behaviour
of ToHexArray and with it the behaviour of eth_getProof. Previously we
encoded an empty slice as 0, now the empty slice is encoded as 0x.
… (#21775)

* core/state/snapshot: print warning if failed to resolve journal

* core/state/snapshot: fix snapshot recovery

When we meet the snapshot journal consisted with:
- disk layer generator with new-format
- diff layer journal with old-format

The base layer should be returned without error.
The broken diff layer can be reconstructed later
but we definitely don't want to reconstruct the
huge diff layer.

* core: add tests
TAP is a text format for test results. Parsers for it are available in many languages,
making it easy to consume. I want TAP output from our protocol tests because the
Hive wrapper around them needs to know about the test names and their individual
results and logs. It would also be possible to just write this info as JSON, but I don't
want to invent a new format.

This also improves the normal console output for tests (when running without --tap).
It now prints -- RUN lines before any output from the test, and indents the log output
by one space.
… output (#21782)

This PR replaces the old test genesis.json and chain.rlp files in the testdata
directory for the eth protocol test suite, and also adds documentation for
running the eth test suite locally.

It also improves the test output text and adds more timeouts.

Co-authored-by: Felix Lange <fjl@twurst.com>
This PR contains a minor optimization in derivesha, by exposing the RLP
int-encoding and making use of it to write integers directly to a
buffer (an RLP integer is known to never require more than 9 bytes
total). rlp.AppendUint64 might be useful in other places too.

The code assumes, just as before, that the hasher (a trie) will copy the
key internally, which it does when doing keybytesToHex(key).

Co-authored-by: Felix Lange <fjl@twurst.com>
build: stop verbose output to keep travis from overflowing
…dation-master-20201111

Conflicts:
      .travis.yml
      appveyor.yml
      params/version.go
…re-geth into merge/foundation-master-20201111
@meowsbits
Copy link
Member Author

Rel #230 (comment), I just merged foundation/release/1.9, which brings the upstream changes up-to-date through their latest v1.9.24 tag.

@meowsbits
Copy link
Member Author

meowsbits commented Dec 10, 2020

Double check:

  • etchash (ECIP1099) logic
  • potential tracer conflicts

devp2p rlpx eth-test <enode ID> cmd/devp2p/internal/ethtest/testdata/fullchain.rlp cmd/devp2p/internal/ethtest/testdata/genesis.json
```

[eth]: https://github.com/ethereum/devp2p/blob/master/caps/eth.md
Copy link
Member Author

Choose a reason for hiding this comment

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

Are the tests described here run programmatically anywhere? (Will they be run in the CI?)

@@ -287,9 +288,29 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig ctyp
// Make sure the state associated with the block is available
head := bc.CurrentBlock()
if _, err := state.New(head.Root(), bc.stateCache, bc.snaps); err != nil {
Copy link
Member Author

@meowsbits meowsbits Dec 10, 2020

Choose a reason for hiding this comment

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

bc.snaps:

	snaps  *snapshot.Tree // Snapshot tree for fast trie leaf access
// SnapshotTree is an Ethereum state snapshot tree. It consists of one persistent
// base layer backed by a key-value store, on top of which arbitrarily many in-
// memory diff layers are topped. The memory diffs can form a tree with branching,
// but the disk layer is singleton and common to all. If a reorg goes deeper than
// the disk layer, everything needs to be deleted.
//
// The goal of a state snapshot is twofold: to allow direct access to account and
// storage data to avoid expensive multi-level trie lookups; and to allow sorted,
// cheap iteration of the account/storage tries for sync aid.
type Tree struct {
	diskdb ethdb.KeyValueStore      // Persistent database to store the snapshot
	triedb *trie.Database           // In-memory cache to access the trie through
	cache  int                      // Megabytes permitted to use for read caches
	layers map[common.Hash]snapshot // Collection of all known layers
	lock   sync.RWMutex
}

// disk layer point of snapshot(if it's enabled). Make sure the
// rewound point is lower than disk layer.
var diskRoot common.Hash
if bc.cacheConfig.SnapshotLimit > 0 {
Copy link
Member Author

Choose a reason for hiding this comment

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

	SnapshotLimit       int           // Memory allowance (MB) to use for caching snapshot entries in memory

// retaining chain consistency.
//
// The method returns the block number where the requested root cap was found.
func (bc *BlockChain) SetHeadBeyondRoot(head uint64, root common.Hash) (uint64, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems an extra condition is added to the original SetHead method, but the original method's logic is not preserved (since SetHead jus wraps SetHeadBeyondRoot).

// - head layer is paired with HEAD state
// - head-1 layer is paired with HEAD-1 state
// - head-127 layer(bottom-most diff layer) is paired with HEAD-127 state
if err := s.snaps.Cap(root, 128); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note 128 is hardcoded here, and got bumped from 127.

eth/api_tracer.go Outdated Show resolved Hide resolved
This fixes value-copying logic for the chain config
interface value in the tracer in case of tracing-specific
overrides.

Tests, though embarassingly amateurish, shamelessly
show the logic and legitimacy of the change.

Date: 2020-12-10 15:23:29-06:00
Signed-off-by: meows <b5c6@protonmail.com>
Date: 2020-12-10 15:25:47-06:00
Signed-off-by: meows <b5c6@protonmail.com>
@ziogaschr
Copy link
Member

@meowsbits the potential tracer conflicts have not yet merged in. They will merged in with ethereum/go-ethereum@23524f8

 Conflicts:
	cmd/puppeth/wizard_genesis.go
	cmd/utils/flags.go
	consensus/ethash/ethash.go
@ziogaschr
Copy link
Member

@meowsbits upstream master bring more changes with regards snapshot. I am not saying to merge them in. Just that we might want to have an overview of what it brings in, in order to better evaluate the snapshot feature and what we merge in/how we resolve conflicts.

@meowsbits
Copy link
Member Author

Sorry, I think there is a naming confusion here from "master-upstream". The master-upstream branch is a hybrid of OUR master and the current pending upstream merge (this PR). It isn't the upstream master (not ethereum/go-ethereum#master).

This latest commit (ce45de9) only did the following...

# Checkout the master-upstream branch which is a hybrid between 
# the current master and current pending upstream changes (ie this PR).
git checkout master-upstream

# Resolve conflicts via merging CURRENT master.
git merge master

git push etclabscore master-upstream

# Checkout this branch.
git checkout merge/foundation-master-20201111

# Update to master-upstream and resolve conflicts.
git merge master-upstream

@meowsbits
Copy link
Member Author

meowsbits commented Dec 21, 2020

The intention of the poorly-named master-upstream was to create a hybrid/intermediate branch dedicated to the upstream merges against master.

This allows us to handle our own features and bugs relative to master, and decide independently of those when to merge upstream changes to master, while still being able to work on upstream merges against a master state.

@ziogaschr
Copy link
Member

My bad @meowsbits as I was meaning foundation master (ethereum/go-ethereum#master). Sorry for the naming confusion I brought in.

@iquidus
Copy link
Contributor

iquidus commented Dec 23, 2020

Double check:

* [ ]  `etchash` (ECIP1099) logic

* [x]  potential tracer conflicts
  • etchash (ECIP1099) logic

@meowsbits meowsbits merged commit ce45de9 into master-upstream Dec 24, 2020
@meowsbits meowsbits deleted the merge/foundation-master-20201111 branch December 24, 2020 02:39
@meowsbits
Copy link
Member Author

This was merged to master at 5c85899.

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

Successfully merging this pull request may close these issues.

None yet