fix deprecated warnings (#6606)
This commit is contained in:
parent
5d11c5229b
commit
3f37caa0da
|
@ -12,7 +12,7 @@ import
|
|||
chronos, chronicles, confutils, stint, json_serialization,
|
||||
../filepath,
|
||||
../networking/network_metadata,
|
||||
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
|
||||
web3, web3/confutils_defs, eth/common/keys, eth/p2p/discoveryv5/random2,
|
||||
stew/[io2, byteutils],
|
||||
../spec/eth2_merkleization,
|
||||
../spec/datatypes/base,
|
||||
|
|
|
@ -56,7 +56,7 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV1):
|
|||
gas_limit: rpcExecutionPayload.gasLimit.uint64,
|
||||
gas_used: rpcExecutionPayload.gasUsed.uint64,
|
||||
timestamp: rpcExecutionPayload.timestamp.uint64,
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(rpcExecutionPayload.extraData.bytes),
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(rpcExecutionPayload.extraData.data),
|
||||
base_fee_per_gas: rpcExecutionPayload.baseFeePerGas,
|
||||
block_hash: rpcExecutionPayload.blockHash.asEth2Digest,
|
||||
transactions: List[bellatrix.Transaction, MAX_TRANSACTIONS_PER_PAYLOAD].init(
|
||||
|
@ -88,7 +88,7 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV1OrV2|ExecutionPaylo
|
|||
gas_limit: rpcExecutionPayload.gasLimit.uint64,
|
||||
gas_used: rpcExecutionPayload.gasUsed.uint64,
|
||||
timestamp: rpcExecutionPayload.timestamp.uint64,
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(rpcExecutionPayload.extraData.bytes),
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(rpcExecutionPayload.extraData.data),
|
||||
base_fee_per_gas: rpcExecutionPayload.baseFeePerGas,
|
||||
block_hash: rpcExecutionPayload.blockHash.asEth2Digest,
|
||||
transactions: List[bellatrix.Transaction, MAX_TRANSACTIONS_PER_PAYLOAD].init(
|
||||
|
@ -119,7 +119,7 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV3):
|
|||
gas_limit: rpcExecutionPayload.gasLimit.uint64,
|
||||
gas_used: rpcExecutionPayload.gasUsed.uint64,
|
||||
timestamp: rpcExecutionPayload.timestamp.uint64,
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(rpcExecutionPayload.extraData.bytes),
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(rpcExecutionPayload.extraData.data),
|
||||
base_fee_per_gas: rpcExecutionPayload.baseFeePerGas,
|
||||
block_hash: rpcExecutionPayload.blockHash.asEth2Digest,
|
||||
transactions: List[bellatrix.Transaction, MAX_TRANSACTIONS_PER_PAYLOAD].init(
|
||||
|
@ -141,12 +141,12 @@ func asConsensusType*(payload: engine_api.GetPayloadV3Response):
|
|||
blobsBundle: deneb.BlobsBundle(
|
||||
commitments: KzgCommitments.init(
|
||||
payload.blobsBundle.commitments.mapIt(
|
||||
kzg_abi.KzgCommitment(bytes: it.bytes))),
|
||||
kzg_abi.KzgCommitment(bytes: it.data))),
|
||||
proofs: KzgProofs.init(
|
||||
payload.blobsBundle.proofs.mapIt(
|
||||
kzg_abi.KzgProof(bytes: it.bytes))),
|
||||
kzg_abi.KzgProof(bytes: it.data))),
|
||||
blobs: Blobs.init(
|
||||
payload.blobsBundle.blobs.mapIt(it.bytes))))
|
||||
payload.blobsBundle.blobs.mapIt(it.data))))
|
||||
|
||||
func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
|
||||
electra.ExecutionPayload =
|
||||
|
@ -189,7 +189,7 @@ func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV4):
|
|||
gas_used: rpcExecutionPayload.gasUsed.uint64,
|
||||
timestamp: rpcExecutionPayload.timestamp.uint64,
|
||||
extra_data: List[byte, MAX_EXTRA_DATA_BYTES].init(
|
||||
rpcExecutionPayload.extraData.bytes),
|
||||
rpcExecutionPayload.extraData.data),
|
||||
base_fee_per_gas: rpcExecutionPayload.baseFeePerGas,
|
||||
block_hash: rpcExecutionPayload.blockHash.asEth2Digest,
|
||||
transactions: List[bellatrix.Transaction, MAX_TRANSACTIONS_PER_PAYLOAD].init(
|
||||
|
@ -211,12 +211,12 @@ func asConsensusType*(payload: engine_api.GetPayloadV4Response):
|
|||
blobsBundle: deneb.BlobsBundle(
|
||||
commitments: KzgCommitments.init(
|
||||
payload.blobsBundle.commitments.mapIt(
|
||||
kzg_abi.KzgCommitment(bytes: it.bytes))),
|
||||
kzg_abi.KzgCommitment(bytes: it.data))),
|
||||
proofs: KzgProofs.init(
|
||||
payload.blobsBundle.proofs.mapIt(
|
||||
kzg_abi.KzgProof(bytes: it.bytes))),
|
||||
kzg_abi.KzgProof(bytes: it.data))),
|
||||
blobs: Blobs.init(
|
||||
payload.blobsBundle.blobs.mapIt(it.bytes))))
|
||||
payload.blobsBundle.blobs.mapIt(it.data))))
|
||||
|
||||
func asEngineExecutionPayload*(blockBody: bellatrix.BeaconBlockBody):
|
||||
ExecutionPayloadV1 =
|
||||
|
|
|
@ -36,7 +36,7 @@ template toGaugeValue*(x: Quantity | BlockNumber): int64 =
|
|||
toGaugeValue(distinctBase x)
|
||||
|
||||
type
|
||||
Eth1BlockNumber* = BlockNumber
|
||||
Eth1BlockNumber* = Quantity
|
||||
Eth1BlockTimestamp* = uint64
|
||||
|
||||
Eth1BlockObj* = object
|
||||
|
|
|
@ -43,7 +43,7 @@ const
|
|||
incbinEnabled* = sizeof(pointer) == 8
|
||||
|
||||
type
|
||||
Eth1BlockHash* = web3types.BlockHash
|
||||
Eth1BlockHash* = web3types.Hash32
|
||||
|
||||
Eth1Network* = enum
|
||||
mainnet
|
||||
|
|
|
@ -25,8 +25,8 @@ export
|
|||
json_serialization, net, sets, rest_types, slashing_protection_common,
|
||||
jsonSerializationResults, rest_keymanager_types
|
||||
|
||||
from web3/primitives import BlockHash, BlockNumber
|
||||
export primitives.BlockHash, primitives.BlockNumber
|
||||
from web3/primitives import Hash32, Quantity
|
||||
export primitives.Hash32, primitives.Quantity
|
||||
|
||||
func decodeMediaType*(
|
||||
contentType: Opt[ContentTypeData]): Result[MediaType, string] =
|
||||
|
@ -995,14 +995,14 @@ proc readValue*(reader: var JsonReader[RestJson], value: var uint8) {.
|
|||
else:
|
||||
reader.raiseUnexpectedValue($res.error() & ": " & svalue)
|
||||
|
||||
## BlockNumber
|
||||
## BlockNumber/Quantity
|
||||
proc writeValue*(
|
||||
w: var JsonWriter[RestJson], value: BlockNumber) {.raises: [IOError].} =
|
||||
w: var JsonWriter[RestJson], value: Quantity) {.raises: [IOError].} =
|
||||
w.writeValue(distinctBase(value))
|
||||
|
||||
proc readValue*(
|
||||
reader: var JsonReader[RestJson],
|
||||
value: var BlockNumber) {.raises: [IOError, SerializationError].} =
|
||||
value: var Quantity) {.raises: [IOError, SerializationError].} =
|
||||
reader.readValue(distinctBase(value))
|
||||
|
||||
## RestNumeric
|
||||
|
@ -1272,17 +1272,17 @@ proc writeValue*(
|
|||
writer: var JsonWriter[RestJson], value: BitArray) {.raises: [IOError].} =
|
||||
writeValue(writer, hexOriginal(value.bytes))
|
||||
|
||||
## BlockHash
|
||||
proc readValue*(reader: var JsonReader[RestJson], value: var BlockHash) {.
|
||||
## BlockHash/Hash32
|
||||
proc readValue*(reader: var JsonReader[RestJson], value: var Hash32) {.
|
||||
raises: [IOError, SerializationError].} =
|
||||
try:
|
||||
hexToByteArray(reader.readValue(string), distinctBase(value))
|
||||
except ValueError:
|
||||
raiseUnexpectedValue(reader,
|
||||
"BlockHash value should be a valid hex string")
|
||||
"Hash32 value should be a valid hex string")
|
||||
|
||||
proc writeValue*(
|
||||
writer: var JsonWriter[RestJson], value: BlockHash) {.raises: [IOError].} =
|
||||
writer: var JsonWriter[RestJson], value: Hash32) {.raises: [IOError].} =
|
||||
writeValue(writer, hexOriginal(distinctBase(value)))
|
||||
|
||||
## Eth2Digest
|
||||
|
|
|
@ -35,14 +35,14 @@ func toGwei*(eth: Ether): Gwei =
|
|||
distinctBase(eth) * ETH_TO_GWEI
|
||||
|
||||
type
|
||||
ExecutionHash256* = eth_types.Hash256
|
||||
ExecutionHash256* = eth_types.Hash32
|
||||
ExecutionTransaction* = eth_types.Transaction
|
||||
ExecutionReceipt* = eth_types.Receipt
|
||||
ExecutionWithdrawal* = eth_types.Withdrawal
|
||||
ExecutionDepositRequest* = eth_types.DepositRequest
|
||||
ExecutionWithdrawalRequest* = eth_types.WithdrawalRequest
|
||||
ExecutionConsolidationRequest* = eth_types.ConsolidationRequest
|
||||
ExecutionBlockHeader* = eth_types.BlockHeader
|
||||
ExecutionBlockHeader* = eth_types.Header
|
||||
|
||||
FinalityCheckpoints* = object
|
||||
justified*: Checkpoint
|
||||
|
@ -592,7 +592,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
|||
stateRoot : payload.state_root.to(Root),
|
||||
transactionsRoot : txRoot,
|
||||
receiptsRoot : payload.receipts_root.to(Root),
|
||||
logsBloom : BloomFilter payload.logs_bloom.data.to(Bloom),
|
||||
logsBloom : Bloom payload.logs_bloom.data.to(Bloom),
|
||||
difficulty : default(DifficultyInt),
|
||||
number : payload.block_number,
|
||||
gasLimit : payload.gas_limit,
|
||||
|
@ -600,7 +600,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
|||
timestamp : EthTime(payload.timestamp),
|
||||
extraData : payload.extra_data.asSeq,
|
||||
mixHash : Bytes32 payload.prev_randao.data, # EIP-4399 `mixHash` -> `prevRandao`
|
||||
nonce : default(BlockNonce),
|
||||
nonce : default(Bytes8),
|
||||
baseFeePerGas : Opt.some payload.base_fee_per_gas,
|
||||
withdrawalsRoot : withdrawalsRoot,
|
||||
blobGasUsed : blobGasUsed, # EIP-4844
|
||||
|
|
|
@ -42,7 +42,7 @@ type
|
|||
|
||||
# Transition
|
||||
TERMINAL_TOTAL_DIFFICULTY*: UInt256
|
||||
TERMINAL_BLOCK_HASH*: BlockHash
|
||||
TERMINAL_BLOCK_HASH*: Hash32
|
||||
TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH*: Epoch # Not actively used, but part of the spec
|
||||
|
||||
# Genesis
|
||||
|
@ -164,7 +164,7 @@ when const_preset == "mainnet":
|
|||
TERMINAL_TOTAL_DIFFICULTY:
|
||||
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
|
||||
# By default, don't use these params
|
||||
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
|
||||
TERMINAL_BLOCK_HASH: Hash32.fromHex(
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||
|
||||
# Genesis
|
||||
|
@ -643,8 +643,8 @@ template parse(T: type string, input: string): T =
|
|||
template parse(T: type Eth1Address, input: string): T =
|
||||
Eth1Address.fromHex(input)
|
||||
|
||||
template parse(T: type BlockHash, input: string): T =
|
||||
BlockHash.fromHex(input)
|
||||
template parse(T: type Hash32, input: string): T =
|
||||
Hash32.fromHex(input)
|
||||
|
||||
template parse(T: type UInt256, input: string): T =
|
||||
parse(input, UInt256, 10)
|
||||
|
|
|
@ -81,7 +81,7 @@ proc setupEngineAPI*(server: RpcServer) =
|
|||
info "eth_getBlockByNumber", quantityTag, fullTransactions
|
||||
|
||||
return if quantityTag == "latest":
|
||||
JrpcConv.encode(BlockObject(number: 1000.BlockNumber)).JsonString
|
||||
JrpcConv.encode(BlockObject(number: 1000.Quantity)).JsonString
|
||||
else:
|
||||
"{}".JsonString
|
||||
|
||||
|
@ -89,7 +89,7 @@ proc setupEngineAPI*(server: RpcServer) =
|
|||
data: string, fullTransactions: bool) -> BlockObject:
|
||||
info "eth_getBlockByHash", data = toHex(data), fullTransactions
|
||||
|
||||
return BlockObject(number: 1000.BlockNumber)
|
||||
return BlockObject(number: 1000.Quantity)
|
||||
|
||||
server.rpc("eth_chainId") do() -> Quantity:
|
||||
info "eth_chainId"
|
||||
|
|
Loading…
Reference in New Issue