mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 04:24:05 +00:00
Fix the build with RLPx
This commit is contained in:
parent
e639cd95c7
commit
2fca9465e7
@ -29,7 +29,7 @@ proc tryEmitting(peer: Peer, topic: string,
|
||||
msgId: string, msg: string): Future[void] {.gcsafe.}
|
||||
|
||||
p2pProtocol GossipSub(version = 1,
|
||||
shortName = "gss",
|
||||
rlpxName = "gss",
|
||||
peerState = GossipSubPeer,
|
||||
networkState = GossipSubNetwork):
|
||||
# This is a very barebones emulation of the GossipSub protocol
|
||||
|
@ -46,9 +46,9 @@
|
||||
|
||||
import
|
||||
sequtils,
|
||||
stew/objects, hashes, eth/rlp, nimcrypto/utils,
|
||||
stew/objects, hashes, nimcrypto/utils,
|
||||
blscurve, json_serialization,
|
||||
digest
|
||||
../version, digest
|
||||
|
||||
export
|
||||
json_serialization
|
||||
@ -257,7 +257,9 @@ else:
|
||||
proc newPrivKey*(): ValidatorPrivKey =
|
||||
SigKey.random()
|
||||
|
||||
# RLP serialization (TODO: remove if no longer necessary)
|
||||
when networkBackend == rlpxBackend:
|
||||
import eth/rlp
|
||||
|
||||
when ValidatorPubKey is BlsValue:
|
||||
proc append*(writer: var RlpWriter, value: ValidatorPubKey) =
|
||||
writer.append if value.kind == Real: value.blsValue.getBytes()
|
||||
@ -267,7 +269,7 @@ else:
|
||||
writer.append value.getBytes()
|
||||
|
||||
proc read*(rlp: var Rlp, T: type ValidatorPubKey): T {.inline.} =
|
||||
result fromBytes(T, rlp.toBytes)
|
||||
result.initFromBytes rlp.toBytes.toOpenArray
|
||||
|
||||
when ValidatorSig is BlsValue:
|
||||
proc append*(writer: var RlpWriter, value: ValidatorSig) =
|
||||
@ -278,7 +280,7 @@ else:
|
||||
writer.append value.getBytes()
|
||||
|
||||
proc read*(rlp: var Rlp, T: type ValidatorSig): T {.inline.} =
|
||||
let bytes = fromBytes(T, rlp.toBytes)
|
||||
result.initFromBytes rlp.toBytes.toOpenArray
|
||||
|
||||
proc writeValue*(writer: var JsonWriter, value: VerKey) {.inline.} =
|
||||
writer.writeValue($value)
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
import
|
||||
macros, hashes, math, json, strutils,
|
||||
stew/[byteutils, bitseqs], chronicles, eth/[common, rlp],
|
||||
../ssz/types, ./crypto, ./digest
|
||||
stew/[byteutils, bitseqs], chronicles, eth/common,
|
||||
../version, ../ssz/types, ./crypto, ./digest
|
||||
|
||||
# TODO Data types:
|
||||
# Presently, we're reusing the data types from the serialization (uint64) in the
|
||||
@ -71,6 +71,8 @@ const
|
||||
template maxSize*(n: int) {.pragma.}
|
||||
|
||||
type
|
||||
Bytes = seq[byte]
|
||||
|
||||
ValidatorIndex* = range[0'u32 .. 0xFFFFFF'u32] # TODO: wrap-around
|
||||
Shard* = uint64
|
||||
Gwei* = uint64
|
||||
@ -388,6 +390,16 @@ type
|
||||
data*: BeaconState
|
||||
root*: Eth2Digest # hash_tree_root (not signing_root!)
|
||||
|
||||
when networkBackend == rlpxBackend:
|
||||
import eth/rlp/bitseqs as rlpBitseqs
|
||||
export read, append
|
||||
|
||||
proc read*(rlp: var Rlp, T: type BitList): T {.inline.} =
|
||||
T rlp.read(BitSeq)
|
||||
|
||||
proc append*(writer: var RlpWriter, value: BitList) =
|
||||
writer.append BitSeq(value)
|
||||
|
||||
template foreachSpecType*(op: untyped) =
|
||||
## These are all spec types that will appear in network messages
|
||||
## and persistent consensus data. This helper template is useful
|
||||
@ -486,6 +498,7 @@ template ethTimeUnit(typ: type) {.dirty.} =
|
||||
proc `%`*(x: typ): JsonNode {.borrow.}
|
||||
|
||||
# Serialization
|
||||
when networkBackend == rlpxBackend:
|
||||
proc read*(rlp: var Rlp, T: type typ): typ {.inline.} =
|
||||
typ(rlp.read(uint64))
|
||||
|
||||
@ -593,4 +606,4 @@ static:
|
||||
|
||||
import nimcrypto, json_serialization
|
||||
export json_serialization
|
||||
export writeValue, readValue, append, read
|
||||
export writeValue, readValue
|
||||
|
@ -4,6 +4,10 @@ import
|
||||
spec/[datatypes, crypto, digest, helpers], eth/rlp,
|
||||
beacon_node_types, eth2_network, beacon_chain_db, block_pool, time, ssz
|
||||
|
||||
when networkBackend == rlpxBackend:
|
||||
import eth/rlp/options as rlpOptions
|
||||
template libp2pProtocol*(name: string, version: int) {.pragma.}
|
||||
|
||||
type
|
||||
ValidatorSetDeltaFlags {.pure.} = enum
|
||||
Activation = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user