bump nim-web3 to bf1ce869b5f76d9744444b248f6f5c6c782fedc7 (#5722)
Etan Kissling (2): remove unused `skip0xPrefix` keep the internal count helper Will (1): Bugfix/nully values (#61) Yuriy Glukhov (5): Contract constructor support Fixed compilation error in exec function Added string encoding Fixed source->from field of EthCall More flexibility to contract DSL, Async contract caller jangko (5): Reduce compiler warnings when using Nim v2 Migrate to json-serialization Add tests of json rpc marshalled types Resolve contract_dsl ambiguity Event handler passing around JsonString instead of JsonNode Share encoder between json-rpc and chronicles (#119) Simplify generic constraint of rpc and chronicles encoders Feature/execution api spec (#69) v0.3.0 bump nim-json-rpc to a6475e49b26d3afc58aaa3d67621c94eafef8efb coffeepots (1): Use nim-json-serialization for RPCs (#172) jangko (10): Add copyright to source file Remove StringOfJson Fix optional parameter parsing fails in rpc macro with generics Rename jrpc_sys module back to jsonmarshal Reenable test hhtps Add test for createRpcSigsFromNim and createSingleRpcSig Let the OS choose the port for tests Add onProcessMessage hook to client Fix example in the README.md Move errors module back to json_rpc folder Upgrade rpc router internals (#178) RPC server handle null return value correctly v0.3.0 kdeme (1): Add example test case that currently fails the Option parsing
This commit is contained in:
parent
c815e71af0
commit
017f9f1103
|
@ -12,7 +12,7 @@ import
|
||||||
# Nimble packages:
|
# Nimble packages:
|
||||||
chronos, metrics, chronicles/timings,
|
chronos, metrics, chronicles/timings,
|
||||||
json_rpc/[client, errors],
|
json_rpc/[client, errors],
|
||||||
web3, web3/ethhexstrings, web3/engine_api,
|
web3, web3/[engine_api, primitives, conversions],
|
||||||
eth/common/[eth_types, transaction],
|
eth/common/[eth_types, transaction],
|
||||||
eth/async_utils, stew/[assign2, byteutils, objects, results, shims/hashes, endians2],
|
eth/async_utils, stew/[assign2, byteutils, objects, results, shims/hashes, endians2],
|
||||||
# Local modules:
|
# Local modules:
|
||||||
|
@ -1440,10 +1440,11 @@ proc exchangeTransitionConfiguration*(m: ELManager) {.async.} =
|
||||||
if cancelled == requests.len:
|
if cancelled == requests.len:
|
||||||
warn "Failed to exchange configuration with the configured EL end-points"
|
warn "Failed to exchange configuration with the configured EL end-points"
|
||||||
|
|
||||||
template readJsonField(j: JsonNode, fieldName: string, ValueType: type): untyped =
|
template readJsonField(logEvent, field: untyped, ValueType: type): untyped =
|
||||||
var res: ValueType
|
if logEvent.field.isNone:
|
||||||
fromJson(j[fieldName], fieldName, res)
|
raise newException(CatchableError,
|
||||||
res
|
"Web3 provider didn't return needed logEvent field " & astToStr(field))
|
||||||
|
logEvent.field.get
|
||||||
|
|
||||||
template init[N: static int](T: type DynamicBytes[N, N]): T =
|
template init[N: static int](T: type DynamicBytes[N, N]): T =
|
||||||
T newSeq[byte](N)
|
T newSeq[byte](N)
|
||||||
|
@ -1460,19 +1461,15 @@ proc fetchTimestamp(connection: ELConnection,
|
||||||
|
|
||||||
blk.timestamp = Eth1BlockTimestamp web3block.timestamp
|
blk.timestamp = Eth1BlockTimestamp web3block.timestamp
|
||||||
|
|
||||||
func depositEventsToBlocks(depositsList: JsonNode): seq[Eth1Block] {.
|
func depositEventsToBlocks(depositsList: openArray[JsonString]): seq[Eth1Block] {.
|
||||||
raises: [CatchableError].} =
|
raises: [CatchableError].} =
|
||||||
if depositsList.kind != JArray:
|
|
||||||
raise newException(CatchableError,
|
|
||||||
"Web3 provider didn't return a list of deposit events")
|
|
||||||
|
|
||||||
var lastEth1Block: Eth1Block
|
var lastEth1Block: Eth1Block
|
||||||
|
|
||||||
for logEvent in depositsList:
|
for logEventData in depositsList:
|
||||||
let
|
let
|
||||||
blockNumber = Eth1BlockNumber readJsonField(logEvent, "blockNumber", Quantity)
|
logEvent = JrpcConv.decode(logEventData.string, LogObject)
|
||||||
blockHash = readJsonField(logEvent, "blockHash", BlockHash)
|
blockNumber = Eth1BlockNumber readJsonField(logEvent, blockNumber, Quantity)
|
||||||
logData = hexToSeqByte(logEvent["data"].getStr)
|
blockHash = readJsonField(logEvent, blockHash, BlockHash)
|
||||||
|
|
||||||
if lastEth1Block == nil or lastEth1Block.number != blockNumber:
|
if lastEth1Block == nil or lastEth1Block.number != blockNumber:
|
||||||
lastEth1Block = Eth1Block(
|
lastEth1Block = Eth1Block(
|
||||||
|
@ -1493,11 +1490,11 @@ func depositEventsToBlocks(depositsList: JsonNode): seq[Eth1Block] {.
|
||||||
index = init Int64LeBytes
|
index = init Int64LeBytes
|
||||||
|
|
||||||
var offset = 0
|
var offset = 0
|
||||||
offset += decode(logData, 0, offset, pubkey)
|
offset += decode(logEvent.data, 0, offset, pubkey)
|
||||||
offset += decode(logData, 0, offset, withdrawalCredentials)
|
offset += decode(logEvent.data, 0, offset, withdrawalCredentials)
|
||||||
offset += decode(logData, 0, offset, amount)
|
offset += decode(logEvent.data, 0, offset, amount)
|
||||||
offset += decode(logData, 0, offset, signature)
|
offset += decode(logEvent.data, 0, offset, signature)
|
||||||
offset += decode(logData, 0, offset, index)
|
offset += decode(logEvent.data, 0, offset, index)
|
||||||
|
|
||||||
if pubkey.len != 48 or
|
if pubkey.len != 48 or
|
||||||
withdrawalCredentials.len != 32 or
|
withdrawalCredentials.len != 32 or
|
||||||
|
@ -1906,7 +1903,7 @@ proc syncBlockRange(m: ELManager,
|
||||||
var currentBlock = fromBlock
|
var currentBlock = fromBlock
|
||||||
while currentBlock <= toBlock:
|
while currentBlock <= toBlock:
|
||||||
var
|
var
|
||||||
depositLogs: JsonNode = nil
|
depositLogs: seq[JsonString]
|
||||||
maxBlockNumberRequested: Eth1BlockNumber
|
maxBlockNumberRequested: Eth1BlockNumber
|
||||||
backoff = 100
|
backoff = 100
|
||||||
|
|
||||||
|
|
|
@ -1209,15 +1209,12 @@ proc ETHExecutionBlockHeaderCreateFromJson(
|
||||||
##
|
##
|
||||||
## See:
|
## See:
|
||||||
## * https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash
|
## * https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash
|
||||||
let node =
|
let data = try:
|
||||||
try:
|
# a direct parameter like JrpcConv.decode($blockHeaderJson, BlockObject)
|
||||||
parseJson($blockHeaderJson)
|
# will cause premature garbage collector kick in.
|
||||||
except Exception:
|
let jsonBytes = $blockHeaderJson
|
||||||
return nil
|
JrpcConv.decode(jsonBytes, BlockObject)
|
||||||
var data: BlockObject
|
except SerializationError:
|
||||||
try:
|
|
||||||
fromJson(node, argName = "", data)
|
|
||||||
except KeyError, ValueError:
|
|
||||||
return nil
|
return nil
|
||||||
if data == nil:
|
if data == nil:
|
||||||
return nil
|
return nil
|
||||||
|
@ -1445,15 +1442,12 @@ proc ETHTransactionsCreateFromJson(
|
||||||
##
|
##
|
||||||
## See:
|
## See:
|
||||||
## * https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash
|
## * https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash
|
||||||
let node =
|
var datas = try:
|
||||||
try:
|
# a direct parameter like JrpcConv.decode($transactionsJson, seq[TransactionObject])
|
||||||
parseJson($transactionsJson)
|
# will cause premature garbage collector kick in.
|
||||||
except Exception:
|
let jsonBytes = $transactionsJson
|
||||||
return nil
|
JrpcConv.decode(jsonBytes, seq[TransactionObject])
|
||||||
var datas: seq[TransactionObject]
|
except SerializationError:
|
||||||
try:
|
|
||||||
fromJson(node, argName = "", datas)
|
|
||||||
except KeyError, ValueError:
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
var txs = newSeqOfCap[ETHTransaction](datas.len)
|
var txs = newSeqOfCap[ETHTransaction](datas.len)
|
||||||
|
@ -2085,15 +2079,12 @@ proc ETHReceiptsCreateFromJson(
|
||||||
##
|
##
|
||||||
## See:
|
## See:
|
||||||
## * https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
|
## * https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
|
||||||
let node =
|
var datas = try:
|
||||||
try:
|
# a direct parameter like JrpcConv.decode($receiptsJson, seq[ReceiptObject])
|
||||||
parseJson($receiptsJson)
|
# will cause premature garbage collector kick in.
|
||||||
except Exception:
|
let jsonBytes = $receiptsJson
|
||||||
return nil
|
JrpcConv.decode(jsonBytes, seq[ReceiptObject])
|
||||||
var datas: seq[ReceiptObject]
|
except SerializationError:
|
||||||
try:
|
|
||||||
fromJson(node, argName = "", datas)
|
|
||||||
except KeyError, ValueError:
|
|
||||||
return nil
|
return nil
|
||||||
if datas.len != ETHTransactionsGetCount(transactions):
|
if datas.len != ETHTransactionsGetCount(transactions):
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -443,15 +443,8 @@ proc doCreateTestnet*(config: CliConfig,
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
let blockAsJson = try:
|
let blockAsJson = genesisBlockContents.get
|
||||||
parseJson genesisBlockContents.get
|
genesisBlock = JrpcConv.decode(blockAsJson, BlockObject)
|
||||||
except CatchableError as err:
|
|
||||||
error "Failed to parse the genesis block json", err = err.msg
|
|
||||||
quit 1
|
|
||||||
except:
|
|
||||||
# TODO The Nim json library should not raise bare exceptions
|
|
||||||
raiseAssert "The Nim json library raise a bare exception"
|
|
||||||
fromJson(blockAsJson, "", genesisBlock)
|
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
error "Failed to load the genesis block from json",
|
error "Failed to load the genesis block from json",
|
||||||
err = err.msg
|
err = err.msg
|
||||||
|
|
|
@ -77,13 +77,13 @@ proc setupEngineAPI*(server: RpcServer) =
|
||||||
status: PayloadExecutionStatus.syncing))
|
status: PayloadExecutionStatus.syncing))
|
||||||
|
|
||||||
server.rpc("eth_getBlockByNumber") do(
|
server.rpc("eth_getBlockByNumber") do(
|
||||||
quantityTag: string, fullTransactions: bool) -> JsonNode:
|
quantityTag: string, fullTransactions: bool) -> JsonString:
|
||||||
info "eth_getBlockByNumber", quantityTag, fullTransactions
|
info "eth_getBlockByNumber", quantityTag, fullTransactions
|
||||||
|
|
||||||
return if quantityTag == "latest":
|
return if quantityTag == "latest":
|
||||||
%BlockObject(number: 1000.Quantity)
|
JrpcConv.encode(BlockObject(number: 1000.Quantity)).JsonString
|
||||||
else:
|
else:
|
||||||
newJObject()
|
"{}".JsonString
|
||||||
|
|
||||||
server.rpc("eth_getBlockByHash") do(
|
server.rpc("eth_getBlockByHash") do(
|
||||||
data: string, fullTransactions: bool) -> BlockObject:
|
data: string, fullTransactions: bool) -> BlockObject:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 08d7fccfe2025d5a2ecca68e6e7b4dd4a7974a8e
|
Subproject commit a6475e49b26d3afc58aaa3d67621c94eafef8efb
|
|
@ -1 +1 @@
|
||||||
Subproject commit 45d09b29d22da63052b259679539a3d4141273a7
|
Subproject commit bf1ce869b5f76d9744444b248f6f5c6c782fedc7
|
Loading…
Reference in New Issue