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