mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-24 12:18:32 +00:00
Bump nim-web3 to dcabb8f29ee55afedefdf93cd3e102bb1daee354 (#5664)
* bump nim-web3 to dcabb8f29ee55afedefdf93cd3e102bb1daee354 also bump json-rpc to a8731e91bc336d930ac66f985d3b88ed7cf2a7d7
This commit is contained in:
parent
61e355639a
commit
15147cccb1
@ -20,7 +20,7 @@ import
|
|||||||
stew/[io2, byteutils], unicodedb/properties, normalize,
|
stew/[io2, byteutils], unicodedb/properties, normalize,
|
||||||
eth/common/eth_types as commonEthTypes, eth/net/nat,
|
eth/common/eth_types as commonEthTypes, eth/net/nat,
|
||||||
eth/p2p/discoveryv5/enr,
|
eth/p2p/discoveryv5/enr,
|
||||||
json_serialization, web3/[ethtypes, confutils_defs],
|
json_serialization, web3/[primitives, confutils_defs],
|
||||||
kzg4844/kzg_ex,
|
kzg4844/kzg_ex,
|
||||||
./spec/[engine_authentication, keystore, network, crypto],
|
./spec/[engine_authentication, keystore, network, crypto],
|
||||||
./spec/datatypes/base,
|
./spec/datatypes/base,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
chronicles, chronos, web3/[ethtypes, engine_api_types],
|
chronicles, chronos, web3/[primitives, engine_api_types],
|
||||||
../spec/datatypes/base,
|
../spec/datatypes/base,
|
||||||
../consensus_object_pools/[blockchain_dag, block_quarantine, attestation_pool],
|
../consensus_object_pools/[blockchain_dag, block_quarantine, attestation_pool],
|
||||||
../el/el_manager,
|
../el/el_manager,
|
||||||
|
@ -13,14 +13,15 @@ import
|
|||||||
../filepath,
|
../filepath,
|
||||||
../networking/network_metadata,
|
../networking/network_metadata,
|
||||||
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
|
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
|
||||||
stew/io2,
|
stew/[io2, byteutils],
|
||||||
../spec/eth2_merkleization,
|
../spec/eth2_merkleization,
|
||||||
../spec/datatypes/base,
|
../spec/datatypes/base,
|
||||||
../validators/keystore_management
|
../validators/keystore_management
|
||||||
|
|
||||||
# Compiled version of /scripts/depositContract.v.py in this repo
|
# Compiled version of /scripts/depositContract.v.py in this repo
|
||||||
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
|
# 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
|
type
|
||||||
Eth1Address = web3.Address
|
Eth1Address = web3.Address
|
||||||
@ -120,24 +121,21 @@ contract(DepositContract):
|
|||||||
signature: SignatureBytes,
|
signature: SignatureBytes,
|
||||||
deposit_data_root: FixedBytes[32])
|
deposit_data_root: FixedBytes[32])
|
||||||
|
|
||||||
proc deployContract*(web3: Web3, code: string): Future[ReceiptObject] {.async.} =
|
proc deployContract*(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} =
|
||||||
var code = code
|
|
||||||
if code[1] notin {'x', 'X'}:
|
|
||||||
code = "0x" & code
|
|
||||||
let tr = EthSend(
|
let tr = EthSend(
|
||||||
source: web3.defaultAccount,
|
`from`: web3.defaultAccount,
|
||||||
data: code,
|
data: code,
|
||||||
gas: Quantity(3000000).some,
|
gas: Quantity(3000000).some,
|
||||||
gasPrice: 1.some)
|
gasPrice: Quantity(1).some)
|
||||||
|
|
||||||
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[TxHash] =
|
||||||
let tr = EthSend(
|
let tr = EthSend(
|
||||||
source: web3.defaultAccount,
|
`from`: web3.defaultAccount,
|
||||||
gas: Quantity(3000000).some,
|
gas: Quantity(3000000).some,
|
||||||
gasPrice: 1.some,
|
gasPrice: Quantity(1).some,
|
||||||
value: some(valueEth.u256 * 1000000000000000000.u256),
|
value: some(valueEth.u256 * 1000000000000000000.u256),
|
||||||
to: some(to))
|
to: some(to))
|
||||||
web3.send(tr)
|
web3.send(tr)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@ import
|
|||||||
eth/trie/[db, hexary],
|
eth/trie/[db, hexary],
|
||||||
json_rpc/jsonmarshal,
|
json_rpc/jsonmarshal,
|
||||||
secp256k1,
|
secp256k1,
|
||||||
web3/ethtypes,
|
web3/eth_api_types,
|
||||||
../el/el_manager,
|
../el/el_manager,
|
||||||
../spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls],
|
../spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls],
|
||||||
../spec/[helpers, light_client_sync],
|
../spec/[helpers, light_client_sync],
|
||||||
@ -1501,7 +1501,7 @@ proc ETHTransactionsCreateFromJson(
|
|||||||
doAssert sizeof(int64) == sizeof(data.gasPrice)
|
doAssert sizeof(int64) == sizeof(data.gasPrice)
|
||||||
doAssert sizeof(int64) == sizeof(data.maxPriorityFeePerGas.get)
|
doAssert sizeof(int64) == sizeof(data.maxPriorityFeePerGas.get)
|
||||||
doAssert sizeof(UInt256) == sizeof(data.maxFeePerBlobGas.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
|
return nil
|
||||||
if distinctBase(data.gasPrice) > int64.high.uint64:
|
if distinctBase(data.gasPrice) > int64.high.uint64:
|
||||||
return nil
|
return nil
|
||||||
@ -1515,12 +1515,12 @@ proc ETHTransactionsCreateFromJson(
|
|||||||
return nil
|
return nil
|
||||||
if distinctBase(data.gas) > int64.high.uint64:
|
if distinctBase(data.gas) > int64.high.uint64:
|
||||||
return nil
|
return nil
|
||||||
if data.v > int64.high.u256:
|
if data.v.uint64 > int64.high.uint64:
|
||||||
return nil
|
return nil
|
||||||
let
|
let
|
||||||
tx = ExecutionTransaction(
|
tx = ExecutionTransaction(
|
||||||
txType: txType,
|
txType: txType,
|
||||||
chainId: data.chainId.get(default(UInt256)).truncate(uint64).ChainId,
|
chainId: data.chainId.get(0.Quantity).ChainId,
|
||||||
nonce: distinctBase(data.nonce),
|
nonce: distinctBase(data.nonce),
|
||||||
gasPrice: data.gasPrice.GasInt,
|
gasPrice: data.gasPrice.GasInt,
|
||||||
maxPriorityFee:
|
maxPriorityFee:
|
||||||
@ -1549,7 +1549,7 @@ proc ETHTransactionsCreateFromJson(
|
|||||||
ExecutionHash256(data: distinctBase(it)))
|
ExecutionHash256(data: distinctBase(it)))
|
||||||
else:
|
else:
|
||||||
@[],
|
@[],
|
||||||
V: data.v.truncate(uint64).int64,
|
V: data.v.int64,
|
||||||
R: data.r,
|
R: data.r,
|
||||||
S: data.s)
|
S: data.s)
|
||||||
rlpBytes =
|
rlpBytes =
|
||||||
@ -2105,7 +2105,7 @@ proc ETHReceiptsCreateFromJson(
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
# Check fork consistency
|
# 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!"
|
"Only update this number once code is adjusted to check new fields!"
|
||||||
static: doAssert totalSerializedFields(LogObject) == 9,
|
static: doAssert totalSerializedFields(LogObject) == 9,
|
||||||
"Only update this number once code is adjusted to check new fields!"
|
"Only update this number once code is adjusted to check new fields!"
|
||||||
@ -2133,16 +2133,26 @@ proc ETHReceiptsCreateFromJson(
|
|||||||
for log in data.logs:
|
for log in data.logs:
|
||||||
if log.removed:
|
if log.removed:
|
||||||
return nil
|
return nil
|
||||||
if distinctBase(log.logIndex) != logIndex + 1:
|
if log.logIndex.isNone:
|
||||||
return nil
|
return nil
|
||||||
logIndex = distinctBase(log.logIndex)
|
if distinctBase(log.logIndex.get) != logIndex + 1:
|
||||||
if log.transactionIndex != data.transactionIndex:
|
|
||||||
return nil
|
return nil
|
||||||
if log.transactionHash != data.transactionHash:
|
logIndex = distinctBase(log.logIndex.get)
|
||||||
|
if log.transactionIndex.isNone:
|
||||||
return nil
|
return nil
|
||||||
if log.blockHash != data.blockHash:
|
if log.transactionIndex.get != data.transactionIndex:
|
||||||
return nil
|
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
|
return nil
|
||||||
if log.data.len mod 32 != 0:
|
if log.data.len mod 32 != 0:
|
||||||
return nil
|
return nil
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
import
|
import
|
||||||
std/[sequtils, strutils, os],
|
std/[sequtils, strutils, os],
|
||||||
stew/[byteutils, objects], stew/shims/macros, nimcrypto/hash,
|
stew/[byteutils, objects], stew/shims/macros, nimcrypto/hash,
|
||||||
web3/[ethtypes, conversions],
|
web3/[conversions],
|
||||||
|
web3/primitives as web3types,
|
||||||
chronicles,
|
chronicles,
|
||||||
eth/common/eth_types_json_serialization,
|
eth/common/eth_types_json_serialization,
|
||||||
../spec/[eth2_ssz_serialization, forks]
|
../spec/[eth2_ssz_serialization, forks]
|
||||||
@ -29,7 +30,7 @@ import
|
|||||||
# from `currentSourcePath`.
|
# from `currentSourcePath`.
|
||||||
|
|
||||||
export
|
export
|
||||||
ethtypes, conversions, RuntimeConfig
|
web3types, conversions, RuntimeConfig
|
||||||
|
|
||||||
const
|
const
|
||||||
vendorDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor"
|
vendorDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor"
|
||||||
@ -37,7 +38,7 @@ const
|
|||||||
incbinEnabled* = sizeof(pointer) == 8
|
incbinEnabled* = sizeof(pointer) == 8
|
||||||
|
|
||||||
type
|
type
|
||||||
Eth1BlockHash* = ethtypes.BlockHash
|
Eth1BlockHash* = web3types.BlockHash
|
||||||
|
|
||||||
Eth1Network* = enum
|
Eth1Network* = enum
|
||||||
mainnet
|
mainnet
|
||||||
|
@ -27,8 +27,8 @@ export
|
|||||||
eth2_ssz_serialization, results, peerid, common, serialization, chronicles,
|
eth2_ssz_serialization, results, peerid, common, serialization, chronicles,
|
||||||
json_serialization, net, sets, rest_types, slashing_protection_common
|
json_serialization, net, sets, rest_types, slashing_protection_common
|
||||||
|
|
||||||
from web3/ethtypes import BlockHash
|
from web3/primitives import BlockHash
|
||||||
export ethtypes.BlockHash
|
export primitives.BlockHash
|
||||||
|
|
||||||
func decodeMediaType*(
|
func decodeMediaType*(
|
||||||
contentType: Opt[ContentTypeData]): Result[MediaType, string] =
|
contentType: Opt[ContentTypeData]): Result[MediaType, string] =
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
std/[json, tables],
|
std/[json, tables],
|
||||||
stew/base10, web3/ethtypes, httputils,
|
stew/base10, web3/primitives, httputils,
|
||||||
".."/forks,
|
".."/forks,
|
||||||
".."/datatypes/[phase0, altair, bellatrix, deneb],
|
".."/datatypes/[phase0, altair, bellatrix, deneb],
|
||||||
".."/mev/[capella_mev, deneb_mev]
|
".."/mev/[capella_mev, deneb_mev]
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
import
|
import
|
||||||
std/[strutils, parseutils, tables, typetraits],
|
std/[strutils, parseutils, tables, typetraits],
|
||||||
chronos/timer,
|
chronos/timer,
|
||||||
stew/[byteutils], stint, web3/[ethtypes],
|
stew/[byteutils], stint, web3/primitives as web3types,
|
||||||
./datatypes/constants
|
./datatypes/constants
|
||||||
|
|
||||||
export constants
|
export constants
|
||||||
|
|
||||||
export stint, ethtypes.toHex, ethtypes.`==`
|
export stint, web3types.toHex, web3types.`==`
|
||||||
|
|
||||||
const
|
const
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/beacon-chain.md#withdrawal-prefixes
|
# 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
|
type
|
||||||
Version* = distinct array[4, byte]
|
Version* = distinct array[4, byte]
|
||||||
Eth1Address* = ethtypes.Address
|
Eth1Address* = web3types.Address
|
||||||
|
|
||||||
RuntimeConfig* = object
|
RuntimeConfig* = object
|
||||||
## https://github.com/ethereum/consensus-specs/tree/v1.4.0-beta.4/configs
|
## https://github.com/ethereum/consensus-specs/tree/v1.4.0-beta.4/configs
|
||||||
|
@ -23,7 +23,7 @@ import
|
|||||||
chronicles, chronicles/timings,
|
chronicles, chronicles/timings,
|
||||||
json_serialization/std/[options, sets, net],
|
json_serialization/std/[options, sets, net],
|
||||||
eth/db/kvstore,
|
eth/db/kvstore,
|
||||||
web3/ethtypes,
|
web3/primitives,
|
||||||
kzg4844,
|
kzg4844,
|
||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import
|
import
|
||||||
std/[json, strutils, times, sequtils],
|
std/[json, strutils, times, sequtils],
|
||||||
chronos, confutils, chronicles,
|
chronos, confutils, chronicles,
|
||||||
web3, web3/ethtypes as web3Types,
|
web3, web3/primitives,
|
||||||
eth/async_utils,
|
eth/async_utils,
|
||||||
../beacon_chain/beacon_chain_db,
|
../beacon_chain/beacon_chain_db,
|
||||||
../beacon_chain/networking/network_metadata,
|
../beacon_chain/networking/network_metadata,
|
||||||
|
@ -29,7 +29,8 @@ from std/times import toUnix
|
|||||||
|
|
||||||
# Compiled version of /scripts/depositContract.v.py in this repo
|
# Compiled version of /scripts/depositContract.v.py in this repo
|
||||||
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
|
# 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
|
# For nim-confutils, which uses this kind of init(Type, value) pattern
|
||||||
func init(T: type IpAddress, ip: IpAddress): T = ip
|
func init(T: type IpAddress, ip: IpAddress): T = ip
|
||||||
@ -282,7 +283,7 @@ contract(DepositContract):
|
|||||||
signature: SignatureBytes,
|
signature: SignatureBytes,
|
||||||
deposit_data_root: FixedBytes[32])
|
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))
|
T(data: distinctBase(address))
|
||||||
|
|
||||||
template `as`(address: BlockHash, T: type Eth2Digest): T =
|
template `as`(address: BlockHash, T: type Eth2Digest): T =
|
||||||
@ -508,24 +509,21 @@ proc doCreateTestnet*(config: CliConfig,
|
|||||||
writeFile(bootstrapFile, enr.toURI)
|
writeFile(bootstrapFile, enr.toURI)
|
||||||
echo "Wrote ", bootstrapFile
|
echo "Wrote ", bootstrapFile
|
||||||
|
|
||||||
proc deployContract(web3: Web3, code: string): Future[ReceiptObject] {.async.} =
|
proc deployContract(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} =
|
||||||
var code = code
|
|
||||||
if code[1] notin {'x', 'X'}:
|
|
||||||
code = "0x" & code
|
|
||||||
let tr = EthSend(
|
let tr = EthSend(
|
||||||
source: web3.defaultAccount,
|
`from`: web3.defaultAccount,
|
||||||
data: code,
|
data: code,
|
||||||
gas: Quantity(3000000).some,
|
gas: Quantity(3000000).some,
|
||||||
gasPrice: 1.some)
|
gasPrice: Quantity(1).some)
|
||||||
|
|
||||||
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[TxHash] =
|
||||||
let tr = EthSend(
|
let tr = EthSend(
|
||||||
source: web3.defaultAccount,
|
`from`: web3.defaultAccount,
|
||||||
gas: Quantity(3000000).some,
|
gas: Quantity(3000000).some,
|
||||||
gasPrice: 1.some,
|
gasPrice: Quantity(1).some,
|
||||||
value: some(valueEth.u256 * 1000000000000000000.u256),
|
value: some(valueEth.u256 * 1000000000000000000.u256),
|
||||||
to: some(to))
|
to: some(to))
|
||||||
web3.send(tr)
|
web3.send(tr)
|
||||||
|
@ -13,7 +13,7 @@ import
|
|||||||
std/typetraits,
|
std/typetraits,
|
||||||
stew/byteutils,
|
stew/byteutils,
|
||||||
json_rpc/[rpcserver, errors],
|
json_rpc/[rpcserver, errors],
|
||||||
web3/[conversions, engine_api_types],
|
web3/[conversions, engine_api_types, eth_api_types],
|
||||||
chronicles
|
chronicles
|
||||||
|
|
||||||
proc setupEngineAPI*(server: RpcServer) =
|
proc setupEngineAPI*(server: RpcServer) =
|
||||||
|
@ -11,7 +11,7 @@ import
|
|||||||
# Status libraries
|
# Status libraries
|
||||||
stew/bitops2,
|
stew/bitops2,
|
||||||
eth/common/eth_types as commonEthTypes, eth/common/eth_types_rlp,
|
eth/common/eth_types as commonEthTypes, eth/common/eth_types_rlp,
|
||||||
web3/ethtypes,
|
web3/primitives,
|
||||||
# Beacon chain internals
|
# Beacon chain internals
|
||||||
../beacon_chain/spec/[forks, helpers, state_transition],
|
../beacon_chain/spec/[forks, helpers, state_transition],
|
||||||
../beacon_chain/spec/datatypes/[bellatrix, capella],
|
../beacon_chain/spec/datatypes/[bellatrix, capella],
|
||||||
|
2
vendor/nim-json-rpc
vendored
2
vendor/nim-json-rpc
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 60c4c9b5f28b530d5d89fd14c337af1d86390a82
|
Subproject commit a8731e91bc336d930ac66f985d3b88ed7cf2a7d7
|
2
vendor/nim-web3
vendored
2
vendor/nim-web3
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 428b931e7c4f1284b4272bc2c11fca2bd70991cd
|
Subproject commit df0af1aca64f6a1a9a76c92776ce2b2ee0c6bfec
|
Loading…
x
Reference in New Issue
Block a user