Bump nim-web3 to dcabb8f29ee55afedefdf93cd3e102bb1daee354 (#5664)

* bump nim-web3 to dcabb8f29ee55afedefdf93cd3e102bb1daee354

also bump json-rpc to a8731e91bc336d930ac66f985d3b88ed7cf2a7d7
This commit is contained in:
andri lim 2023-12-12 22:15:00 +07:00 committed by GitHub
parent 61e355639a
commit 15147cccb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 57 additions and 50 deletions

View File

@ -20,7 +20,7 @@ import
stew/[io2, byteutils], unicodedb/properties, normalize,
eth/common/eth_types as commonEthTypes, eth/net/nat,
eth/p2p/discoveryv5/enr,
json_serialization, web3/[ethtypes, confutils_defs],
json_serialization, web3/[primitives, confutils_defs],
kzg4844/kzg_ex,
./spec/[engine_authentication, keystore, network, crypto],
./spec/datatypes/base,

View File

@ -8,7 +8,7 @@
{.push raises: [].}
import
chronicles, chronos, web3/[ethtypes, engine_api_types],
chronicles, chronos, web3/[primitives, engine_api_types],
../spec/datatypes/base,
../consensus_object_pools/[blockchain_dag, block_quarantine, attestation_pool],
../el/el_manager,

View File

@ -13,14 +13,15 @@ import
../filepath,
../networking/network_metadata,
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
stew/io2,
stew/[io2, byteutils],
../spec/eth2_merkleization,
../spec/datatypes/base,
../validators/keystore_management
# Compiled version of /scripts/depositContract.v.py in this repo
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
const contractCode = staticRead "deposit_contract_code.txt"
const contractCode =
hexToSeqByte staticRead "deposit_contract_code.txt"
type
Eth1Address = web3.Address
@ -120,24 +121,21 @@ contract(DepositContract):
signature: SignatureBytes,
deposit_data_root: FixedBytes[32])
proc deployContract*(web3: Web3, code: string): Future[ReceiptObject] {.async.} =
var code = code
if code[1] notin {'x', 'X'}:
code = "0x" & code
proc deployContract*(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} =
let tr = EthSend(
source: web3.defaultAccount,
`from`: web3.defaultAccount,
data: code,
gas: Quantity(3000000).some,
gasPrice: 1.some)
gasPrice: Quantity(1).some)
let r = await web3.send(tr)
result = await web3.getMinedTransactionReceipt(r)
proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
let tr = EthSend(
source: web3.defaultAccount,
`from`: web3.defaultAccount,
gas: Quantity(3000000).some,
gasPrice: 1.some,
gasPrice: Quantity(1).some,
value: some(valueEth.u256 * 1000000000000000000.u256),
to: some(to))
web3.send(tr)

View File

