mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 05:44:40 +00:00
Bump nim-web3 to c8f36f59cb354196cfe117b6866e81d450c8cfd7 (#2878)
* Bump nim-web3 to c8f36f59cb354196cfe117b6866e81d450c8cfd7 * Fix portal bridge * Comply to nph format style
This commit is contained in:
parent
e55583bf7a
commit
5e90522e70
@ -42,9 +42,10 @@ func asEthBlock(blockObject: BlockObject): EthBlock =
|
||||
let
|
||||
header = blockObject.toBlockHeader()
|
||||
transactions = toTransactions(blockObject.transactions)
|
||||
withdrawals = toWithdrawals(blockObject.withdrawals)
|
||||
|
||||
EthBlock(header: header, transactions: transactions, withdrawals: withdrawals)
|
||||
EthBlock(
|
||||
header: header, transactions: transactions, withdrawals: blockObject.withdrawals
|
||||
)
|
||||
|
||||
func asPortalBlock(
|
||||
ethBlock: EthBlock
|
||||
|
@ -276,9 +276,9 @@ func vHashes(x: Opt[seq[Hash32]]): seq[VersionedHash] =
|
||||
if x.isNone: return
|
||||
else: x.get
|
||||
|
||||
func authList(x: Opt[seq[AuthorizationObject]]): seq[Authorization] =
|
||||
func authList(x: Opt[seq[Authorization]]): seq[Authorization] =
|
||||
if x.isNone: return
|
||||
else: ethAuthList x.get
|
||||
else: x.get
|
||||
|
||||
proc toTransaction(tx: TransactionObject): Transaction =
|
||||
Transaction(
|
||||
@ -306,24 +306,6 @@ proc toTransactions*(txs: openArray[TxOrHash]): seq[Transaction] =
|
||||
doAssert x.kind == tohTx
|
||||
result.add toTransaction(x.tx)
|
||||
|
||||
proc toWithdrawal(wd: WithdrawalObject): Withdrawal =
|
||||
Withdrawal(
|
||||
index: wd.index.uint64,
|
||||
validatorIndex: wd.validatorIndex.uint64,
|
||||
address: wd.address,
|
||||
amount: wd.amount.uint64,
|
||||
)
|
||||
|
||||
proc toWithdrawals(list: seq[WithdrawalObject]): seq[Withdrawal] =
|
||||
result = newSeqOfCap[Withdrawal](list.len)
|
||||
for wd in list:
|
||||
result.add toWithdrawal(wd)
|
||||
|
||||
proc toWithdrawals*(list: Opt[seq[WithdrawalObject]]): Opt[seq[Withdrawal]] =
|
||||
if list.isNone:
|
||||
return Opt.none(seq[Withdrawal])
|
||||
Opt.some(toWithdrawals(list.get))
|
||||
|
||||
type
|
||||
RPCReceipt* = object
|
||||
txHash*: Hash32
|
||||
@ -415,7 +397,7 @@ proc toRPCTx(tx: eth_api.TransactionObject): RPCTx =
|
||||
Opt.some(vHashes tx.blobVersionedHashes)
|
||||
else:
|
||||
Opt.none(seq[VersionedHash]),
|
||||
authorizationList: ethAuthList(tx.authorizationList),
|
||||
authorizationList: tx.authorizationList,
|
||||
)
|
||||
|
||||
proc waitForTTD*(client: RpcClient,
|
||||
@ -469,7 +451,7 @@ proc latestBlock*(client: RpcClient): Result[Block, string] =
|
||||
let output = Block(
|
||||
header: toBlockHeader(res),
|
||||
transactions: toTransactions(res.transactions),
|
||||
withdrawals: toWithdrawals(res.withdrawals),
|
||||
withdrawals: res.withdrawals,
|
||||
)
|
||||
return ok(output)
|
||||
|
||||
|
@ -94,27 +94,6 @@ func ethTxs*(list: openArray[Web3Tx]):
|
||||
for x in list:
|
||||
result.add ethTx(x)
|
||||
|
||||
func ethAuth*(x: AuthorizationObject): Authorization =
|
||||
Authorization(
|
||||
chainId: ChainId x.chainId,
|
||||
address: x.address,
|
||||
nonce: distinctBase x.nonce,
|
||||
v: distinctBase x.v,
|
||||
r: x.r,
|
||||
s: x.s,
|
||||
)
|
||||
|
||||
func ethAuthList*(list: openArray[AuthorizationObject]):
|
||||
seq[Authorization] =
|
||||
result = newSeqOfCap[Authorization](list.len)
|
||||
for x in list:
|
||||
result.add ethAuth(x)
|
||||
|
||||
func ethAuthList*(x: Opt[seq[AuthorizationObject]]):
|
||||
Opt[seq[Authorization]] =
|
||||
if x.isNone: Opt.none(seq[Authorization])
|
||||
else: Opt.some(ethAuthList x.get)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Eth types to Web3 types
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -90,42 +90,9 @@ proc unsignedTx*(tx: TransactionArgs, chain: CoreDbRef, defaultNonce: AccountNon
|
||||
|
||||
return res
|
||||
|
||||
proc toWd(wd: Withdrawal): WithdrawalObject =
|
||||
WithdrawalObject(
|
||||
index: Quantity(wd.index),
|
||||
validatorIndex: Quantity wd.validatorIndex,
|
||||
address: wd.address,
|
||||
amount: Quantity wd.amount,
|
||||
)
|
||||
|
||||
proc toWdList(list: openArray[Withdrawal]): seq[WithdrawalObject] =
|
||||
result = newSeqOfCap[WithdrawalObject](list.len)
|
||||
for x in list:
|
||||
result.add toWd(x)
|
||||
|
||||
func toWdList(x: Opt[seq[Withdrawal]]):
|
||||
Opt[seq[WithdrawalObject]] =
|
||||
if x.isNone: Opt.none(seq[WithdrawalObject])
|
||||
else: Opt.some(toWdList x.get)
|
||||
|
||||
func toAuth*(x: Authorization): AuthorizationObject =
|
||||
AuthorizationObject(
|
||||
chainId: Quantity(x.chainId),
|
||||
address: x.address,
|
||||
nonce: Quantity(x.nonce),
|
||||
v: Quantity(x.v),
|
||||
r: x.r,
|
||||
s: x.s,
|
||||
)
|
||||
|
||||
proc toAuthList(list: openArray[Authorization]): seq[AuthorizationObject] =
|
||||
result = newSeqOfCap[AuthorizationObject](list.len)
|
||||
for x in list:
|
||||
result.add toAuth(x)
|
||||
|
||||
proc populateTransactionObject*(tx: Transaction,
|
||||
optionalHash: Opt[eth_types.Hash32] = Opt.none(eth_types.Hash32),
|
||||
optionalNumber: Opt[eth_types.BlockNumber] = Opt.none(eth_types.BlockNumber),
|
||||
optionalHash: Opt[Hash32] = Opt.none(Hash32),
|
||||
optionalNumber: Opt[uint64] = Opt.none(uint64),
|
||||
txIndex: Opt[uint64] = Opt.none(uint64)): TransactionObject =
|
||||
result = TransactionObject()
|
||||
result.`type` = Opt.some Quantity(tx.txType)
|
||||
@ -158,9 +125,9 @@ proc populateTransactionObject*(tx: Transaction,
|
||||
result.blobVersionedHashes = Opt.some(tx.versionedHashes)
|
||||
|
||||
if tx.txType >= TxEip7702:
|
||||
result.authorizationList = Opt.some(toAuthList(tx.authorizationList))
|
||||
result.authorizationList = Opt.some(tx.authorizationList)
|
||||
|
||||
proc populateBlockObject*(blockHash: eth_types.Hash32,
|
||||
proc populateBlockObject*(blockHash: Hash32,
|
||||
blk: Block,
|
||||
totalDifficulty: UInt256,
|
||||
fullTx: bool,
|
||||
@ -207,7 +174,7 @@ proc populateBlockObject*(blockHash: eth_types.Hash32,
|
||||
result.transactions.add txOrHash(txHash)
|
||||
|
||||
result.withdrawalsRoot = header.withdrawalsRoot
|
||||
result.withdrawals = toWdList blk.withdrawals
|
||||
result.withdrawals = blk.withdrawals
|
||||
result.parentBeaconBlockRoot = header.parentBeaconBlockRoot
|
||||
result.blobGasUsed = w3Qty(header.blobGasUsed)
|
||||
result.excessBlobGas = w3Qty(header.excessBlobGas)
|
||||
|
@ -199,7 +199,8 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
|
||||
elif consensusFork == ConsensusFork.Capella:
|
||||
Opt.none(PayloadAttributesV2)
|
||||
elif consensusFork == ConsensusFork.Deneb or
|
||||
consensusFork == ConsensusFork.Electra:
|
||||
consensusFork == ConsensusFork.Electra or
|
||||
consensusFork == ConsensusFork.Fulu:
|
||||
Opt.none(PayloadAttributesV3)
|
||||
else:
|
||||
static: doAssert(false, "Unsupported consensus fork")
|
||||
@ -247,7 +248,8 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
|
||||
response = payloadResponse,
|
||||
payload = payload,
|
||||
versionedHashes = versioned_hashes
|
||||
elif consensusFork == ConsensusFork.Electra:
|
||||
elif consensusFork == ConsensusFork.Electra or
|
||||
consensusFork == ConsensusFork.Fulu:
|
||||
# Calculate the versioned hashes from the kzg commitments
|
||||
let versioned_hashes = mapIt(
|
||||
forkyBlck.message.body.blob_kzg_commitments,
|
||||
|
2
vendor/nim-web3
vendored
2
vendor/nim-web3
vendored
@ -1 +1 @@
|
||||
Subproject commit ff92d2877985faee5ac6abc3bea805b85f2be1c8
|
||||
Subproject commit c8f36f59cb354196cfe117b6866e81d450c8cfd7
|
2
vendor/nimbus-eth2
vendored
2
vendor/nimbus-eth2
vendored
@ -1 +1 @@
|
||||
Subproject commit 5d940b4c1eaf65475f8cea54d396ebbec35deec2
|
||||
Subproject commit 1eaeea10b3acae082738d93b9dde85b0db759e05
|
Loading…
x
Reference in New Issue
Block a user