Commit Graph

1584 Commits

Author SHA1 Message Date
1408309b74 feat(net): add active session type (#169)
* refactor(net): unify capability types

* refactor(net): unify capability types

* feat(net): add active session type
2022-11-07 23:15:38 +01:00
caad026c70 refactor: rename HeaderLocked to SealedHeader (#173) 2022-11-07 21:06:53 +01:00
5721262740 refactor(net): unify capability types (#168)
* refactor(net): unify capability types

* refactor(net): unify capability types
2022-11-07 18:04:17 +01:00
b7cdfbf4f9 feat(net): network scaffolding (#110)
* feat(net): network scaffolding
2022-11-07 09:27:08 +01:00
ca2b5ef7c7 style(p2p): simplify pinger (#165)
* style(p2p): simplify pinger

* update docs
2022-11-04 15:01:50 +01:00
5cb2c6e615 style(p2p): get rid of expects (#164)
* style(p2p): get rid of expects

* test: add test
2022-11-04 14:51:13 +01:00
9b74d7d39d feat(eth-wire): use UnauthedEthStream to create EthStream (#162)
* Create UnauthedEthStream

* remove authed flag from EthStream

* encode and decode in status handshake

 * update test to assert the proper status is communicated

* cargo fmt

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
2022-11-04 08:36:40 +01:00
43a0a2b160 feat(eth-wire): return Hello on handshake (#161)
* feat(eth-wire): return Hello on handshake

* update P2PStream docs based on new auth design

* cargo fmt

* make clippy happy
2022-11-04 08:14:41 +01:00
ccdf2ffa92 hotfix(eth-wire): loosen lints temporarily 2022-11-03 12:43:19 -07:00
699db03187 feat(db): db error handling and Provider scaffolding (#154)
* feat(db): db error handling and Provider scaffolding
* remove one map_err
* fix after merge
2022-11-03 17:00:58 +01:00
bff27a4154 fix(rpc): type encoding (#155)
* fix(rpc): type encoding

* copy bytes from ethers
2022-11-03 03:04:09 -07:00
3c72a12aff feat(eth-wire): Implement p2p stream (#114)
* wip: p2pstream

* add comment for handshake timeout

* temp allow some lint violations

* ignore unused_variables

* start of ping task

 * TODO: make it compile
 * TODO: test ping/pong/disconnect state machine
 * TODO: send subprotocol messages to stream
 * TODO: encode non-hello p2p messages as snappy encoding without using
   an encoder
 * TODO: create test comparing encoder to hand-written snappy encoding
   for ping, pong, disconnect messages

* implement message handling in stream poll method

 * restricts S to be Stream+Sink for P2PStream to implement Stream
 * start of a poll-based refactor

* impl Stream and Sink for P2PStream

 * add tests
 * TODO: make stream/sink types compatible
 * TODO: handshake message ids
 * TODO: inner poll fn
 * TODO: pinger interval
 * TODO: ethstream test
 * TODO: passthrough test

* create pingers and test

* impl working timeout interval pinger

 * it should be much easier to poll for pings and detect timeouts now

* use pinger in p2p stream

 * change item produced by stream so it's compatible with EthStream
   * add note on pros/cons
 * shorten message sends in stream

* improve errors and remove redundant methods

* fix handshake

* debugging printlns

* fix encoding and decoding

 * switch to snappy formatting for non-hello p2p messages

* cargo fmt

* perform handshake in ethstream over p2pstream test

 * remove check for `Hello` messages outside of the handshake because
   `P2PStream`s should assume messages sent in the sink are subprotocol
   messages, not `p2p` messages.

* impl From<EthVersion> for CapabilityMessage

* remove printlns

* add total_message method to EthVersion

* decode Hello in handshake

 * disallow protocol versions other than v5

* Integrate snappy and implement message size limits

* document constants, move stream definition

* fix missing hello message id

* implement shared capabilities

 * todo: test shared capabilities
 * todo: determine how / when / why to support multiple capabilities
 * removes obsolete authed and offset fields

* add sink api TODOs

* remove les

 * should add protocols when necessary rather than name unsupported
   protocols

* fix snappy compression length

 * add test for p2pstream over a passthrough codec which tests that
   peers agree on a single shared capability

* fix some clippy lints
2022-11-03 00:01:54 -07:00
ac2f3fcd8a feat: Consensus crate and verification functions. (#152)
* wip executor

* wip

* Cleanup added some checks and structure to executor

* adding additional block/header checks

* add basefee calculation and check

* some cleanup

* Sanity check test

* Test for sanity check

* move verification to consensus crate

* cleanup

* Better Error handling
2022-11-02 12:59:51 +01:00
6c0e2753dd test: add mock discovery testing (#139) 2022-10-26 14:33:13 +02:00
61b8829bdf feat(sync): headers stage (#126)
* port headers stage

* clean up, utils & tests

* more tests

* unwind cleanup & tests

* remove unused rand crate
2022-10-25 16:50:01 -07:00
ce64fefd78 feat(net): add discv4 crate (#113)
* port kad

* feat: port kad bucket

* feat: add discv4

* chore: rustfmt

* cargo update

* just reuse discv5 table

* test: add rlp tests

* message encoding

* feat: impl codec roundtrip testing

* more work in message handling

* implement ping

* feat: impl commands

* cleanup

* more cleanup

* trim config

* more docs

* feat: implement recursive lookup

* docs

* cleanup config

* feat: implement update stream

* chore: config cleanup

* docs: add crate docs

* feat: more testing

* fix deny

* clarify ring

* docs: more docs

* use discv5 master

* docs: address review and add comments

* update readme

* rustmft

* chore(clippy): make clippy happy
2022-10-25 14:23:24 +02:00
2a8189d7c9 chore(db): Add tests and fuzz target to BlockNumHash (#130)
* add tests and fuzz target for BlockNumHash

* use block 1 for test_block_num_hash

* new clippy stds

* fmt
2022-10-25 01:23:10 -07:00
15bd88e637 headers(part2) - feat: add Downloader trait and test utils (#118)
* feat(interfaces): implement header client traits

* feat: add downloader trait implementer

* feat: use explicit error type instead of ok(false)

* feat: add constructor to HeaderLocked

* test: scaffold mock consensus, downloader and headersclient helpers

* test: implement test consensus

* test: implement test headers client

* refactor: cleanup download headers

* chore: fix lint

* s/test_utils/test_helpers

* headers(part 3) feat: implement Linear downloader (#119)

* feat: add headers downloaders crate

* feat: more scaffolding

* interfaces: generalize retryable erros

* feat: implement linear downloader

* fix linear downloader tests & add builder

* extend & reverse

* feat: linear downloader generics behind arc and reversed return order (#120)

* put client & consensus behind arc and return headers in rev

* cleanup

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>

* extract test_utils

* cargo fmt

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
2022-10-24 04:56:43 -07:00
c277015f5c feat(eth): add remaining eth protocol message types (#82)
* chore: port over remaining types from ethp2p

https://github.com/Rjected/ethp2p/

* replace fastrlp with reth_rlp

* use correct type for tx messages

 * encoding / decoding still todo

* derive Default for AccessList

* export receipts

 * also add Hash to more types

* fix receipts tests

* remove unused receipts test imports

* add convenience methods on transaction

* add block body

* move blockbody to eth-wire, uncomment wire type

* uncomment rest of messages

 * TODO: refactor tests and make tests pass

* use U128 instead of Uint for td

* expose wire types

* use reth_eth_wire instead of ethp2p

* expose Signature

* refactor pooled transaction tests

* fix hash calculation

 * do not hash the entire buffer

* uncomment block test and make clippy happy

* module-level documentation for message types

 * apply a clippy fix

* cargo fmt

* actually make clippy happy

* use H256 instead of [u8; 32]

 * use partition in split_transaction_by_hashes instead of peekable

Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
2022-10-19 23:24:50 -04:00
4298e3aa87 feat(rpc): more rpc scaffolding (#99)
* feat(rpc): more rpc scaffolding

* use Into<String>

* rm unused error
2022-10-19 22:12:53 +02:00
8009d997c0 Implement ETH P2P (#81)
* refactor: move things to types

* feat(ethwire): bring in message type from ethp2p

30c11138d5/src/message.rs

* feat(ethwire): add eth-stream with Stream/Sink impls

* feat(ethwire): make Sink error an EthStreamError

* feat(ecies): expose util module

* add more deps

* feat: add broadcast newblockhashes

* fix: rlp serialize with message-id first

* chore: cleanup doc

* wip: test eth connection

* bump cargo lock

* feat: add rlp codec and get stream tests working

* fix: convert RlpCodec to PassthroughCodec

we were rlp encoding twice

* Revert "fix: convert RlpCodec to PassthroughCodec"

This reverts commit 6e6e0a58112c14d7ffba62dc83f9747ddc280641.

This does not handle framing, which would fail decoding if a partial
write happened to the socket.

* add tracing

* refactor: add handshake error

* feat(ethwire): add status handshake

* test(ethwire): handshake works

* refactor: expose EthStream::new

* chore: clippy lints

* fix: get rid of rlp codec

we can instead use LengthLimitedCodec from Tokio IO, which we re-export
as PassthroughCodec

* fix(eth): add handshake + msg error checks

1. 10MB message lengths
2. Same Genesis, Version, Chain on Status Handshake

* chore: ignore result_large_err

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
2022-10-16 20:10:25 -07:00
5dfe5ac29b feat(net): add Framed ECIES implementation (#80)
* feat(net): add ecies crate

* cargo fmt

* add hex-literal and proptest to dev-dependencies

 * adds std feature to reth-rlp

* document util

* document more

* chore: allow missing docs in ecies/algorith.rs

* feat(ecies): improve error handling

remove anyhow and strictly type all errors

* refactor(ecies): movem ingress/egress to lib.rs

* chore(ecies): allow missing docs in mac

* chore(ecies): cleanup utils

* refactor(ecies): move ECIES Codec to separate file

* refactor(ecies): rename proto to stream

* add test scaffold

* implement server/client read/write test

* chore: clippy / fmt

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
2022-10-15 18:20:17 -07:00
533c3ebe98 feat(rpc): add EthApiServer impl skeleton (#75) 2022-10-14 12:01:00 -07:00
a644318c32 feat(p2p): Include forkid file from apache licenced repo (#68)
* Start using reth-rlp
* Include apache licenced forkid file in primitives
* Move forkid to eth-wire
2022-10-14 16:52:59 +02:00
8eb2ea4152 feat(rpc): add rpc-api client feature (#33)
* feat(rpc): add rpc-api client feature

* refactor: combine proc macro

* feat: add missing deserialize functions

* add missing derive
2022-10-11 11:56:12 +02:00
230e9ef179 feat(p2p): add anchor file for discovery state (#11)
* feat(p2p): add anchor file for discovery state

* move rustdoc and improve error messages

Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>

* add temp file tests and log drop error

 * fix error due to lack of read option
 * fix empty and nonexistent file error

* remove redundant new

* replace println with tracing

* show underlying error in custom error message

* chore: cargo fmt

* change AsRef<Path> to &Path

* remove ineffective dedups

* chore: cargo fmt

* switch out Vec<Enr<K>> for HashSet<Enr<K>>

* cargo fmt

* use tempdir instead of of std::env::temp_dir

* refactor anchor to contain &Path instead of File

 * change new_from_file to explicitly include logic for opening existing
   files, rather than calling out to from_toml
 * remove from_toml because new_from_file handles existing files
   properly with only a path. It is not possible to obtain a Path from a
   File anyways, its only purpose was to accept a File type

* use PathBuf instead of Path

Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
2022-10-10 13:02:54 -04:00
d7c8b70cc3 feat: add eth-wire (#20) 2022-10-10 09:46:02 -07:00
bc30cbce61 Skeleton primitives and interface crate (#13)
* wip interface primitives

* wip

* Integrate it inside rpc- crates

* fmt

* move tx to mod.rs

* Add interfaces, executor to toml

* Added nits, comments fix
2022-10-06 14:48:57 +02:00
14d0b6ac4e fix: make everything compile again 2022-10-03 15:36:13 +02:00
9251b286d0 feat: add engine api types and interface 2022-10-03 15:31:08 +02:00
8b7bef4f48 feat: add debug functions 2022-10-03 15:18:22 +02:00
eeda03a3f3 feat: add missing eth_ functions 2022-10-03 15:06:58 +02:00
5e0315cce0 move crates into net 2022-10-03 13:40:26 +02:00
6ff7cf5a74 feat: add p2p crate (#4)
* feat: add p2p crate

* move p2p to net subfolder

* add lib.rs and Cargo.toml to net

* remove net crate, use explicit names in workspace
2022-09-30 09:27:52 -07:00