Commit Graph

74 Commits

Author SHA1 Message Date
Delweng
b0095eeb20
ethclient,event: replace noarg fmt.Errorf with errors.New (#27334)
Signed-off-by: jsvisa <delweng@gmail.com>
2023-05-24 12:39:49 +02:00
Martin Holst Swende
9231770811
rpc: change BlockNumber constant values to match ethclient (#27219)
ethclient accepts certain negative block number values as specifiers for the "pending",
"safe" and "finalized" block. In case of "pending", the value accepted by ethclient (-1)
did not match rpc.PendingBlockNumber (-2).

This wasn't really a problem, but other values accepted by ethclient did match the
definitions in package rpc, and it's weird to have this one special case where they don't.

To fix it, we decided to change the values of the constants rather than changing ethclient.
The constant values are not otherwise significant. This is a breaking API change, but we
believe not a dangerous one.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2023-05-23 13:18:38 +02:00
Delweng
c8b0afb2c4
ethclient: acquire the rpc.Client (#27246)
Signed-off-by: jsvisa <delweng@gmail.com>
2023-05-11 10:09:16 +03:00
Péter Szilágyi
dde2da0efb
all: remove ethash pow, only retain shims needed for consensus and tests (#27178)
* all: remove ethash pow, only retain shims needed for consensus and tests

* all: thank you linter

* all: disallow launching Geth in legacy PoW mode

* cmd/env/internal/t8ntool: remove dangling ethash flag
2023-05-03 12:58:39 +03:00
Sina Mahmoodi
ae66009640
internal/ethapi: add block overrides to eth_call (#26414)
Adds an optional config parameter to eth_call which allows users to override block context fields (same functionality that was added to traceCall in #24871)

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-05-02 04:28:43 -04:00
norwnd
df383addee
ethclient: ensure returned subscription is nil on error (#26976) 2023-03-25 22:38:43 +01:00
Felix Lange
4688d3c8f4
ethclient: fix panic when requesting missing blocks (#26817)
This fixes a regression introduced by #26723.
Fixes #26816.
2023-03-07 05:21:23 -05:00
Peter (bitfly)
e1b98f49a5
ethclient: include withdrawals in ethclient block responses (#26778)
* include withdrawals in ethclient responses

* omit empty withdrawals array in json serialization
2023-02-28 15:40:24 +02:00
rjl493456442
fe01a2f63b
all: use unified emptyRootHash and emptyCodeHash (#26718)
The EmptyRootHash and EmptyCodeHash are defined everywhere in the codebase, this PR replaces all of them with unified one defined in core/types package, and also defines constants for TxRoot, WithdrawalsRoot and UncleRoot
2023-02-21 06:12:27 -05:00
Mio
78d089b5b7
ethclient/gethclient: fix typo (#26580)
fix grammar typo
2023-01-31 03:28:32 -05:00
Felix Lange
d379e3f605
ethclient/gethclient: ensure getProof keys parameter is not null (#26409)
Other clients do not accept a parameter value of null for this array.
2023-01-12 11:31:21 +01:00
Marius van der Wijden
db82ea2ee3
core: reset txpool on sethead (#26392)
This change sends a HeadChainEvent when SetHead is invoked. The txpool will then reset the txnoncer on receiving the event.
2022-12-29 07:24:34 -05:00
ligi
bc90a88263
ethclient: docs, fix misleading comment (#26189)
closes #26188
2022-11-16 08:44:54 +01:00
lmittmann
5b1a04b9c7
eth/filters, ethclient/gethclient: add fullTx option to pending tx filter (#25186)
This PR adds a way to subscribe to the _full_ pending transactions, as opposed to just being notified about hashes. 

In use cases where client subscribes to newPendingTransactions and gets txhashes only to then request the actual transaction, the caller can now shortcut that flow and obtain the transactions directly. 


Co-authored-by: Felix Lange <fjl@twurst.com>
2022-10-12 11:54:52 +02:00
Martin Holst Swende
5a02b2d6d0
all: fix spelling mistakes (#25961) 2022-10-11 09:37:00 +02:00
Martin Holst Swende
067bac3f24
core, ethclient/gethclient: improve flaky tests (#25918)
* ethclient/gethclient: improve time-sensitive flaky test

* eth/catalyst: fix (?) flaky test

* core: stop blockchains in tests after use

* core: fix dangling blockchain instances

* core: rm whitespace

* eth/gasprice, eth/tracers, consensus/clique: stop dangling blockchains in tests

* all: address review concerns

* core: goimports

* eth/catalyst: fix another time-sensitive test

* consensus/clique: add snapshot test run function

* core: rename stop() to stopWithoutSaving()

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-10-06 13:39:20 +02:00
Janko Simonovic
1a63a76fcc
ethclient/gethclient: fix bugs in override object encoding (#25616)
This fixes a bug where contract code would be overridden to empty code ("0x")
when the Code field of OverrideAccount was left nil. The change also cleans up
the encoding of overrides to only send necessary fields, and improves documentation.

Fixes #25615

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-09-27 19:23:53 +02:00
rjl493456442
dea1fb3cfc
all: cleanup tests (#25641)
Follow-up to PR #25523 to cleanup all relevant tests.
2022-09-07 20:21:59 +02:00
Rachel Bousfield
8df8eb4e7a
ethclient: add 'finalized' and 'safe' block number support (#25580) 2022-08-30 14:56:39 +02:00
Sina Mahmoodi
36874b63a1
eth/filters: add global block logs cache (#25459)
This adds a cache for block logs which is shared by all filters. The cache
size of is configurable using the `--cache.blocklogs` flag.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-08-19 11:14:59 +02:00
Justin Traglia
2c5648d891
all: fix some typos (#25551)
* Fix some typos

* Fix some mistakes

* Revert 4byte.json

* Fix an incorrect fix

* Change files to fails
2022-08-19 09:00:21 +03:00
rjl493456442
a41ea8a97c
all: cleanup the APIs for initializing genesis (#25473)
* all: polish tests

* core: apply feedback from Guillaume

* core: fix comment
2022-08-09 12:44:39 +03:00
lightclient
9ad508018e
ethereum, ethclient: add FeeHistory support (#25403)
Co-authored-by: Felix Lange <fjl@twurst.com>
2022-07-29 18:22:04 +02:00
Delweng
b196ad1c16
all: add whitespace linter (#25312)
* golangci: typo

Signed-off-by: Delweng <delweng@gmail.com>

* golangci: add whietspace

Signed-off-by: Delweng <delweng@gmail.com>

* *: rm whitesapce using golangci-lint

Signed-off-by: Delweng <delweng@gmail.com>

* cmd/puppeth: revert accidental resurrection

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2022-07-25 13:14:03 +03:00
Felipe Strozberg
f5ff022dbc
ethclient: add PeerCount method (#24849)
* adding peer count function

* Update ethclient.go

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-05-11 08:05:55 +03:00
Joshua Gutow
84041e8f31
ethclient/gethclient: return storage proofs in GetProof (#24697)
Storage proofs were being unmarshalled from the RPC form to the go struct, but were not being included in the final returned struct.
2022-04-27 11:51:24 +02:00
zhiqiangxu
e98114da4f
ethclient: add CallContractAtHash (#24355)
* add CallContractAtHash to ethclient

* add docstring and test

* optimize test

* ethclient: nits

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2022-02-15 11:55:55 +02:00
Felix Lange
0169d579d0
ethclient: fix unmarshaling of ethereum.SyncProgress (#24199)
SyncProgress was modified in PR #23576 to add the fields reported for
snap sync. The PR also changed ethclient to use the SyncProgress struct
directly instead of wrapping it for hex-decoding. This broke the
SyncProgress method.

Fix it by putting back the custom wrapper. While here, also put back the
fast sync related fields because SyncProgress is stable API and thus
removing fields is not allowed.

Fixes #24180
Fixes #24176
2022-01-05 16:12:47 +01:00
Péter Szilágyi
c10a0a62c3
eth: request id dispatcher and direct req/reply APIs (#23576)
* eth: request ID based message dispatcher

* eth: fix dispatcher cancellation, rework fetchers idleness tracker

* eth/downloader: drop peers who refuse to serve advertised chains
2021-11-26 13:26:03 +02:00
Lee Bousfield
16341e0563
ethclient: fix tx sender cache miss detection (#23877)
This fixes a bug in TransactionSender where it would return the
zero address for transactions where the sender address wasn't
cached already.

Co-authored-by: Felix Lange <fjl@twurst.com>
2021-11-17 14:44:41 +01:00
Harry Dutton
3ce9f6d96f
ethclient: fix typo (#23778) 2021-10-20 16:22:02 +02:00
Martin Holst Swende
1b34283810
ethclient, accounts/keystore: fix flaky tests (#23599)
* ethclient/gethclient: fix flaky test (due to map key ordering)

* accounts/keystore: fix test failing due to rand collision due to low time resolution on windows
2021-09-20 10:23:44 +02:00
Marius van der Wijden
2faf796d2a
internal/ethapi: fix panic in accesslist creation (#23225)
* internal/ethapi: revert + fix properly in al tracer

* internal/ethapi: use toMessage instead of creating new message

* internal/ethapi: remove ineffassign

* core: fix invalid unmarshalling, fix test

Co-authored-by: Martin Holst Swende <martin@swende.se>
2021-07-28 14:21:35 +02:00
Marius van der Wijden
e7c8693635
internal/ethapi: fix panic in access list creation (#23133)
Fixes test failure in the last commit.
2021-06-30 14:23:20 +02:00
Marius van der Wijden
acdf9238fb
ethclient/gethclient: RPC client wrapper for geth-specific API (#22977)
This commit adds the package gethclient which is similar to the ethclient
and implements some geth specific functionality.

Co-authored-by: Edgar Aroutiounian <edgar.factorial@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2021-06-30 11:03:01 +02:00
Péter Szilágyi
7a7abe3de8
accounts/abi/bind: fix bounded contracts and sim backend for 1559 (#23038)
* accounts/abi/bind: fix bounded contracts and sim backend for 1559

* accounts/abi/bind, ethclient: don't rely on chain config for gas prices

* all: enable London for all internal tests

* les: get receipt type info in les tests

* les: fix weird test

Co-authored-by: Martin Holst Swende <martin@swende.se>
2021-06-15 13:56:14 +03:00
meowsbits
aa8b2189c6
ethclient: fix error handling for header test (#22514)
The wantErr field was disused, and the error returned by HeaderByNumber
was not properly tested.

This simplifies the error checking using errors.Is and asserts that getting
an expected missing header returns ethereum.NotFound. Also adds a nil
check condition for header.Number before using big.Int's Sign method.
2021-03-19 11:14:23 +01:00
lightclient
bbfb1e4008
all: add support for EIP-2718, EIP-2930 transactions (#21502)
This adds support for EIP-2718 typed transactions as well as EIP-2930
access list transactions (tx type 1). These EIPs are scheduled for the
Berlin fork.

There very few changes to existing APIs in core/types, and several new APIs
to deal with access list transactions. In particular, there are two new
constructor functions for transactions: types.NewTx and types.SignNewTx.
Since the canonical encoding of typed transactions is not RLP-compatible,
Transaction now has new methods for encoding and decoding: MarshalBinary
and UnmarshalBinary.

The existing EIP-155 signer does not support the new transaction types.
All code dealing with transaction signatures should be updated to use the
newer EIP-2930 signer. To make this easier for future updates, we have
added new constructor functions for types.Signer: types.LatestSigner and
types.LatestSignerForChainID. 

This change also adds support for the YoloV3 testnet.

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
2021-02-25 15:26:57 +01:00
gary rong
098a2b6e26
eth: move eth.Config to a common package (#22205)
This moves the eth config definition into a separate package, eth/ethconfig. 
Packages eth and les can now import this common package instead of
importing eth from les, reducing dependencies.

Co-authored-by: Felix Lange <fjl@twurst.com>
2021-02-05 13:51:15 +01:00
Marius van der Wijden
889f5645b5
ethclient: better test suite for ethclient package (#22127)
This commit extends the ethclient test suite and increases code coverage of the ethclient
package from ~15% to >55%. These tests act as early smoke tests to signal issues in the
RPC-interface. E.g. if a functionality like eth_chainId or eth_call breaks, the test
will break.
2021-01-08 21:29:25 +01:00
Mason Fischer
cf2a77af28
ethclient: fix BlockNumber (#21565)
It didn't actually work because it called a method that doesn't
exist. This fixes it also adds a test.

Co-authored-by: Felix Lange <fjl@twurst.com>
2020-09-15 11:29:51 +02:00
Dan Sosedoff
1167639524
ethclient: add BlockNumber method (#21500)
This adds a new client method BlockNumber to fetch the most recent
block number of the chain.
2020-09-10 14:24:21 +02:00
rene
c0c01612e9
node: refactor package node (#21105)
This PR significantly changes the APIs for instantiating Ethereum nodes in
a Go program. The new APIs are not backwards-compatible, but we feel that
this is made up for by the much simpler way of registering services on
node.Node. You can find more information and rationale in the design
document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775.

There is also a new feature in Node's Go API: it is now possible to
register arbitrary handlers on the user-facing HTTP server. In geth, this
facility is used to enable GraphQL.

There is a single minor change relevant for geth users in this PR: The
GraphQL API is no longer available separately from the JSON-RPC HTTP
server. If you want GraphQL, you need to enable it using the
./geth --http --graphql flag combination.

The --graphql.port and --graphql.addr flags are no longer available.
2020-08-03 19:40:46 +02:00
Sammy Libre
7163a6664e
ethclient: serialize negative block number as "pending" (#21177)
Fixes #21175

Co-authored-by: sammy007 <sammy007@users.noreply.github.com>
Co-authored-by: Adam Schmideg <adamschmideg@users.noreply.github.com>
2020-07-21 10:51:15 +02:00
Felix Lange
c013192ba7 ethclient: remove use of common.ToHex (#20326) 2019-11-19 15:53:26 +02:00
Felix Lange
2b54666018 ethclient, internal/ethapi: add support for EIP-695 (eth_chainId) (#19694)
EIP-695 was written in 2017. Parity and Infura have support for this
method and we should, too.
2019-06-11 14:12:33 +03:00
Dmitry Shulyak
15f24ff189 ethclient: ensure tx json is not nil before accessing it (#19653)
TransactionInBlock crashed if json was nil and there was an error
because it tried to access fields `From` and `BlockHash` of the nil object.
2019-06-03 17:52:02 +02:00
Martin Holst Swende
5036992b06 eth, les: add error when accessing missing block state (#18346)
This change makes getBalance, getCode, getStorageAt, getProof,
call, getTransactionCount return an error if the block number in
the request doesn't exist. getHeaderByNumber still returns null
for missing headers.
2019-05-02 14:50:23 +02:00
tamirms
b16cc501a8 ethclient: include block hash from FilterQuery (#17996)
ethereum/go-ethereum#16734 introduced BlockHash to the FilterQuery
struct. However, ethclient was not updated to include BlockHash in the actual
RPC request.
2018-11-08 13:26:47 +01:00
Steven Roose
69c52bde3f ethclient: fix RPC parse error of Parity response (#16924)
The error produced when using a Parity RPC was the following:

ERROR: transaction did not get mined: failed to get tx for txid 0xbdeb094b3278019383c8da148ff1cb5b5dbd61bf8731bc2310ac1b8ed0235226: json: cannot unmarshal non-string into Go struct field txExtraInfo.blockHash of type common.Hash
2018-06-11 10:41:09 +03:00