Commit Graph

12125 Commits

Author SHA1 Message Date
wbt
f1e1d9f874
node: support expressive origin rules in ws.origins (#21481)
* Only compare hostnames in ws.origins

Also using a helper function for ToLower consolidates all preparation steps in one function for more maintainable consistency.

Spaces => tabs

Remove a semicolon

Add space at start of comment

Remove parens around conditional

Handle case wehre parsed hostname is empty

When passing a single word like "localhost" the parsed hostname is an empty string. Handle this and the error-parsing case together as default, and the nonempty hostname case in the conditional.

Refactor with new originIsAllowed functions

Adds originIsAllowed() & ruleAllowsOrigin(); removes prepOriginForComparison

Remove blank line

Added tests for simple allowed-orign rule

which does not specify a protocol or port, just a hostname

Fix copy-paste: `:=` => `=`

Remove parens around conditional

Remove autoadded whitespace on blank lines

Compare scheme, hostname, and port with rule

if the rule specifies those portions.

Remove one autoadded trailing whitespace

Better handle case where only origin host is given

e.g. "localhost"

Remove parens around conditional

Refactor: attemptWebsocketConnectionFromOrigin DRY

Include return type on helper function

Provide srv obj in helper fn

Provide srv to helper fn

Remove stray underscore

Remove blank line

parent 93e666b4c1e7e49b8406dc83ed93f4a02ea49ac1
author wbt <wbt@users.noreply.github.com> 1598559718 -0400
committer Martin Holst Swende <martin@swende.se> 1605602257 +0100
gpgsig -----BEGIN PGP SIGNATURE-----

 iQFFBAABCAAvFiEEypmrtbNuJK1doP1AaDtDjAWl3fAFAl+zi9ARHG1hcnRpbkBz
 d2VuZGUuc2UACgkQaDtDjAWl3fDRiwgAoMtzU8dwRV7Q9xkCwWEx9Wz2f3n6jUr2
 VWBycDKGKwRkPPOER3oc9kzjGU/P1tFlK07PjfnAKZ9KWzxpDcJZwYM3xCBurG7A
 16y4YsQnzgPNONv3xIkdi3RZtDBIiPFFEmdZFFvZ/jKexfI6JIYPngCAoqdTIFb9
 On/aPvvVWQn1ExfmarsvvJ7kUDUG77tZipuacEH5FfFsfelBWOEYPe+I9ToUHskv
 +qO6rOkV1Ojk8eBc6o0R1PnApwCAlEhJs7aM/SEOg4B4ZJJneiFuEXBIG9+0yS2I
 NOicuDPLGucOB5nBsfIKI3USPeE+3jxdT8go2lN5Nrhm6MimoILDsQ==
 =sgUp
 -----END PGP SIGNATURE-----

Refactor: drop err var for more concise test lines

Add several tests for new WebSocket origin checks

Remove autoadded whitespace on blank lines

Restore TestWebsocketOrigins originally-named test

and rename the others to be helpers rather than full tests

Remove autoadded whitespace on blank line

Temporarily comment out new test sets

Uncomment test around origin rule with scheme

Remove tests without scheme on browser origin

per https://github.com/ethereum/go-ethereum/pull/21481/files#r479371498

Uncomment tests with port; remove some blank lines

Handle when browser does not specify scheme/port

Uncomment test for including scheme & port in rule

Add IP tests

* node: more tests + table-driven, ws origin changes

Co-authored-by: Martin Holst Swende <martin@swende.se>
2020-11-19 14:54:49 +01:00
Péter Szilágyi
28080463d2
Merge pull request #21861 from holiman/remove_retesteth
cmd/geth: remove retesteth
2020-11-19 07:49:40 +02:00
gary rong
b9ff57c59e
metrics: fix the panic for reading empty cpu stats (#21864) 2020-11-18 21:50:11 +01:00
gary rong
23524f8900
all: disable recording preimage of trie keys (#21402)
* cmd, core, eth, light, trie: disable recording preimage by default

* core, eth: fix unit tests

* core: fix import

* all: change to nopreimage

* cmd, core, eth, trie: use cache.preimages flag

* cmd: enable preimages for archive node

* cmd/utils, trie: simplify preimage tracking a bit

* core: fix linter

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2020-11-18 11:51:33 +02:00
Martin Holst Swende
6b9858085f
cmd/geth: improve les test on windows (#21860) 2020-11-17 12:01:19 +01:00
Abd ar-Rahman Hamidi
db87223269
crypto/secp256k1: add checking z sign in affineFromJacobian (#18419)
The z == 0 check is hit whenever we Add two points with the same x1/x2
coordinate. crypto/elliptic uses the same check in their affineFromJacobian
function. This change does not affect block processing or tx signature verification
in any way, because it does not use the Add or Double methods.
2020-11-17 11:47:17 +01:00
Martin Holst Swende
d513584e52
cmd/geth: remove retesteth 2020-11-17 11:44:38 +01:00
Preston Van Loon
844485ec6a
consensus/ethash: fix usage of *reflect.SliceHeader (#21372)
* consensus/ethash: only use *reflect.SliceHeader, not reflect.SliceHeader. See comment here: https://github.com/golang/go/issues/40397\#issuecomment-663748689

* consensus/ethash: pr feedback from @mdempsky, makes a copy of dest such that is not mutated

* consensus/ethash: remove noop assign

* consensus/ethash: apply same fix to another location

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2020-11-17 11:35:58 +02:00
Sad Pencil
1ea7537997
crypto/bn256: refine comments according to #19577, #21595, and #21836 (#21847) 2020-11-17 09:51:36 +01:00
Pascal Dierich
92c56eb820
common: fix documentation of Address.SetBytes (#21814) 2020-11-16 14:08:13 +01:00
Nicolas Feignon
cf856ea1ad
accounts/abi: template: set events Raw field in Parse methods (#21807) 2020-11-13 13:43:15 +01:00
Marius van der Wijden
2045a2bba3
core, all: split vm.Context into BlockContext and TxContext (#21672)
* all: core: split vm.Config into BlockConfig and TxConfig

* core: core/vm: reset EVM between tx in block instead of creating new

* core/vm: added docs
2020-11-13 13:42:19 +01:00
Martin Holst Swende
6f4cccf8d2
core/vm, protocol_params: implement eip-2565 modexp repricing (#21607)
* core/vm, protocol_params: implement eip-2565 modexp repricing

* core/vm: fix review concerns
2020-11-13 13:39:59 +01:00
Martin Holst Swende
0703c91fba
tests/fuzzers: improve the fuzzers (#21829)
* tests/fuzzers, common/bitutil: make fuzzers use correct returnvalues + remove output

* tests/fuzzers/stacktrie: fix duplicate-key insertion in stacktrie (false positive)

* tests/fuzzers/stacktrie: fix compilation error

* tests/fuzzers: linter nits
2020-11-13 12:36:38 +01:00
Marius van der Wijden
9ded4e33c5
crypto/bn256: better comments for u, P and Order (#21836) 2020-11-13 10:17:23 +01:00
Martin Holst Swende
a19b4235c7
crypto/bn256: improve bn256 fuzzer (#21815)
* crypto/cloudflare: fix nil deref in random G1/G2 reading

* crypto/bn256: improve fuzzer

* crypto/bn256: fix some flaws in fuzzer
2020-11-13 09:27:57 +01:00
Felix Lange
919229d63c params: begin v1.9.25 release cycle 2020-11-12 21:21:24 +01:00
Péter Szilágyi
cc05b050df
params: release Geth v1.9.24 with Go 1.15.5 (#21842) 2020-11-12 21:10:15 +01:00
Felix Lange
920a287117
.travis.yml: move test builders after install builders (#21833) 2020-11-11 23:52:50 +01:00
Felix Lange
d49407427d
build: fix regressions with the -dlgo change (#21831)
This fixes cross-build and mobile framework failures.
It also disables the mac test builder because it was failing
all the time in hard to understand ways and we can't afford
it anymore under Travis CI's new pricing.
2020-11-11 22:08:22 +01:00
Slava Karpenko
d990df909d
consensus/ethash: use 64bit indexes for the DAG generation (#21793)
* Bit boundary fix for the DAG generation routine

* Fix unnecessary conversion warnings

Co-authored-by: Sergey Pavlov <spavlov@gmail.com>
2020-11-11 21:13:12 +01:00
Felix Lange
27d93c1848
build: add -dlgo flag in ci.go (#21824)
This new flag downloads a known version of Go and builds with it. This
is meant for environments where we can't easily upgrade the installed Go
version.

* .travis.yml: remove install step for PR test builders

We added this step originally to avoid re-building everything
for every test. go test has become much smarter in recent go
releases, so we no longer need to install anything here.
2020-11-11 14:34:43 +01:00
Marius van der Wijden
70868b1e4a
fuzzers: removed fuzzbuzz configuration (#21813)
We decided to move our fuzzing efforts to oss-fuzz since fuzzbuzz is still early access.
2020-11-10 21:54:59 +02:00
Martin Holst Swende
941d8b5c5c
scripts: create oss-fuzz script in go-ethereum (#21808) 2020-11-10 15:21:41 +01:00
gary rong
c52dfd55fb
p2p/simulations/adapters/exec: fix some issues (#21801)
- Remove the ws:// prefix from the status endpoint since
  the ws:// is already included in the stack.WSEndpoint().
- Don't register the services again in the node start.
  Registration is already done in the initialization stage.
- Expose admin namespace via websocket.
  This namespace is necessary for connecting the peers via websocket.
- Offer logging relevant options for exec adapter.
  It's really painful to mix all log output in the single console. So
  this PR offers two additional options for exec adapter in this case
  testers can config the log output(e.g. file output) and log level
  for each p2p node.
2020-11-10 14:19:44 +01:00
Péter Szilágyi
0c34eae172
Merge pull request #21803 from holiman/ethash
consensus/ethash: fix the percentage progress report
2020-11-09 17:57:23 +02:00
Péter Szilágyi
7c30f4d085
Merge pull request #21804 from karalabe/snapshot-marker-sync
core/state/snapshot: update generator marker in sync with flushes
2020-11-09 17:50:26 +02:00
Péter Szilágyi
040928d8bb
Merge pull request #21805 from karalabe/travis-drop-1.13
travis: drop Go 1.13 builders as it's not supported any more
2020-11-09 17:49:56 +02:00
Péter Szilágyi
9e688fb64c
Merge pull request #21806 from karalabe/deprecate-eoan
build: stop building for Ubuntu Eoan, not supported any more
2020-11-09 17:49:21 +02:00
Péter Szilágyi
1143dc6e29
build: stop building for Ubuntu Eoan, not supported any more 2020-11-09 17:43:54 +02:00
Péter Szilágyi
eb694ea706
travis: drop Go 1.13 builders as it's not supported any more 2020-11-09 17:39:42 +02:00
Martin Holst Swende
81678971db
trie, tests/fuzzers: implement a stacktrie fuzzer + stacktrie fixes (#21799)
* trie: fix error in stacktrie not committing small roots

* fuzzers: make trie-fuzzer use correct returnvalues

* trie: improved tests

* tests/fuzzers: fuzzer for stacktrie vs regular trie

* test/fuzzers: make stacktrie fuzzer use 32-byte keys

* trie: fix error in stacktrie with small nodes

* trie: add (skipped) testcase for stacktrie

* tests/fuzzers: address review comments for stacktrie fuzzer

* trie: fix docs in stacktrie
2020-11-09 15:08:12 +01:00
Péter Szilágyi
7b7b327ff2
core/state/snapshot: update generator marker in sync with flushes 2020-11-09 16:03:58 +02:00
Martin Holst Swende
81ff700077
consensus/ethash: fix the percentage progress report 2020-11-09 11:56:29 +01:00
Péter Szilágyi
97fc1c3b1d
Merge pull request #21787 from karalabe/pod-non-verbose
build: stop verbose output to keep travis from overflowing
2020-11-05 11:55:50 +02:00
Péter Szilágyi
6cfe494276
build: stop verbose output to keep travis from overflowing 2020-11-05 11:52:35 +02:00
Martin Holst Swende
175506e7fd
core/types, rlp: optimize derivesha (#21728)
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>
2020-11-04 19:29:24 +01:00
rene
36bb7ac083
cmd/devp2p/internal/ethtest: add correct chain files and improve test 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>
2020-11-04 17:36:56 +01:00
Felix Lange
5d20fbbb6f
cmd/devp2p, internal/utesting: implement TAP output (#21760)
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.
2020-11-04 15:02:58 +01:00
gary rong
e6402677c2
core/state/snapshot: fix journal recovery from generating old journal (#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
2020-11-04 13:41:46 +02:00
Marius van der Wijden
3eebf34038
common: remove ToHex and ToHexArray (#21610)
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.
2020-11-04 11:20:39 +01:00
gary rong
b63bffe820
les, p2p/simulations/adapters: fix issues found while simulating les (#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.
2020-10-30 18:04:38 +01:00
gary rong
b63e3c37a6
core: improve snapshot journal recovery (#21594)
* 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>
2020-10-29 21:01:58 +02:00
gary rong
43c278cdf9
core/state: disable snapshot iteration if it's not fully constructed (#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
2020-10-28 14:27:37 +02:00
gary rong
18145adf08
core/state: maintain one more diff layer (#21730)
* core/state: maintain one more diff layer

* core/state: address comment
2020-10-28 14:00:22 +02:00
Marius van der Wijden
296a27d106
accounts/abi/bind: restore error functionality (#21743)
* 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>
2020-10-27 17:22:44 +01:00
James Prestwich
1a55e20d35
cmd/geth: fix dir path in geth attach for yolov2 network (#21749) 2020-10-26 14:45:08 +02:00
Péter Szilágyi
7b748e550a
Merge pull request #21747 from holiman/yolov2update
params: update yolov2 bootnode with elastic ip
2020-10-23 17:48:43 +03:00
Martin Holst Swende
68ac4eb796
params: update yolov2 bootnode with elastic ip 2020-10-23 16:47:26 +02:00
Péter Szilágyi
8a94aa91fb
Merge pull request #21745 from holiman/yolov2_bootnodes
utils, params: add yolov2 bootnode
2020-10-23 16:42:08 +03:00