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