Commit Graph

115 Commits

Author SHA1 Message Date
andri lim b736906dc7
Fix Authorization fields name to v, r, s (#749) 2024-10-15 14:09:16 +00:00
Miran bb76daa6d9
add missing type, fix typo, meaningful deprecations (#745) 2024-10-08 20:21:16 +02:00
Kim De Mey cea821df60
Add times_rlp and headers_rlp modules (#743) 2024-10-04 17:19:59 +02:00
Jacek Sieka 4ea11b9fb9
transaction signing helpers (#742)
Transaction signing is something that happens in a lot of places - this
PR introduces primitives for transaction signing in `transaction_utils`
such that we can use the same logic across web3/eth1/etc for this simple
operation.

`transaction_utils` also contains a few more "spec-derived" helpers for
working with transactions, such as the computation of a contract address
etc that cannot easily be introduced in `transactions` itself without
bringing in dependencies like secp and rlp, so they end up in a separate
module.

Finally, since these modules collect "versions" of these transaction
types across different eips, some tests are moved to follow the same
structure.
2024-10-04 13:46:58 +02:00
Jacek Sieka 5ce3c4557f
prevRandao -> Bytes32 (#740)
This one is a bit of a mess because it has different names and types
across specs :/
2024-10-02 13:00:10 +02:00
Jacek Sieka 70b7519f02
avoid typed return in generic template (#739) 2024-10-02 09:33:22 +02:00
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 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
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
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
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
andri lim 9b6497ed8a
GasInt, BlockNumber, fields name closer to the spec (#696) 2024-06-12 00:13:11 +07: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 68bd675b75
faster `hash` for `Address` (#688) 2024-06-05 22:46:23 +02:00
Jacek Sieka 258798873c
eth_types: remove unused ref types (#685)
remove unused ref types
2024-05-28 08:42:13 +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
Kim De Mey 2ad07a6010
Fix two bugs in Receipts RLP encoding/decoding (#672)
1. Fix Assertion error when receipt is not a List nor has a single
byte value. Receiving such garbage data would cause a crash.
2. Fix decoding of Receipt list by adding the missing Blob
encapsulation

Also added tests for these scenarios.
2024-02-05 23:22:15 +01:00
andri lim 1bae1d8426
Fix rlpHash of Transaction: remove EIP-4844 blobs before hashing (#643) 2023-10-22 14:37:49 +07:00
jangko e34a9c4e5d
Fix EthTime.now from func to proc due to sideeffects 2023-10-17 17:20:34 +07:00
jangko 2be8c183d1
Change EthTime from Time to distinct uint64
Cancun test vector demand a uint64 of block timestamp.
Therefore using std.Time will not able to pass test.
2023-10-17 16:00:57 +07:00
andri lim fe88d9e6b7
Change maxFeePerBlobGas from GasInt to UInt256 (#640)
* Change maxFeePerBlobGas from GasInt to UInt256

per latest spec:
https://eips.ethereum.org/EIPS/eip-4844#blob-transaction

* fix eip-4844 test
2023-09-24 14:33:24 +07:00
Etan Kissling 894ec07d9f
fix `{.raises.}` annotation to `writeValue` (#631)
`writeValue` doesn't raise `SerializationError`, so the `{.push.}`
is not optimal. Move `{.raises.}` to each `proc`, same as other modules.
2023-08-19 19:03:10 +02:00
jangko 074edff1b4
EIP-4788: Add parentBeaconBlockRoot field to BlockHeader 2023-08-18 17:52:55 +07:00
jangko 521db96a65
rename data gas to blob gas 2023-07-28 10:19:00 +07:00
jangko 6b8a7b009e
implement EIP-4844: Shard Blobs Transactions 2023-06-23 13:48:51 +07:00
jangko 6dacb2ca5c
fixes related to stint breaking changes 2023-06-21 17:55:00 +07:00
tersec c608426d03
add/change Deneb fields per https://github.com/ethereum/execution-apis/pull/417 (#616) 2023-06-03 18:47:55 +00:00
andri lim 91b2b9d2ed
rlp codec support optional fields (#613)
Instead of patching BlockHeader or BlockBody codec
each time it get additional optional fields,
this PR make the rlp codec automatically handle
optional fields. Thus rlp codec overloading of
EthBlock, BlockHeader, and BlockBody can be removed.
2023-05-30 16:02:02 +03:00
jangko 67bbd88616
Replace exception with assertion in rlp.append of BlockHeader
Using exception in rlp.append turn out creates more problem than it solve.
`blockHash` operation is literally everywhere in nimbus-eth1, nimbus-eth2, and fluffy-code.
The compiler begins to complain about unlisted exception.
Rlp bytes coming from network and test vectors already verified by the decoder.
So, any invalid optional fields of blockheader that come into rlp.append means
programming error. Assertion will be more apropiate in this situation and less problematic.
2023-05-25 15:27:37 +07:00
jangko 7ff6de2367
fix rlp.readRecordType of BlockBody and friends
including:
- fix rlp.append of BlockHeader
- add tests for rlp.readRecordType of BlockBody
- add tests for rlp.append of BlockHeader
- add tests for EthBlock roundtrip
2023-05-23 14:37:47 +07:00
jangko e639dc1e14
fix missing withdrawals field in EthBlock 2023-05-22 16:11:30 +07:00
Kim De Mey d57a1094b1
Remove all Defect raises to avoid unnecessary warnings (#607)
As this module dropped support for Nim versions < 1.6, all Defect
raises can be removed to avoid unnecessary warnings
2023-05-10 15:50:04 +02:00
tersec 7564b21ade
support only Nim 1.6+ (#606) 2023-05-09 20:19:44 +00:00
Jordan Hrycaj 9a1d35f803
Fix block body encoding (#598)
why:
  List wrapper was missing in `append()` mixin.
2023-04-19 13:26:41 +01:00
Adam Spitz 9e89f0dccc
Made rlp.readRecordType(BlockBody, false) include withdrawals. (#594) 2023-03-17 10:41:38 -04:00
Adam Spitz 20d2d318f0
Fixed a bug that I just introduced in the BlockBody RLP code. (#583)
The nimbus-eth1 tests seem to think that this is the right thing to do.
2023-01-21 14:41:30 +01:00
Adam Spitz 5b189ce5e2
EIP-4895: added withdrawals to BlockBody. (#581) 2023-01-20 12:18:39 +01:00
tersec 68f4c53828
withdrawals amount in uint64 gwei: https://github.com/ethereum/execution-apis/pull/354 (#577) 2023-01-14 14:39:23 +00:00
zah 0807378e7f
Migrate some functions from nimbus-eth1 in order to make them available in nimbus-eth2 (#576) 2023-01-10 18:56:27 +02:00