@ -17,7 +17,7 @@ import
eth/trie/[db, hexary],
json_rpc/jsonmarshal,
secp256k1,
web3/ethtypes,
web3/eth_api_types,
../el/el_manager,
../spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls],
../spec/[helpers, light_client_sync],
@ -1501,7 +1501,7 @@ proc ETHTransactionsCreateFromJson(
doAssert sizeof(int64) == sizeof(data.gasPrice)
doAssert sizeof(int64) == sizeof(data.maxPriorityFeePerGas.get)
doAssert sizeof(UInt256) == sizeof(data.maxFeePerBlobGas.get)
if data.chainId.get(default(UInt256)) > distinctBase(ChainId.high).u256:
if distinctBase(data.chainId.get(0.Quantity)) > distinctBase(ChainId.high):
return nil
if distinctBase(data.gasPrice) > int64.high.uint64:
return nil
@ -1515,12 +1515,12 @@ proc ETHTransactionsCreateFromJson(
return nil
if distinctBase(data.gas) > int64.high.uint64:
return nil
if data.v > int64.high.u256:
if data.v.uint64 > int64.high.uint64:
return nil
let
tx = ExecutionTransaction(
txType: txType,
chainId: data.chainId.get(default(UInt256)).truncate(uint64).ChainId,
chainId: data.chainId.get(0.Quantity).ChainId,
nonce: distinctBase(data.nonce),
gasPrice: data.gasPrice.GasInt,
maxPriorityFee:
@ -1549,7 +1549,7 @@ proc ETHTransactionsCreateFromJson(
ExecutionHash256(data: distinctBase(it)))
else:
@[],
V: data.v.truncate(uint64).int64,
V: data.v.int64,
R: data.r,
S: data.s)
rlpBytes =
@ -2105,7 +2105,7 @@ proc ETHReceiptsCreateFromJson(
return nil
# Check fork consistency
static: doAssert totalSerializedFields(ReceiptObject) == 15,
static: doAssert totalSerializedFields(ReceiptObject) == 17,
"Only update this number once code is adjusted to check new fields!"
static: doAssert totalSerializedFields(LogObject) == 9,
"Only update this number once code is adjusted to check new fields!"
@ -2133,16 +2133,26 @@ proc ETHReceiptsCreateFromJson(
for log in data.logs:
if log.removed:
return nil
if distinctBase(log.logIndex) != logIndex + 1:
if log.logIndex.isNone:
return nil
logIndex = distinctBase(log.logIndex)
if log.transactionIndex != data.transactionIndex:
if distinctBase(log.logIndex.get) != logIndex + 1:
return nil
if log.transactionHash != data.transactionHash:
logIndex = distinctBase(log.logIndex.get)
if log.transactionIndex.isNone:
return nil
if log.blockHash != data.blockHash:
if log.transactionIndex.get != data.transactionIndex:
return nil
if log.blockNumber != data.blockNumber:
if log.transactionHash.isNone:
return nil
if log.transactionHash.get != data.transactionHash:
return nil
if log.blockHash.isNone:
return nil
if log.blockHash.get != data.blockHash:
return nil
if log.blockNumber.isNone:
return nil
if log.blockNumber.get != data.blockNumber:
return nil
if log.data.len mod 32 != 0:
return nil

View File

@ -10,7 +10,8 @@
import
std/[sequtils, strutils, os],
stew/[byteutils, objects], stew/shims/macros, nimcrypto/hash,
web3/[ethtypes, conversions],
web3/[conversions],
web3/primitives as web3types,
chronicles,
eth/common/eth_types_json_serialization,
../spec/[eth2_ssz_serialization, forks]
@ -29,7 +30,7 @@ import
# from `currentSourcePath`.
export
ethtypes, conversions, RuntimeConfig
web3types, conversions, RuntimeConfig
const
vendorDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor"
@ -37,7 +38,7 @@ const
incbinEnabled* = sizeof(pointer) == 8
type
Eth1BlockHash* = ethtypes.BlockHash
Eth1BlockHash* = web3types.BlockHash
Eth1Network* = enum
mainnet

View File

@ -27,8 +27,8 @@ export
eth2_ssz_serialization, results, peerid, common, serialization, chronicles,
json_serialization, net, sets, rest_types, slashing_protection_common
from web3/ethtypes import BlockHash
export ethtypes.BlockHash
from web3/primitives import BlockHash
export primitives.BlockHash
func decodeMediaType*(
contentType: Opt[ContentTypeData]): Result[MediaType, string] =

View File

@ -15,7 +15,7 @@
import
std/[json, tables],
stew/base10, web3/ethtypes, httputils,
stew/base10, web3/primitives, httputils,
".."/forks,
".."/datatypes/[phase0, altair, bellatrix, deneb],
".."/mev/[capella_mev, deneb_mev]

View File

@ -10,12 +10,12 @@
import
std/[strutils, parseutils, tables, typetraits],
chronos/timer,
stew/[byteutils], stint, web3/[ethtypes],
stew/[byteutils], stint, web3/primitives as web3types,
./datatypes/constants
export constants
export stint, ethtypes.toHex, ethtypes.`==`
export stint, web3types.toHex, web3types.`==`
const
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/beacon-chain.md#withdrawal-prefixes
@ -33,7 +33,7 @@ const
type
Version* = distinct array[4, byte]
Eth1Address* = ethtypes.Address
Eth1Address* = web3types.Address
RuntimeConfig* = object
## https://github.com/ethereum/consensus-specs/tree/v1.4.0-beta.4/configs

View File

@ -23,7 +23,7 @@ import
chronicles, chronicles/timings,
json_serialization/std/[options, sets, net],
eth/db/kvstore,
web3/ethtypes,
web3/primitives,
kzg4844,
# Local modules

View File

@ -8,7 +8,7 @@
import
std/[json, strutils, times, sequtils],
chronos, confutils, chronicles,
web3, web3/ethtypes as web3Types,
web3, web3/primitives,
eth/async_utils,
../beacon_chain/beacon_chain_db,
../beacon_chain/networking/network_metadata,

View File

@ -29,7 +29,8 @@ from std/times import toUnix
# Compiled version of /scripts/depositContract.v.py in this repo
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
const depositContractCode = staticRead "../beacon_chain/el/deposit_contract_code.txt"
const depositContractCode =
hexToSeqByte staticRead "../beacon_chain/el/deposit_contract_code.txt"
# For nim-confutils, which uses this kind of init(Type, value) pattern
func init(T: type IpAddress, ip: IpAddress): T = ip
@ -282,7 +283,7 @@ contract(DepositContract):
signature: SignatureBytes,
deposit_data_root: FixedBytes[32])
template `as`(address: ethtypes.Address, T: type bellatrix.ExecutionAddress): T =
template `as`(address: Eth1Address, T: type bellatrix.ExecutionAddress): T =
T(data: distinctBase(address))
template `as`(address: BlockHash, T: type Eth2Digest): T =
@ -508,24 +509,21 @@ proc doCreateTestnet*(config: CliConfig,
writeFile(bootstrapFile, enr.toURI)
echo "Wrote ", bootstrapFile
proc deployContract(web3: Web3, code: string): Future[ReceiptObject] {.async.} =
var code = code
if code[1] notin {'x', 'X'}:
code = "0x" & code
proc deployContract(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} =
let tr = EthSend(
source: web3.defaultAccount,
`from`: web3.defaultAccount,
data: code,
gas: Quantity(3000000).some,
gasPrice: 1.some)
gasPrice: Quantity(1).some)
let r = await web3.send(tr)
result = await web3.getMinedTransactionReceipt(r)
proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
let tr = EthSend(
source: web3.defaultAccount,
`from`: web3.defaultAccount,
gas: Quantity(3000000).some,
gasPrice: 1.some,
gasPrice: Quantity(1).some,
value: some(valueEth.u256 * 1000000000000000000.u256),
to: some(to))
web3.send(tr)

View File

@ -13,7 +13,7 @@ import
std/typetraits,
stew/byteutils,
json_rpc/[rpcserver, errors],
web3/[conversions, engine_api_types],
web3/[conversions, engine_api_types, eth_api_types],
chronicles
proc setupEngineAPI*(server: RpcServer) =

View File

@ -11,7 +11,7 @@ import
# Status libraries
stew/bitops2,
eth/common/eth_types as commonEthTypes, eth/common/eth_types_rlp,
web3/ethtypes,
web3/primitives,
# Beacon chain internals
../beacon_chain/spec/[forks, helpers, state_transition],
../beacon_chain/spec/datatypes/[bellatrix, capella],

2
vendor/nim-json-rpc vendored

@ -1 +1 @@
Subproject commit 60c4c9b5f28b530d5d89fd14c337af1d86390a82
Subproject commit a8731e91bc336d930ac66f985d3b88ed7cf2a7d7

2
vendor/nim-web3 vendored

@ -1 +1 @@
Subproject commit 428b931e7c4f1284b4272bc2c11fca2bd70991cd
Subproject commit df0af1aca64f6a1a9a76c92776ce2b2ee0c6bfec