Commit Graph

32 Commits

Author SHA1 Message Date
Adam Spitz 58284ffeda
Attempt to connect to many peers concurrently, not in sequence. (#575)
The old code, which did it in sequence, made it take a very long
time to accumulate peers in the peer pool, particularly because
occasionally a connection-attempt would hang for a couple of minutes
before timing out.
2023-01-04 05:56:23 -05:00
Kim De Mey 522db295f2
Fix RLP deserialzation for Enum with holes (#554)
RLP Enum deserialization would currently not check if "hole values"
were attempted to be converted to the enum type. Now use
checkedEnumAssign and fail with RlpTypeMismatch on invalid values.

There is at least one occurance of an enum with holes in rlpx p2p:
DisconnectionReason. For this enum the issue could occur.

Also:
- Added enum RLP tests and rlpx p2p disconnect message tests to
test the DisconnectionReason with enum hole value.
- Fixed worse custom DisconnectionReason decoding occurance
in rlpx in waitSingleMsg proc where this issue could occur.
2022-11-14 15:49:37 +01:00
Kim De Mey 9b0f054b04
Tackle some Nim warnings new since Nim 1.4 & 1.6 (#553) 2022-11-10 16:32:57 +01:00
andri lim 10870d8b15
Revert #544 "Fix related to nim devel branch" (#551)
This reverts commit:
5d13052dd9
e1bdf1741a
d238693571
2022-11-09 18:57:04 +01:00
jangko e1bdf1741a
refactor p2pProtocol internals
Nim devel brach(1.7.1) introduce gc=orc as default mode.
Because the p2p protocol using unsafe pointer operations
for it's ProtocolInfo and using global variables scattered
around, the orc mistakenly(or maybe correctly) crash the protocol.
2022-11-08 09:41:45 +07:00
Kim De Mey fef47331c3
Networkid common (#547)
* Move NetworkId type to common eth_types

NetworkId is after all a common type and this way it avoid an
application that requires it to also import all devp2p related
network types.

RLP related calls are moved to eth_types_rlp, this means that p2p
protocols that send NetworkId over the wire need to import this
too. Or just common in general.

* Remove # in front of multiline comment end bracket

These seem to be interpreted wrongly by the GitHub code browser.
2022-10-20 08:49:20 +02:00
jangko ae616935c3
move eth1 specific code to where it belongs 2022-10-11 14:52:25 +07:00
Jacek Sieka d31abca010
clean up eth_types (#531)
`eth_types` is being imported from many projects and ends up causing
long build times due to its extensive import lists - this PR starts
cleaning some of that up by moving the chain DB and RLP to their own
modules.

this PR also moves `keccakHash` to its own module and uses it in many
places.
2022-09-02 16:57:52 +02:00
Jacek Sieka 1b516682bd
bearssl: use split api (#510) 2022-06-17 22:45:37 +02:00
Jordan Hrycaj 00ed6ad312
Dedicated RLP reader for `DisconnectionReason` (#507)
* Provide dedicated `DisconnectionReason` enum type RLP reader

why:
  Without this reader, the program communicating via RLPX will crash when
  receiving out of bound reason codes disconnect message.

  Out of bound value assignments to an enum causes a `RangeError`defect
  and consequently the program to terminate. This `RangeError` is avoided
  here and a `MalformedRlpError` catchable error raised.

* Using default exception type in bespoke `read(DisconnectionReason)`

why:
  This should not differ from the default enum parser. The particular
  message is different and more targeted, here.

  Note: The default RLP parser was not used because `
  `array[1,DisconnectionReason]` is currently not properly handled and
  should give a siliar error message as a `DisconnectionReason` error.

* De-clutter, custom read() was not needed

Co-authored-by: jordan <jordan@curd.mjh-it.com>
2022-05-26 10:23:40 +01:00
Kim De Mey e62fdfe6f1
Add bind ip and bind port for eth1 rlpx and discovery protocols (#485)
Includes some small refactor on usage of result and Nim style
according to style guide.
2022-03-15 18:08:15 +01:00
kdeme 81f0a56ebd
Add/update bunch of license headers 2021-05-11 09:37:33 +02:00
kdeme 755729c6a1
Fix several compiler warnings
Mostly replacing deprecated calls
2021-05-11 09:24:23 +02:00
kdeme 90b4724492
Adjust for chronosStrictException usage in rest of eth/p2p 2021-05-06 17:20:54 +02:00
Kim De Mey 762415319c
Add build_dcli target and add it to CI (#344)
* Add build_dcli target and add it to CI

* Fix local imports for dcli

* And use local imports for all other files too

* Use local imports in tests and rlpx protocols
2021-04-06 13:33:24 +02:00
Kim De Mey 0be863d2de
Add raises annotations to make exception tracking work (#336)
See https://github.com/status-im/nim-chronos/pull/166
2021-03-24 12:52:09 +01:00
jangko dda2bec8aa turn networkId into distinct uint 2021-02-13 17:43:17 +07:00
Jacek Sieka 484fbcab1b
use bearssl rng throughout (#265)
* use bearssl rng throughout

* seeder can fail

* imports and exports

* modules, sigh

* one more try

* move var

* even fewer thread vars

* remove out-of-date genrated files
2020-07-07 10:56:26 +02:00
Jacek Sieka 1646d78d83
cleanups (#226) 2020-04-18 10:17:59 +02:00
Jacek Sieka 0b110f3287
Secp more refactor (#211)
* simplify some modules

* mark several modules with raises
* fix clearing of keys in auth.nim
* fix keyfile case dropping off
* fix keyfile stream storage
* uuid should be output in lowercase

* enode: simplify API
2020-04-06 18:24:15 +02:00
Zahary Karadjov e4ec051fc6
Take advantage of the new shared DSL helpers to simplify the RLPx back-end implementation 2019-06-24 05:12:22 +03:00
Zahary Karadjov 76bb2cde5c
More shared code extracted out of RLPx 2019-06-24 05:12:22 +03:00
Zahary Karadjov f761889518
Refactored the p2pProtocol macro to eliminate most code duplication in the backends 2019-06-24 05:12:22 +03:00
kdeme 442c3d9f7b More whisper changes (#43)
* Make messages with invalid ID a catchable error as we should not disconnect on this

* Add unimplemented message IDs used by Status

* Make whisper log less verbose + add comment on duplicate messages

* Cleanup + add documentation
2019-04-26 07:36:54 -06:00
kdeme 7cdd31e982 Add option to set specific protocol for observer 2019-04-18 17:17:57 +02:00
Zahary Karadjov dc2b6170b5 Improved error-handling; Timeouts in all handshakes 2019-03-26 17:32:17 +02:00
Jacek Sieka cbe67720ce
use Moment for tracking timeouts (#25)
* use Moment for tracking timeouts
* Use the new Duration type throughout RLPx
2019-03-25 11:32:18 -06:00
Zahary Karadjov f0bf0570d1 Support compiling with json logging; Drop package_visible_types 2019-03-25 02:10:09 +02:00
Jacek Sieka a69e52bf3e
bind to any address for listening (#20) 2019-03-19 12:15:16 -06:00
Zahary Karadjov 3efec171a6 Make the APIs compatible with libp2p
Lib2P2 handles RPC requests and responses with separate streams
while DEV2P2 is relying on tagged messages transmitted over a
single stream. To cover both models through the same application
code, we introduce a new `response` variable in the request handlers.
The user is supposed to issue a call to `response.send` in order to
reply to the request. Please note that the `response.send` signature
is strongly typed and depends on the current message.
2019-03-12 13:36:39 +02:00
Mamy Ratsimbazafy 07cf801b97
Rebrand asyncdispatch2 to chronos (#2)
* Rebrand asyncdispatch2 to chronos

* fix nimble path to chronos
2019-02-06 17:01:04 +01:00
Yuriy Glukhov e75a00f86e Moved eth-p2p to eth 2019-02-05 17:40:29 +02:00