post-merge nrpc fix (#2685)
* post-merge nrpc fix * bump * bump * bump * bump * bump * bump * bump * bump * bump * bump * bump
This commit is contained in:
parent
9192aa13ed
commit
ce331b4de8
|
@ -53,7 +53,7 @@ func toLogs(list: openArray[LogObject]): seq[Log] =
|
|||
result.add Log(
|
||||
address: ethAddr x.address,
|
||||
data: x.data,
|
||||
topics: toTopics(x.topics)
|
||||
topics: x.topics
|
||||
)
|
||||
|
||||
proc txReceipt*(client: RpcClient, txHash: common.Hash256): Future[Option[Receipt]] {.async.} =
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import
|
||||
std/[typetraits],
|
||||
chronicles,
|
||||
web3/primitives as web3types,
|
||||
web3/eth_api_types,
|
||||
web3/engine_api_types,
|
||||
|
@ -51,9 +52,6 @@ proc `$`*(x: Opt[PayloadID]): string =
|
|||
if x.isNone: "none"
|
||||
else: x.get().toHex
|
||||
|
||||
proc `$`*(x: Web3Quantity): string =
|
||||
$distinctBase(x)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Web3 defaults
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -403,3 +401,5 @@ func ethRequests*(p: ExecutionPayload): Opt[seq[Request]] =
|
|||
res.add ethRequest(x)
|
||||
|
||||
ok(res)
|
||||
|
||||
chronicles.formatIt(Quantity): $(distinctBase it)
|
|
@ -13,7 +13,7 @@ import
|
|||
chronicles,
|
||||
metrics,
|
||||
chronos/timer,
|
||||
std/[os, strformat, strutils],
|
||||
std/[strformat, strutils],
|
||||
stew/io2,
|
||||
beacon_chain/era_db,
|
||||
beacon_chain/networking/network_metadata,
|
||||
|
@ -33,33 +33,6 @@ declareCounter nec_imported_gas, "Gas processed during import"
|
|||
|
||||
var running {.volatile.} = true
|
||||
|
||||
func shortLog(a: timer.Duration, parts = int.high): string {.inline.} =
|
||||
## Returns string representation of Duration ``a`` as nanoseconds value.
|
||||
var
|
||||
res = ""
|
||||
v = a.nanoseconds()
|
||||
parts = parts
|
||||
|
||||
template f(n: string, T: Duration) =
|
||||
if v >= T.nanoseconds():
|
||||
res.add($(uint64(v div T.nanoseconds())))
|
||||
res.add(n)
|
||||
v = v mod T.nanoseconds()
|
||||
dec parts
|
||||
if v == 0 or parts <= 0:
|
||||
return res
|
||||
|
||||
f("w", Week)
|
||||
f("d", Day)
|
||||
f("h", Hour)
|
||||
f("m", Minute)
|
||||
f("s", Second)
|
||||
f("ms", Millisecond)
|
||||
f("us", Microsecond)
|
||||
f("ns", Nanosecond)
|
||||
|
||||
res
|
||||
|
||||
proc importBlocks*(conf: NimbusConf, com: CommonRef) =
|
||||
proc controlCHandler() {.noconv.} =
|
||||
when defined(windows):
|
||||
|
@ -191,7 +164,7 @@ proc importBlocks*(conf: NimbusConf, com: CommonRef) =
|
|||
avgBps = f(imported.float / diff0),
|
||||
avgTps = f(txs.float / diff0),
|
||||
avgMGps = f(gas.float / 1000000 / diff0),
|
||||
elapsed = shortLog(time2 - time0, 3)
|
||||
elapsed = toString(time2 - time0, 3)
|
||||
|
||||
metrics.set(nec_import_block_number, int64(blockNumber))
|
||||
nec_imported_blocks.inc(blocks.len)
|
||||
|
|
|
@ -218,7 +218,7 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
|
|||
payloadResponse = await rpcClient.newPayload(
|
||||
payload,
|
||||
versioned_hashes,
|
||||
primitives.FixedBytes[32] forkyBlck.message.parent_root.data,
|
||||
forkyBlck.message.parent_root.to(Hash32),
|
||||
)
|
||||
notice "Payload status", response = payloadResponse
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ func pp*(a: Opt[EthAddress]): string =
|
|||
func pp*(a: openArray[EthAddress]): string =
|
||||
"[" & a.mapIt(it.pp).join(" ") & "]"
|
||||
|
||||
func pp*(a: Bytes8): string =
|
||||
func pp*(a: Bytes8|Bytes32): string =
|
||||
a.toHex
|
||||
|
||||
func pp*(a: NetworkPayload): string =
|
||||
|
|
|
@ -90,7 +90,7 @@ proc filtersMain*() =
|
|||
len(filteredLogs) == 0
|
||||
|
||||
test "Filter topics, specific topic at first position":
|
||||
let topic = w3Hash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic = bytes32("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
|
||||
let filteredLogs =
|
||||
filterLogs(
|
||||
|
@ -108,8 +108,8 @@ proc filtersMain*() =
|
|||
log.topics[0] == topic
|
||||
|
||||
test "Filter topics, specific topic at first position and second position":
|
||||
let topic = w3Hash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic1 = w3Hash("0x000000000000000000000000919040a01a0adcef25ed6ecbc6ab2a86ca6d77df")
|
||||
let topic = bytes32("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic1 = bytes32("0x000000000000000000000000919040a01a0adcef25ed6ecbc6ab2a86ca6d77df")
|
||||
|
||||
let filteredLogs =
|
||||
filterLogs(
|
||||
|
@ -128,8 +128,8 @@ proc filtersMain*() =
|
|||
log.topics[1] == topic1
|
||||
|
||||
test "Filter topics, specific topic at first position and third position":
|
||||
let topic = w3Hash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic1 = w3Hash("0x000000000000000000000000fdc183d01a793613736cd40a5a578f49add1772b")
|
||||
let topic = bytes32("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic1 = bytes32("0x000000000000000000000000fdc183d01a793613736cd40a5a578f49add1772b")
|
||||
|
||||
let filteredLogs =
|
||||
filterLogs(
|
||||
|
@ -151,8 +151,8 @@ proc filtersMain*() =
|
|||
log.topics[2] == topic1
|
||||
|
||||
test "Filter topics, or query at first position":
|
||||
let topic = w3Hash("0x4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef")
|
||||
let topic1 = w3Hash("0x526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b79236")
|
||||
let topic = bytes32("0x4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef")
|
||||
let topic1 = bytes32("0x526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b79236")
|
||||
|
||||
let filteredLogs =
|
||||
filterLogs(
|
||||
|
@ -171,11 +171,11 @@ proc filtersMain*() =
|
|||
log.topics[0] == topic or log.topics[0] == topic1
|
||||
|
||||
test "Filter topics, or query at first position and or query at second position":
|
||||
let topic = w3Hash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic1 = w3Hash("0xa64da754fccf55aa65a1f0128a648633fade3884b236e879ee9f64c78df5d5d7")
|
||||
let topic = bytes32("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
|
||||
let topic1 = bytes32("0xa64da754fccf55aa65a1f0128a648633fade3884b236e879ee9f64c78df5d5d7")
|
||||
|
||||
let topic2 = w3Hash("0x000000000000000000000000e16c02eac87920033ac72fc55ee1df3151c75786")
|
||||
let topic3 = w3Hash("0x000000000000000000000000b626a5facc4de1c813f5293ec3be31979f1d1c78")
|
||||
let topic2 = bytes32("0x000000000000000000000000e16c02eac87920033ac72fc55ee1df3151c75786")
|
||||
let topic3 = bytes32("0x000000000000000000000000b626a5facc4de1c813f5293ec3be31979f1d1c78")
|
||||
|
||||
let filteredLogs =
|
||||
filterLogs(
|
||||
|
|
|
@ -295,7 +295,7 @@ const
|
|||
NumTransactions = 17
|
||||
NumBlocks = 13
|
||||
feeRecipient = initAddr(401)
|
||||
prevRandao = EMPTY_UNCLE_HASH # it can be any valid hash
|
||||
prevRandao = Bytes32 EMPTY_UNCLE_HASH # it can be any valid hash
|
||||
|
||||
proc runLedgerTransactionTests(noisy = true) =
|
||||
suite "Ledger nesting scenarios":
|
||||
|
|
|
@ -378,7 +378,7 @@ proc opEnvMain*() =
|
|||
assembler:
|
||||
title: "EIP-4399 PrevRandao: EMPTY_UNCLE_HASH"
|
||||
setup:
|
||||
vmState.blockCtx.prevRandao = EMPTY_UNCLE_HASH
|
||||
vmState.blockCtx.prevRandao = Bytes32 EMPTY_UNCLE_HASH
|
||||
code:
|
||||
PrevRandao
|
||||
Stop
|
||||
|
|
|
@ -125,7 +125,7 @@ proc initEnv(envFork: HardFork): TestEnv =
|
|||
const
|
||||
amount = 1000.u256
|
||||
slot = 0x11.u256
|
||||
prevRandao = EMPTY_UNCLE_HASH # it can be any valid hash
|
||||
prevRandao = Bytes32 EMPTY_UNCLE_HASH # it can be any valid hash
|
||||
|
||||
proc runTxPoolPosTest() =
|
||||
var
|
||||
|
@ -173,7 +173,7 @@ proc runTxPoolPosTest() =
|
|||
test "validate TxPool prevRandao setter":
|
||||
var sdb = LedgerRef.init(com.db, blk.header.stateRoot)
|
||||
let val = sdb.getStorage(recipient, slot)
|
||||
let randao = Hash32(val.toBytesBE)
|
||||
let randao = Bytes32(val.toBytesBE)
|
||||
check randao == prevRandao
|
||||
|
||||
test "feeRecipient rewarded":
|
||||
|
@ -238,7 +238,7 @@ proc runTxPoolBlobhashTest() =
|
|||
test "validate TxPool prevRandao setter":
|
||||
var sdb = LedgerRef.init(com.db, blk.header.stateRoot)
|
||||
let val = sdb.getStorage(recipient, slot)
|
||||
let randao = Hash32(val.toBytesBE)
|
||||
let randao = Bytes32(val.toBytesBE)
|
||||
check randao == prevRandao
|
||||
|
||||
test "feeRecipient rewarded":
|
||||
|
|
|
@ -30,6 +30,9 @@ proc fromJson(T: type UInt256, n: JsonNode): UInt256 =
|
|||
else:
|
||||
UInt256.fromHex(hex)
|
||||
|
||||
template fromJson*(T: type Bytes32, n: JsonNode): Bytes32 =
|
||||
Bytes32(hexToByteArray(n.getStr, 32))
|
||||
|
||||
template fromJson*(T: type Hash256, n: JsonNode): Hash256 =
|
||||
Hash32(hexToByteArray(n.getStr, 32))
|
||||
|
||||
|
@ -109,7 +112,7 @@ proc parseHeader*(n: JsonNode): BlockHeader =
|
|||
gasLimit : required(GasInt, "currentGasLimit"),
|
||||
timestamp : required(EthTime, "currentTimestamp"),
|
||||
stateRoot : emptyRlpHash,
|
||||
mixHash : omitZero(Hash256, "currentRandom"),
|
||||
mixHash : omitZero(Bytes32, "currentRandom"),
|
||||
baseFeePerGas : optional(UInt256, "currentBaseFee"),
|
||||
withdrawalsRoot: optional(Hash256, "currentWithdrawalsRoot"),
|
||||
excessBlobGas : optional(uint64, "currentExcessBlobGas"),
|
||||
|
|
|
@ -55,6 +55,16 @@ template fromJson(T: type UInt256, n: JsonNode, field: string): UInt256 =
|
|||
template fromJson(T: type ChainId, n: JsonNode, field: string): ChainId =
|
||||
parseHexOrInt[uint64](n[field].getStr()).ChainId
|
||||
|
||||
proc fromJson(T: type Bytes32, n: JsonNode): Bytes32 =
|
||||
var num = n.getStr()
|
||||
num.removePrefix("0x")
|
||||
if num.len < 64:
|
||||
num = repeat('0', 64 - num.len) & num
|
||||
Bytes32(hexToByteArray(num, 32))
|
||||
|
||||
proc fromJson(T: type Bytes32, n: JsonNode, field: string): Bytes32 =
|
||||
fromJson(T, n[field])
|
||||
|
||||
proc fromJson(T: type Hash256, n: JsonNode): Hash256 =
|
||||
var num = n.getStr()
|
||||
num.removePrefix("0x")
|
||||
|
@ -174,7 +184,7 @@ proc parseEnv*(ctx: var TransContext, n: JsonNode) =
|
|||
required(ctx.env, BlockNumber, currentNumber)
|
||||
required(ctx.env, EthTime, currentTimestamp)
|
||||
optional(ctx.env, DifficultyInt, currentDifficulty)
|
||||
optional(ctx.env, Hash256, currentRandom)
|
||||
optional(ctx.env, Bytes32, currentRandom)
|
||||
optional(ctx.env, DifficultyInt, parentDifficulty)
|
||||
omitZero(ctx.env, EthTime, parentTimestamp)
|
||||
optional(ctx.env, UInt256, currentBaseFee)
|
||||
|
|
|
@ -52,7 +52,7 @@ type
|
|||
BCTEnv* = object
|
||||
currentCoinbase*: primitives.Address
|
||||
currentDifficulty*: UInt256
|
||||
currentRandom*: Opt[BlockHash]
|
||||
currentRandom*: Opt[Bytes32]
|
||||
parentDifficulty*: Opt[UInt256]
|
||||
currentGasLimit*: Quantity
|
||||
currentNumber*: Quantity
|
||||
|
@ -121,7 +121,7 @@ proc toBctEnv(parentBlock, currentBlock: EthBlock, hashes: BCTHashes): BCTEnv =
|
|||
result.currentNumber = w3Qty(current.number)
|
||||
result.currentTimestamp = Opt.some w3Qty(current.timestamp)
|
||||
result.currentDifficulty = current.difficulty
|
||||
result.currentRandom = Opt.some w3Hash(current.mixHash)
|
||||
result.currentRandom = Opt.some current.mixHash
|
||||
|
||||
# t8n should able to calculate these values itself if not supplied
|
||||
#result.currentBaseFee = current.baseFeePerGas
|
||||
|
|
|
@ -93,7 +93,7 @@ proc envToHeader(env: EnvStruct): BlockHeader =
|
|||
BlockHeader(
|
||||
coinbase : env.currentCoinbase,
|
||||
difficulty : env.currentDifficulty.get(0.u256),
|
||||
mixHash : env.currentRandom.get(default(Hash256)),
|
||||
mixHash : env.currentRandom.get(default(Bytes32)),
|
||||
number : env.currentNumber,
|
||||
gasLimit : env.currentGasLimit,
|
||||
timestamp : env.currentTimestamp,
|
||||
|
|
|
@ -30,7 +30,7 @@ type
|
|||
EnvStruct* = object
|
||||
currentCoinbase*: EthAddress
|
||||
currentDifficulty*: Opt[DifficultyInt]
|
||||
currentRandom*: Opt[Hash256]
|
||||
currentRandom*: Opt[Bytes32]
|
||||
parentDifficulty*: Opt[DifficultyInt]
|
||||
currentGasLimit*: GasInt
|
||||
currentNumber*: BlockNumber
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5ce3c4557fc78ee425fcb8f30f80cb336bbe0b7c
|
||||
Subproject commit 792b8b9bff09a5ed7cc98bc12b0c3d991e019b6f
|
|
@ -1 +1 @@
|
|||
Subproject commit b41316b25c77c525a2d33192a52958a6972b839d
|
||||
Subproject commit 62a0005b0907a64090827d4e5d691682587f5b2a
|
Loading…
Reference in New Issue