Bump nim-web3 to c8f36f59cb354196cfe117b6866e81d450c8cfd7 (#6727)

* Bump nim-web3 to c8f36f59cb354196cfe117b6866e81d450c8cfd7
* no need to convert accessList and authorizationList anymore
This commit is contained in:
andri lim 2024-11-27 14:42:45 +07:00 committed by GitHub
parent f12ceb8c75
commit 1eaeea10b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 30 deletions

View File

@ -194,7 +194,7 @@ type
depositContractSyncStatus: DepositContractSyncStatus depositContractSyncStatus: DepositContractSyncStatus
## Are we sure that this EL has synced the deposit contract? ## Are we sure that this EL has synced the deposit contract?
lastPayloadId: Opt[PayloadID] lastPayloadId: Opt[Bytes8]
FullBlockId* = object FullBlockId* = object
number: Eth1BlockNumber number: Eth1BlockNumber
@ -485,7 +485,7 @@ func areSameAs(expectedParams: Option[NextExpectedPayloadParams],
expectedParams.get.safeBlockHash == latestSafe and expectedParams.get.safeBlockHash == latestSafe and
expectedParams.get.finalizedBlockHash == latestFinalized and expectedParams.get.finalizedBlockHash == latestFinalized and
expectedParams.get.payloadAttributes.timestamp.uint64 == timestamp and expectedParams.get.payloadAttributes.timestamp.uint64 == timestamp and
expectedParams.get.payloadAttributes.prevRandao.bytes == randomData.data and expectedParams.get.payloadAttributes.prevRandao.data == randomData.data and
expectedParams.get.payloadAttributes.suggestedFeeRecipient == feeRecipient and expectedParams.get.payloadAttributes.suggestedFeeRecipient == feeRecipient and
expectedParams.get.payloadAttributes.withdrawals == withdrawals expectedParams.get.payloadAttributes.withdrawals == withdrawals

View File

@ -1305,18 +1305,13 @@ proc ETHExecutionBlockHeaderCreateFromJson(
doAssert data.withdrawalsRoot.isSome # Checked above doAssert data.withdrawalsRoot.isSome # Checked above
wds = newSeqOfCap[ETHWithdrawal](data.withdrawals.get.len) wds = newSeqOfCap[ETHWithdrawal](data.withdrawals.get.len)
for data in data.withdrawals.get: for wd in data.withdrawals.get:
# Check fork consistency # Check fork consistency
static: doAssert totalSerializedFields(WithdrawalObject) == 4, static: doAssert totalSerializedFields(eth_types.EthWithdrawal) == 4,
"Only update this number once code is adjusted to check new fields!" "Only update this number once code is adjusted to check new fields!"
# Construct withdrawal # Construct withdrawal
let let
wd = eth_types.EthWithdrawal(
index: distinctBase(data.index),
validatorIndex: distinctBase(data.validatorIndex),
address: distinctBase(data.address).to(EthAddress),
amount: distinctBase(data.amount))
rlpBytes = rlpBytes =
try: try:
rlp.encode(wd) rlp.encode(wd)
@ -1562,7 +1557,7 @@ proc ETHTransactionsCreateFromJson(
if data.authorizationList.isSome: if data.authorizationList.isSome:
for authorization in data.authorizationList.get: for authorization in data.authorizationList.get:
static: doAssert sizeof(uint64) == sizeof(authorization.chainId) static: doAssert sizeof(uint64) == sizeof(authorization.chainId)
if distinctBase(authorization.v) > uint8.high: if authorization.v > uint8.high:
return nil return nil
let let
tx = eth_types.EthTransaction( tx = eth_types.EthTransaction(
@ -1583,9 +1578,7 @@ proc ETHTransactionsCreateFromJson(
payload: data.input, payload: data.input,
accessList: accessList:
if data.accessList.isSome: if data.accessList.isSome:
data.accessList.get.mapIt(AccessPair( data.accessList.get
address: distinctBase(it.address).to(EthAddress),
storageKeys: it.storageKeys.mapIt(distinctBase(it).to(Bytes32))))
else: else:
@[], @[],
maxFeePerBlobGas: maxFeePerBlobGas:
@ -1598,13 +1591,7 @@ proc ETHTransactionsCreateFromJson(
@[], @[],
authorizationList: authorizationList:
if data.authorizationList.isSome: if data.authorizationList.isSome:
data.authorizationList.get.mapIt(Authorization( data.authorizationList.get
chainId: it.chainId.ChainId,
address: distinctBase(it.address).to(EthAddress),
nonce: distinctBase(it.nonce),
v: distinctBase(it.v),
r: it.r,
s: it.s))
else: else:
@[], @[],
V: distinctBase(data.v), V: distinctBase(data.v),
@ -1615,7 +1602,7 @@ proc ETHTransactionsCreateFromJson(
rlp.encode(tx) rlp.encode(tx)
except RlpError: except RlpError:
raiseAssert "Unreachable" raiseAssert "Unreachable"
hash = keccakHash(rlpBytes) hash = keccak256(rlpBytes)
if data.hash.asEth2Digest != hash: if data.hash.asEth2Digest != hash:
return nil return nil
@ -1664,7 +1651,7 @@ proc ETHTransactionsCreateFromJson(
of DestinationType.Regular: of DestinationType.Regular:
tx.to.get tx.to.get
of DestinationType.Create: of DestinationType.Create:
let hash = keccakHash(rlp.encodeList(fromAddress, tx.nonce)) let hash = keccak256(rlp.encodeList(fromAddress, tx.nonce))
hash.to(EthAddress) hash.to(EthAddress)
# Compute authorizations # Compute authorizations
@ -1683,7 +1670,7 @@ proc ETHTransactionsCreateFromJson(
signature: @sig) signature: @sig)
txs.add ETHTransaction( txs.add ETHTransaction(
hash: keccakHash(rlpBytes), hash: keccak256(rlpBytes),
chainId: distinctBase(tx.chainId), chainId: distinctBase(tx.chainId),
`from`: ExecutionAddress(data: fromAddress), `from`: ExecutionAddress(data: fromAddress),
nonce: tx.nonce, nonce: tx.nonce,

View File

@ -263,7 +263,7 @@ func `as`(blk: BlockObject, T: type bellatrix.ExecutionPayloadHeader): T =
gas_limit: uint64 blk.gasLimit, gas_limit: uint64 blk.gasLimit,
gas_used: uint64 blk.gasUsed, gas_used: uint64 blk.gasUsed,
timestamp: uint64 blk.timestamp, timestamp: uint64 blk.timestamp,
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.bytes), extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.data),
base_fee_per_gas: blk.baseFeePerGas.getOrDefault(), base_fee_per_gas: blk.baseFeePerGas.getOrDefault(),
block_hash: blk.hash as Eth2Digest, block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest) transactions_root: blk.transactionsRoot as Eth2Digest)
@ -279,7 +279,7 @@ func `as`(blk: BlockObject, T: type capella.ExecutionPayloadHeader): T =
gas_limit: uint64 blk.gasLimit, gas_limit: uint64 blk.gasLimit,
gas_used: uint64 blk.gasUsed, gas_used: uint64 blk.gasUsed,
timestamp: uint64 blk.timestamp, timestamp: uint64 blk.timestamp,
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.bytes), extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.data),
base_fee_per_gas: blk.baseFeePerGas.getOrDefault(), base_fee_per_gas: blk.baseFeePerGas.getOrDefault(),
block_hash: blk.hash as Eth2Digest, block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest, transactions_root: blk.transactionsRoot as Eth2Digest,
@ -296,7 +296,7 @@ func `as`(blk: BlockObject, T: type deneb.ExecutionPayloadHeader): T =
gas_limit: uint64 blk.gasLimit, gas_limit: uint64 blk.gasLimit,
gas_used: uint64 blk.gasUsed, gas_used: uint64 blk.gasUsed,
timestamp: uint64 blk.timestamp, timestamp: uint64 blk.timestamp,
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.bytes), extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.data),
base_fee_per_gas: blk.baseFeePerGas.getOrDefault(), base_fee_per_gas: blk.baseFeePerGas.getOrDefault(),
block_hash: blk.hash as Eth2Digest, block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest, transactions_root: blk.transactionsRoot as Eth2Digest,
@ -315,7 +315,7 @@ func `as`(blk: BlockObject, T: type electra.ExecutionPayloadHeader): T =
gas_limit: uint64 blk.gasLimit, gas_limit: uint64 blk.gasLimit,
gas_used: uint64 blk.gasUsed, gas_used: uint64 blk.gasUsed,
timestamp: uint64 blk.timestamp, timestamp: uint64 blk.timestamp,
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.bytes), extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.data),
base_fee_per_gas: blk.baseFeePerGas.getOrDefault(), base_fee_per_gas: blk.baseFeePerGas.getOrDefault(),
block_hash: blk.hash as Eth2Digest, block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest, transactions_root: blk.transactionsRoot as Eth2Digest,
@ -334,7 +334,7 @@ func `as`(blk: BlockObject, T: type fulu.ExecutionPayloadHeader): T =
gas_limit: uint64 blk.gasLimit, gas_limit: uint64 blk.gasLimit,
gas_used: uint64 blk.gasUsed, gas_used: uint64 blk.gasUsed,
timestamp: uint64 blk.timestamp, timestamp: uint64 blk.timestamp,
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.bytes), extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(blk.extraData.data),
base_fee_per_gas: blk.baseFeePerGas.getOrDefault(), base_fee_per_gas: blk.baseFeePerGas.getOrDefault(),
block_hash: blk.hash as Eth2Digest, block_hash: blk.hash as Eth2Digest,
transactions_root: blk.transactionsRoot as Eth2Digest, transactions_root: blk.transactionsRoot as Eth2Digest,
@ -562,7 +562,7 @@ when isMainModule:
let r = await web3.send(tr) let r = await web3.send(tr)
result = await web3.getMinedTransactionReceipt(r) result = await web3.getMinedTransactionReceipt(r)
proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[Hash32] =
let tr = TransactionArgs( let tr = TransactionArgs(
`from`: Opt.some web3.defaultAccount, `from`: Opt.some web3.defaultAccount,
# TODO: Force json-rpc to generate 'data' field # TODO: Force json-rpc to generate 'data' field

2
vendor/nim-web3 vendored

@ -1 +1 @@
Subproject commit ff92d2877985faee5ac6abc3bea805b85f2be1c8 Subproject commit c8f36f59cb354196cfe117b6866e81d450c8cfd7