Commit Graph

945 Commits

Author SHA1 Message Date
Jacek Sieka 086ac68c86
Change `VersionedHash` to `Hash32` (#738)
This is closer to both the exeuction spec and api
2024-10-01 11:54:01 +02:00
Jacek Sieka 119c910a4e
remove remaining `int` holdouts in rlp (#737)
these were never well defined
2024-09-30 18:32:36 +02:00
Jacek Sieka b49df0a71a
remove binary tries (#736)
Binary tries were an early research idea but are no longer part of any
plausible etheruem roadmap, hence we remove them.
2024-09-30 12:59:16 +02:00
Jacek Sieka 00f5fb1fe0
clean up json serialization (#735)
serialize fewer non-eth types and more eth types - this module is
fraught with issues however since there's no one good "canonical"
encoding to choose - this goes back to the json ser framework lacking
good isolation between projects.
2024-09-30 10:34:47 +02:00
Jacek Sieka 6bd6bae86c
Align core types with execution spec (#733)
Since these types were written, we've gained an executable spec:

https://github.com/ethereum/execution-specs

This PR aligns some of the types we use with this spec to simplify
comparisons and cross-referencing.

Using a `distinct` type is a tradeoff between nim ergonomics, type
safety and the ability to work around nim quirks and stdlib weaknesses.

In particular, it allows us to overload common functions such as `hash`
with correct and performant versions as well as maintain control over
string conversions etc at the cost of a little bit of ceremony when
instantiating them.

Apart from distinct byte types, `Hash32`, is introduced in lieu of the
existing `Hash256`, again aligning this commonly used type with the spec
which picks bytes rather than bits in the name.
2024-09-29 10:52:19 +02:00
Jacek Sieka 3d51887c15
move signal ignore out of `eth/common` (#734)
`net/nat` is the only place where it is used and it certainly doesn't
belong in `common`
2024-09-24 11:30:05 +02:00
Miran 410eab5a16
update ci.yml to test Nim 2.2; also test gcc-14 (#730) 2024-09-24 05:23:32 +00:00
Kim De Mey aa1e738a97
Add discv5 constants to know allowed max talkresp message size (#732) 2024-09-19 17:53:11 +02:00
andri lim 4eecab27ef
Implement EIP-7702 Transaction and Receipt (#731)
* Implement EIP-7702 Transaction and Receipt
2024-09-13 13:37:43 +07:00
jangko 59715353db
Fix EIP-7865 types and RLP encoding 2024-09-10 20:31:07 +07:00
tersec 11eafac0f0
handle new UPnP return value (#728) 2024-09-10 05:10:08 +00:00
Kim De Mey f2568a64c0
Fix potential uTP clock drift overflow (#726) 2024-09-03 16:48:24 +02:00
Jordan Hrycaj 92c7bea807
Reassign logging weights in RLPx handler (#725)
why:
  Too much noise, updating sort of guided by
  https://github.com/status-im/nimbus-eth2/blob/unstable/docs/logging.md
2024-08-30 18:00:11 +00:00
Jordan Hrycaj 5ecbcb5886
Using unsigned types for message type and requst IDs (#722)
* Using unsigned types for message type and requst IDs

why:
  Negative values are neither defined for RLP nor in the protocol specs
  which refer to the RLPs (see yellow paper app B clause (199).

* Fix `int` argument (must be `uint`) in fuzzing tests

why:
  Not part of all tests so it slipped through.
2024-08-30 17:27:09 +00:00
Kim De Mey b874e12516
Differentiate log for invalid packet seqnr without reorder buffer and not (#723) 2024-08-29 18:15:26 +02:00
Jordan Hrycaj 98b2a34075
Fix rlpx hello crash caused by rlp decoder (#721)
* Restricting exception catcher

why:
  `CatchableError` is not needed here

* Check data length before converting to `openArray[]`

why:
  Getting the first entry of an `openArray[]` crashes with `IndexDefect`.
  This is particularly annoying when decoding messages in rlpx.

* Added unit test using rlpx message that causes this problem to detect
2024-08-19 11:38:46 +00:00
Etan Kissling cc6d88962e
Treat putting empty data in hexary trie as deleting data (#720)
Other implementations of MPT delete entries when attempting to put empty
value, because empty value cannot exist in RLP. We should match the
behaviour.

- https://github.com/ethereum/py-trie/pull/109

Also cross-checked with Geth and Ethereumjs implementations.
2024-08-14 23:48:39 +00:00
Jordan Hrycaj 9511502273
Removed obsolete chunked rlpx message protocol extension (#719) 2024-08-13 15:10:47 +00:00
Jacek Sieka 56f72c7a66
Revert speedups (#718)
* Revert "hash compatibility fix (#717)"

This reverts commit 047de2b788.

* Revert "port eth2_digest speedups to eth_hash (#716)"

This reverts commit 864d54467e.
2024-08-09 07:20:35 +02:00
Jacek Sieka 047de2b788
hash compatibility fix (#717) 2024-08-09 06:23:56 +02:00
Jacek Sieka 864d54467e
port eth2_digest speedups to eth_hash (#716)
* port eth2_digest speedups to eth_hash

* faster comparison
* `hash` integration
* lower-case printing
2024-08-08 05:44:15 +00:00
andri lim ebfe63b9b6
Convert GasInt to uint64 (#713) 2024-07-06 20:24:14 +07:00
Etan Kissling d8fda55c79
define Electra types and RLP encoding (#711)
Add types for EIP-6110, EIP-7002 and EIP-7251 validator operations.
2024-07-03 13:22:18 +02:00
Etan Kissling b90483e9d2
avoid warnings when processing `GasInt` for RLP (#712)
RLP does not support signed integer values, so we have to convert
`GasInt` to `uint64` when decoding / encoding via RLP.
2024-07-03 13:21:45 +02:00
Miran b80c227f52
simplify .nimble file (#708) 2024-07-01 18:06:10 +02:00
Kim De Mey 8088fe72d7
Update discv5 to use non deprecated ENR calls and simplify code (#710)
And due to avoiding an extra PublicKey.fromRaw call we get a
little performance boost also.
2024-06-27 16:18:21 +02:00
Kim De Mey d7577f59d7
Rework of ENR decoding code (#709)
- Rework to have exception raise only at rlp decoding and use
result types from then onwards
- Adjust the current API to have result versions and deprecated
the ones which had var Record + bool
- Add PublickKey to the Record object, as this allows us to skip
fromRaw calls whenever access is needed to the public key
- Add a TypedRecord.fromRecord which cannot fail and deprecate
the old one
- Some other minor clean-up & re-ordering
2024-06-27 15:15:23 +02:00
Kim De Mey 7f20d79945
Overhaul of ENR implementation - part I (#707)
- Rework adding and updating of fields by having an insert call
that gets used everywhere. Avoiding also duplicate keys. One
side-effect of this is that ENR sequence number will always get
updated on an update call, even if nothing changes.
- Deprecate initRecord as it is only used in tests and is flawed
- Assert when predefined keys go into the extra custom pairs.
Any of the predefined keys are only to be passed now via specific
parameters to make sure that the correct types are stored in ENR.
- Clearify the Opt.none behaviour for Record.update
- When setting ipv6, allow for tcp/udp port fields to be used
default
- General clean-up
- Rework/clean-up completely the ENR tests.
2024-06-24 14:57:39 +02:00
Kim De Mey 26212c881b
Use results.Opt instead of option in discv5, utp and nat (#705)
+ some other minor cleanups
2024-06-18 18:09:27 +02:00
Kim De Mey f169068df6
Fix missing CancelledError on discv5 waitMessage + results imports (#704)
Fixes a missing CancelledError async raising on discv5 waitMessage
which would cause "Error set on a non-raising future".

Also moves some more results import away from stew.
2024-06-13 12:11:25 +02:00
andri lim 7c952cf40e
Revert GasInt back to int64 (#703)
Turn out it requires more planning to switch GasInt to uint64
2024-06-13 12:11:16 +02:00
Kim De Mey 207244c2db
Add more missing async raises in uTP (#702) 2024-06-12 18:01:23 +02:00
andri lim 224048a1d5
Revert perPeerMsgIdVar type until it properly fixed (#701)
* Revert perPeerMsgIdVar type until it properly fixed

* Add reminder
2024-06-12 13:29:57 +07:00
andri lim 4cccf25af7
Reduce compiler warnings related to rlp encode int (#699) 2024-06-12 09:29:18 +07:00
andri lim 9b6497ed8a
GasInt, BlockNumber, fields name closer to the spec (#696) 2024-06-12 00:13:11 +07:00
Kim De Mey c3f9160fd2
Add async raises annotations for uTP code (#692)
* Add async raises annotations for uTP code

* Avoid compiler error + further clean-up
2024-06-11 13:56:37 +02:00
Kim De Mey 3d66c5b899
Fix ImplicitDefaultValue warnings + replace some obsolete inits (#697) 2024-06-10 21:19:25 +02:00
Kim De Mey 50e71b2daa
Add async raises annotations for discv5 (#690) 2024-06-10 13:47:35 +02:00
Jacek Sieka c9b545b6c4
No sink (#695)
https://github.com/nim-lang/Nim/issues/23354
2024-06-10 10:12:32 +02:00
Jacek Sieka 5599435901
ethblock: txs -> transactions (#694)
Using the same name as BlockBody to make them easily interchangeable -
* add a few inits
2024-06-08 19:25:25 +02:00
Jacek Sieka b9b522f7ac
keccak doesn't need `init` (#693) 2024-06-07 22:30:32 +02:00
Jacek Sieka c02e050db8
avoid `burnMem` for `keccakHash` (#691)
We don't need to clear keccak context after hashing ethereum data since
it is already public - similar to
https://github.com/status-im/nimbus-eth2/pull/222.

Because we overwrite the result fully, we also don't need to zero first.
2024-06-07 16:27:38 +02:00
Jacek Sieka d935c0de47
rlp: avoid or make faster seq copies (#689) 2024-06-06 20:27:43 +02:00
Jacek Sieka 68bd675b75
faster `hash` for `Address` (#688) 2024-06-05 22:46:23 +02:00
Jacek Sieka 0e83cfda97
results: use standalone repo (#687) 2024-05-30 14:46:57 +02:00
Jacek Sieka 50b3d0193c
Revert missing hexary trie node work (#686)
* Revert "In the incomplete-db node-existence check, don't use contains. (#603)"

This reverts commit 4b818e8307.

* Revert "Some changes to make hexary.nim better able to handle incomplete DBs (#602)"

This reverts commit f5dd26eac0.

* Revert "Added maybeGet, for working with incomplete DBs. (#595)"

This reverts commit 4754543605.
2024-05-28 10:05:57 +02:00
Jacek Sieka 258798873c
eth_types: remove unused ref types (#685)
remove unused ref types
2024-05-28 08:42:13 +02:00
Jacek Sieka bb5cb6a4d0
rlp: refresh code (#683)
A first step in cleaning up RLP, which has lots of interesting issues -
the next step would be to clean up the exception handling as well
(Resultify?)

* remove `RlpNode` (unused)
* single-pass parsing for most functionality via RlpItem
* stricter conformance to spec
  * remove float support
  * warn about signed integers
  * raise on invalid RLP earlier
* avoid several pointless allocations, in particular in `listLen`,
`listElem` etc
* include spec docs
2024-05-26 09:58:24 +02:00
Jacek Sieka 0addffcc6c
binary tries: remove (#684)
not used anywhere
2024-05-26 09:57:59 +02:00
Etan Kissling c482b4c5b6
Introduce wrapper type for EIP-4844 transactions (#682)
EIP-4844 blob sidecars are a concept that only exists in the mempool.
After inclusion of a transaction into an execution block, only the
versioned hash within the transaction remains. To improve type safety,
replace the `Transaction.networkPayload` member with a wrapper type
`PooledTransaction` that is used in contexts where blob sidecars exist.
2024-05-13 11:19:00 +03:00