diff --git a/beacon_chain/beacon_node_light_client.nim b/beacon_chain/beacon_node_light_client.nim index 1df0ddb37..b6e15b06b 100644 --- a/beacon_chain/beacon_node_light_client.nim +++ b/beacon_chain/beacon_node_light_client.nim @@ -73,7 +73,7 @@ proc initLightClient*( headBlockHash = blckPayload.block_hash, safeBlockHash = beaconHead.safeExecutionBlockHash, finalizedBlockHash = beaconHead.finalizedExecutionBlockHash, - payloadAttributes = none attributes) + payloadAttributes = Opt.none attributes) case node.dag.cfg.consensusForkAtEpoch( forkyBlck.message.slot.epoch) diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim index 50fcec775..b561e854e 100644 --- a/beacon_chain/consensus_object_pools/consensus_manager.nim +++ b/beacon_chain/consensus_object_pools/consensus_manager.nim @@ -184,7 +184,7 @@ proc updateExecutionClientHead*( headBlockHash = headExecutionBlockHash, safeBlockHash = newHead.safeExecutionBlockHash, finalizedBlockHash = newHead.finalizedExecutionBlockHash, - payloadAttributes = none attributes) + payloadAttributes = Opt.none attributes) # Can't use dag.head here because it hasn't been updated yet let @@ -374,7 +374,7 @@ proc runProposalForkchoiceUpdated*( let (status, _) = await self.elManager.forkchoiceUpdated( headBlockHash, safeBlockHash, beaconHead.finalizedExecutionBlockHash, - payloadAttributes = some fcPayloadAttributes) + payloadAttributes = Opt.some fcPayloadAttributes) debug "Fork-choice updated for proposal", status static: doAssert high(ConsensusFork) == ConsensusFork.Electra diff --git a/beacon_chain/el/deposit_contract.nim b/beacon_chain/el/deposit_contract.nim index 213907879..1dcdfccef 100644 --- a/beacon_chain/el/deposit_contract.nim +++ b/beacon_chain/el/deposit_contract.nim @@ -123,25 +123,25 @@ contract(DepositContract): proc deployContract*(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, - data: code.some, - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some) + `from`: Opt.some web3.defaultAccount, + data: Opt.some code, + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1)) let r = await web3.send(tr) result = await web3.getMinedTransactionReceipt(r) proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, + `from`: Opt.some web3.defaultAccount, # TODO: Force json-rpc to generate 'data' field # should not be needed anymore, new execution-api schema # is using `input` field - data: some(newSeq[byte]()), - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some, - value: some(valueEth.u256 * 1000000000000000000.u256), - to: some(to)) + data: Opt.some(newSeq[byte]()), + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1), + value: Opt.some(valueEth.u256 * 1000000000000000000.u256), + to: Opt.some(to)) web3.send(tr) type @@ -153,7 +153,7 @@ proc ethToWei(eth: UInt256): UInt256 = proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} = result = await newWeb3(web3Url) if privateKey.len != 0: - result.privateKey = some(PrivateKey.fromHex(privateKey)[]) + result.privateKey = Opt.some(PrivateKey.fromHex(privateKey)[]) else: let accounts = await result.provider.eth_accounts() doAssert(accounts.len > 0) diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index e204f68db..d2e754c87 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -106,7 +106,7 @@ type Running, Closing, Closed ELManager* = ref object - eth1Network: Option[Eth1Network] + eth1Network: Opt[Eth1Network] ## If this value is supplied the EL manager will check whether ## all configured EL nodes are connected to the same network. @@ -133,7 +133,7 @@ type ## also includes blocks without deposits because we must ## vote for a block only if it's part of our known history. - syncTargetBlock: Option[Eth1BlockNumber] + syncTargetBlock: Opt[Eth1BlockNumber] chainSyncingLoopFut: Future[void] exchangeTransitionConfigurationLoopFut: Future[void] @@ -177,7 +177,7 @@ type depositContractSyncStatus: DepositContractSyncStatus ## Are we sure that this EL has synced the deposit contract? - lastPayloadId: Option[PayloadID] + lastPayloadId: Opt[PayloadID] FullBlockId* = object number: Eth1BlockNumber @@ -419,7 +419,7 @@ func asConsensusType*(payloadWithValue: BellatrixExecutionPayloadWithValue): executionPayload: payloadWithValue.executionPayload.asConsensusType, blockValue: payloadWithValue.blockValue) -template maybeDeref[T](o: Option[T]): T = o.get +template maybeDeref[T](o: Opt[T]): T = o.get template maybeDeref[V](v: V): V = v func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV1OrV2|ExecutionPayloadV2): @@ -779,15 +779,15 @@ func areSameAs(expectedParams: Option[NextExpectedPayloadParams], proc forkchoiceUpdated(rpcClient: RpcClient, state: ForkchoiceStateV1, - payloadAttributes: Option[PayloadAttributesV1] | - Option[PayloadAttributesV2] | - Option[PayloadAttributesV3]): + payloadAttributes: Opt[PayloadAttributesV1] | + Opt[PayloadAttributesV2] | + Opt[PayloadAttributesV3]): Future[ForkchoiceUpdatedResponse] = - when payloadAttributes is Option[PayloadAttributesV1]: + when payloadAttributes is Opt[PayloadAttributesV1]: rpcClient.engine_forkchoiceUpdatedV1(state, payloadAttributes) - elif payloadAttributes is Option[PayloadAttributesV2]: + elif payloadAttributes is Opt[PayloadAttributesV2]: rpcClient.engine_forkchoiceUpdatedV2(state, payloadAttributes) - elif payloadAttributes is Option[PayloadAttributesV3]: + elif payloadAttributes is Opt[PayloadAttributesV3]: rpcClient.engine_forkchoiceUpdatedV3(state, payloadAttributes) else: static: doAssert false @@ -817,7 +817,7 @@ proc getPayloadFromSingleEL( headBlockHash: headBlock.asBlockHash, safeBlockHash: safeBlock.asBlockHash, finalizedBlockHash: finalizedBlock.asBlockHash), - some PayloadAttributesV1( + Opt.some PayloadAttributesV1( timestamp: Quantity timestamp, prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient)) @@ -827,7 +827,7 @@ proc getPayloadFromSingleEL( headBlockHash: headBlock.asBlockHash, safeBlockHash: safeBlock.asBlockHash, finalizedBlockHash: finalizedBlock.asBlockHash), - some PayloadAttributesV2( + Opt.some PayloadAttributesV2( timestamp: Quantity timestamp, prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient, @@ -841,7 +841,7 @@ proc getPayloadFromSingleEL( headBlockHash: headBlock.asBlockHash, safeBlockHash: safeBlock.asBlockHash, finalizedBlockHash: finalizedBlock.asBlockHash), - some PayloadAttributesV3( + Opt.some PayloadAttributesV3( timestamp: Quantity timestamp, prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient, @@ -1341,9 +1341,9 @@ proc sendNewPayload*( proc forkchoiceUpdatedForSingleEL( connection: ELConnection, state: ref ForkchoiceStateV1, - payloadAttributes: Option[PayloadAttributesV1] | - Option[PayloadAttributesV2] | - Option[PayloadAttributesV3] + payloadAttributes: Opt[PayloadAttributesV1] | + Opt[PayloadAttributesV2] | + Opt[PayloadAttributesV3] ): Future[PayloadStatusV1] {.async: (raises: [CatchableError]).} = let rpcClient = await connection.connectedRpcClient() @@ -1363,10 +1363,10 @@ proc forkchoiceUpdatedForSingleEL( proc forkchoiceUpdated*( m: ELManager, headBlockHash, safeBlockHash, finalizedBlockHash: Eth2Digest, - payloadAttributes: Option[PayloadAttributesV1] | - Option[PayloadAttributesV2] | - Option[PayloadAttributesV3] -): Future[(PayloadExecutionStatus, Option[BlockHash])] {. + payloadAttributes: Opt[PayloadAttributesV1] | + Opt[PayloadAttributesV2] | + Opt[PayloadAttributesV3] +): Future[(PayloadExecutionStatus, Opt[BlockHash])] {. async: (raises: [CancelledError]).} = doAssert not headBlockHash.isZero @@ -1383,16 +1383,16 @@ proc forkchoiceUpdated*( # payload (`Hash32()` if none yet finalized)" if m.elConnections.len == 0: - return (PayloadExecutionStatus.syncing, none BlockHash) + return (PayloadExecutionStatus.syncing, Opt.none BlockHash) - when payloadAttributes is Option[PayloadAttributesV3]: + when payloadAttributes is Opt[PayloadAttributesV3]: template payloadAttributesV3(): auto = if payloadAttributes.isSome: payloadAttributes.get else: # As timestamp and prevRandao are both 0, won't false-positive match (static(default(PayloadAttributesV3))) - elif payloadAttributes is Option[PayloadAttributesV2]: + elif payloadAttributes is Opt[PayloadAttributesV2]: template payloadAttributesV3(): auto = if payloadAttributes.isSome: PayloadAttributesV3( @@ -1404,7 +1404,7 @@ proc forkchoiceUpdated*( else: # As timestamp and prevRandao are both 0, won't false-positive match (static(default(PayloadAttributesV3))) - elif payloadAttributes is Option[PayloadAttributesV1]: + elif payloadAttributes is Opt[PayloadAttributesV1]: template payloadAttributesV3(): auto = if payloadAttributes.isSome: PayloadAttributesV3( @@ -1489,7 +1489,7 @@ proc forkchoiceUpdated*( pendingRequests.filterIt(not(it.finished())). mapIt(it.cancelAndWait()) await noCancel allFutures(pending) - return (PayloadExecutionStatus.invalid, none BlockHash) + return (PayloadExecutionStatus.invalid, Opt.none BlockHash) elif responseProcessor.selectedResponse.isSome: # We spawn task which will wait for all other responses which are # still pending, after 30.seconds all pending requests will be @@ -1504,7 +1504,7 @@ proc forkchoiceUpdated*( pendingRequests.filterIt(not(it.finished())). mapIt(it.cancelAndWait()) await noCancel allFutures(pending) - return (PayloadExecutionStatus.syncing, none BlockHash) + return (PayloadExecutionStatus.syncing, Opt.none BlockHash) if len(pendingRequests) == 0: # All requests failed, we will continue our attempts until deadline @@ -1762,7 +1762,7 @@ proc new*(T: type ELManager, depositContractBlockHash: Eth2Digest, db: BeaconChainDB, engineApiUrls: seq[EngineApiUrl], - eth1Network: Option[Eth1Network]): T = + eth1Network: Opt[Eth1Network]): T = let eth1Chain = Eth1Chain.init( cfg, db, depositContractBlockNumber, depositContractBlockHash) @@ -1847,8 +1847,8 @@ proc syncBlockRange( await connection.engineApiRequest( depositContract.getJsonLogs( DepositEvent, - fromBlock = some blockId(currentBlock), - toBlock = some blockId(maxBlockNumberRequested)), + fromBlock = Opt.some blockId(currentBlock), + toBlock = Opt.some blockId(maxBlockNumberRequested)), "getLogs", Moment.now(), 30.seconds) except CancelledError as exc: debug "Request for deposit logs was interrupted" @@ -2089,7 +2089,7 @@ proc syncEth1Chain( latestBlockNumber = latestBlock.number - m.syncTargetBlock = some( + m.syncTargetBlock = Opt.some( if latestBlock.number > m.cfg.ETH1_FOLLOW_DISTANCE.Eth1BlockNumber: latestBlock.number - m.cfg.ETH1_FOLLOW_DISTANCE else: diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index 1eb1b86b4..bfef52d31 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -242,7 +242,7 @@ proc expectValidForkchoiceUpdated( headBlockHash = headBlockHash, safeBlockHash = safeBlockHash, finalizedBlockHash = finalizedBlockHash, - payloadAttributes = none headBlockPayloadAttributesType) + payloadAttributes = Opt.none headBlockPayloadAttributesType) receivedExecutionBlockHash = when typeof(receivedBlock).kind >= ConsensusFork.Bellatrix: receivedBlock.message.body.execution_payload.block_hash @@ -684,7 +684,7 @@ proc storeBlock( self.consensusManager[].optimisticExecutionBlockHash, safeBlockHash = newHead.get.safeExecutionBlockHash, finalizedBlockHash = newHead.get.finalizedExecutionBlockHash, - payloadAttributes = none attributes) + payloadAttributes = Opt.none attributes) let consensusFork = self.consensusManager.dag.cfg.consensusForkAtEpoch( newHead.get.blck.bid.slot.epoch) diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index b3ae420ab..c3aa4eac9 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -9,7 +9,6 @@ import std/[json, sequtils, times], - stew/saturation_arith, eth/common/[eth_types_rlp, transaction], eth/keys, eth/p2p/discoveryv5/random2, @@ -1254,37 +1253,37 @@ proc ETHExecutionBlockHeaderCreateFromJson( coinbase: distinctBase(data.miner), stateRoot: data.stateRoot.asEth2Digest, txRoot: data.transactionsRoot.asEth2Digest, - receiptRoot: data.receiptsRoot.asEth2Digest, - bloom: distinctBase(data.logsBloom), + receiptsRoot: data.receiptsRoot.asEth2Digest, + logsBloom: distinctBase(data.logsBloom), difficulty: data.difficulty, - blockNumber: distinctBase(data.number).u256, - gasLimit: cast[int64](data.gasLimit), - gasUsed: cast[int64](data.gasUsed), - timestamp: EthTime(int64.saturate distinctBase(data.timestamp)), + number: distinctBase(data.number), + gasLimit: distinctBase(data.gasLimit), + gasUsed: distinctBase(data.gasUsed), + timestamp: EthTime(distinctBase(data.timestamp)), extraData: distinctBase(data.extraData), - mixDigest: data.mixHash.asEth2Digest, + mixHash: data.mixHash.asEth2Digest, nonce: distinctBase(data.nonce.get), - fee: data.baseFeePerGas, + baseFeePerGas: data.baseFeePerGas, withdrawalsRoot: if data.withdrawalsRoot.isSome: - some(data.withdrawalsRoot.get.asEth2Digest) + Opt.some(data.withdrawalsRoot.get.asEth2Digest) else: - none(ExecutionHash256), + Opt.none(ExecutionHash256), blobGasUsed: if data.blobGasUsed.isSome: - some distinctBase(data.blobGasUsed.get) + Opt.some distinctBase(data.blobGasUsed.get) else: - none(uint64), + Opt.none(uint64), excessBlobGas: if data.excessBlobGas.isSome: - some distinctBase(data.excessBlobGas.get) + Opt.some distinctBase(data.excessBlobGas.get) else: - none(uint64), + Opt.none(uint64), parentBeaconBlockRoot: if data.parentBeaconBlockRoot.isSome: - some distinctBase(data.parentBeaconBlockRoot.get.asEth2Digest) + Opt.some distinctBase(data.parentBeaconBlockRoot.get.asEth2Digest) else: - none(ExecutionHash256)) + Opt.none(ExecutionHash256)) if rlpHash(blockHeader) != executionHash[]: return nil @@ -1529,15 +1528,15 @@ proc ETHTransactionsCreateFromJson( chainId: data.chainId.get(0.Quantity).ChainId, nonce: distinctBase(data.nonce), gasPrice: data.gasPrice.GasInt, - maxPriorityFee: + maxPriorityFeePerGas: distinctBase(data.maxPriorityFeePerGas.get(data.gasPrice)).GasInt, - maxFee: distinctBase(data.maxFeePerGas.get(data.gasPrice)).GasInt, + maxFeePerGas: distinctBase(data.maxFeePerGas.get(data.gasPrice)).GasInt, gasLimit: distinctBase(data.gas).GasInt, to: if data.to.isSome: - some(distinctBase(data.to.get)) + Opt.some(distinctBase(data.to.get)) else: - none(EthAddress), + Opt.none(EthAddress), value: data.value, payload: data.input, accessList: @@ -1555,7 +1554,7 @@ proc ETHTransactionsCreateFromJson( ExecutionHash256(data: distinctBase(it))) else: @[], - V: data.v.int64, + V: data.v.uint64, R: data.r, S: data.s) rlpBytes = @@ -1567,7 +1566,7 @@ proc ETHTransactionsCreateFromJson( if data.hash.asEth2Digest != hash: return nil - template isEven(x: int64): bool = + template isEven(x: uint64): bool = (x and 1) == 0 # Compute from execution address @@ -1614,9 +1613,9 @@ proc ETHTransactionsCreateFromJson( chainId: distinctBase(tx.chainId).u256, `from`: ExecutionAddress(data: fromAddress), nonce: tx.nonce, - maxPriorityFeePerGas: tx.maxPriorityFee.uint64, - maxFeePerGas: tx.maxFee.uint64, - gas: tx.gasLimit.uint64, + maxPriorityFeePerGas: tx.maxPriorityFeePerGas, + maxFeePerGas: tx.maxFeePerGas, + gas: tx.gasLimit, destinationType: destinationType, to: ExecutionAddress(data: toAddress), value: tx.value, @@ -2178,7 +2177,7 @@ proc ETHReceiptsCreateFromJson( else: default(ExecutionHash256), cumulativeGasUsed: distinctBase(data.cumulativeGasUsed).GasInt, - bloom: distinctBase(data.logsBloom), + logsBloom: distinctBase(data.logsBloom), logs: data.logs.mapIt(Log( address: distinctBase(it.address), topics: it.topics.mapIt(distinctBase(it)), @@ -2198,7 +2197,7 @@ proc ETHReceiptsCreateFromJson( root: rec.hash, status: rec.status, gasUsed: distinctBase(data.gasUsed), # Validated during sanity checks. - logsBloom: BloomLogs(data: rec.bloom), + logsBloom: BloomLogs(data: rec.logsBloom), logs: rec.logs.mapIt(ETHLog( address: ExecutionAddress(data: it.address), topics: it.topics.mapIt(Eth2Digest(data: it)), diff --git a/beacon_chain/networking/network_metadata.nim b/beacon_chain/networking/network_metadata.nim index 7d7d8c954..3ba5f45b7 100644 --- a/beacon_chain/networking/network_metadata.nim +++ b/beacon_chain/networking/network_metadata.nim @@ -78,7 +78,7 @@ type # additional checks to ensure we are connecting to a web3 provider # serving data for the same network. The value can be set to `None` # for custom networks and testing purposes. - eth1Network*: Option[Eth1Network] + eth1Network*: Opt[Eth1Network] cfg*: RuntimeConfig # Parsing `enr.Records` is still not possible at compile-time @@ -112,10 +112,10 @@ proc readBootEnr*(path: string): seq[string] {.raises: [IOError].} = proc loadEth2NetworkMetadata*( path: string, - eth1Network = none(Eth1Network), + eth1Network = Opt.none(Eth1Network), isCompileTime = false, - downloadGenesisFrom = none(DownloadInfo), - useBakedInGenesis = none(string) + downloadGenesisFrom = Opt.none(DownloadInfo), + useBakedInGenesis = Opt.none(string) ): Result[Eth2NetworkMetadata, string] {.raises: [IOError, PresetFileError].} = # Load data in mainnet format # https://github.com/eth-clients/mainnet @@ -208,9 +208,9 @@ proc loadEth2NetworkMetadata*( proc loadCompileTimeNetworkMetadata( path: string, - eth1Network = none(Eth1Network), - useBakedInGenesis = none(string), - downloadGenesisFrom = none(DownloadInfo)): Eth2NetworkMetadata = + eth1Network = Opt.none(Eth1Network), + useBakedInGenesis = Opt.none(string), + downloadGenesisFrom = Opt.none(DownloadInfo)): Eth2NetworkMetadata = if fileExists(path & "/config.yaml"): try: let res = loadEth2NetworkMetadata( @@ -255,13 +255,13 @@ when const_preset == "gnosis": const gnosisMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/gnosis-chain-configs/mainnet", - none(Eth1Network), - useBakedInGenesis = some "gnosis") + Opt.none(Eth1Network), + useBakedInGenesis = Opt.some "gnosis") chiadoMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/gnosis-chain-configs/chiado", - none(Eth1Network), - useBakedInGenesis = some "chiado") + Opt.none(Eth1Network), + useBakedInGenesis = Opt.some "chiado") static: for network in [gnosisMetadata, chiadoMetadata]: @@ -300,20 +300,20 @@ elif const_preset == "mainnet": const mainnetMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/mainnet/metadata", - some mainnet, - useBakedInGenesis = some "mainnet") + Opt.some mainnet, + useBakedInGenesis = Opt.some "mainnet") holeskyMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/holesky/custom_config_data", - some holesky, - downloadGenesisFrom = some DownloadInfo( + Opt.some holesky, + downloadGenesisFrom = Opt.some DownloadInfo( url: "https://github.com/status-im/nimbus-eth2/releases/download/v23.9.1/holesky-genesis.ssz.sz", digest: Eth2Digest.fromHex "0x0ea3f6f9515823b59c863454675fefcd1d8b4f2dbe454db166206a41fda060a0")) sepoliaMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/sepolia/bepolia", - some sepolia, - useBakedInGenesis = some "sepolia") + Opt.some sepolia, + useBakedInGenesis = Opt.some "sepolia") static: for network in [mainnetMetadata, sepoliaMetadata, holeskyMetadata]: diff --git a/beacon_chain/nimbus_light_client.nim b/beacon_chain/nimbus_light_client.nim index abd515bee..2f78df875 100644 --- a/beacon_chain/nimbus_light_client.nim +++ b/beacon_chain/nimbus_light_client.nim @@ -123,7 +123,7 @@ programMain: headBlockHash = payload.block_hash, safeBlockHash = payload.block_hash, # stub value finalizedBlockHash = ZERO_HASH, - payloadAttributes = none(consensusFork.PayloadAttributes)) + payloadAttributes = Opt.none(consensusFork.PayloadAttributes)) else: discard optimisticProcessor = initOptimisticProcessor( getBeaconTime, optimisticHandler) diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index b4521250a..ee376329d 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -484,24 +484,24 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = txRoot = payload.computeTransactionsTrieRoot() withdrawalsRoot = when typeof(payload).kind >= ConsensusFork.Capella: - some payload.computeWithdrawalsTrieRoot() + Opt.some payload.computeWithdrawalsTrieRoot() else: - none(ExecutionHash256) + Opt.none(ExecutionHash256) blobGasUsed = when typeof(payload).kind >= ConsensusFork.Deneb: - some payload.blob_gas_used + Opt.some payload.blob_gas_used else: - none(uint64) + Opt.none(uint64) excessBlobGas = when typeof(payload).kind >= ConsensusFork.Deneb: - some payload.excess_blob_gas + Opt.some payload.excess_blob_gas else: - none(uint64) + Opt.none(uint64) parentBeaconBlockRoot = when typeof(payload).kind >= ConsensusFork.Deneb: - some ExecutionHash256(data: blck.parent_root.data) + Opt.some ExecutionHash256(data: blck.parent_root.data) else: - none(ExecutionHash256) + Opt.none(ExecutionHash256) ExecutionBlockHeader( parentHash : payload.parent_hash, @@ -509,17 +509,17 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = coinbase : EthAddress payload.fee_recipient.data, stateRoot : payload.state_root, txRoot : txRoot, - receiptRoot : payload.receipts_root, - bloom : payload.logs_bloom.data, + receiptsRoot : payload.receipts_root, + logsBloom : payload.logs_bloom.data, difficulty : default(DifficultyInt), - blockNumber : payload.block_number.u256, + number : payload.block_number, gasLimit : cast[GasInt](payload.gas_limit), gasUsed : cast[GasInt](payload.gas_used), timestamp : EthTime(int64.saturate payload.timestamp), extraData : payload.extra_data.asSeq, - mixDigest : payload.prev_randao, # EIP-4399 `mixDigest` -> `prevRandao` + mixHash : payload.prev_randao, # EIP-4399 `mixHash` -> `prevRandao` nonce : default(BlockNonce), - fee : some payload.base_fee_per_gas, + baseFeePerGas : Opt.some payload.base_fee_per_gas, withdrawalsRoot : withdrawalsRoot, blobGasUsed : blobGasUsed, # EIP-4844 excessBlobGas : excessBlobGas, # EIP-4844 diff --git a/ncli/ncli_testnet.nim b/ncli/ncli_testnet.nim index b9e0bbb67..de8c98b65 100644 --- a/ncli/ncli_testnet.nim +++ b/ncli/ncli_testnet.nim @@ -289,7 +289,7 @@ template `as`(address: Eth1Address, T: type bellatrix.ExecutionAddress): T = template `as`(address: BlockHash, T: type Eth2Digest): T = asEth2Digest(address) -func getOrDefault[T](x: Option[T]): T = +func getOrDefault[T](x: Opt[T]): T = if x.isSome: x.get else: @@ -505,25 +505,25 @@ proc doCreateTestnet*(config: CliConfig, proc deployContract(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, - data: code.some, - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some) + `from`: Opt.some web3.defaultAccount, + data: Opt.some code, + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1)) let r = await web3.send(tr) result = await web3.getMinedTransactionReceipt(r) proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, + `from`: Opt.some web3.defaultAccount, # TODO: Force json-rpc to generate 'data' field # should not be needed anymore, new execution-api schema # is using `input` field - data: some(newSeq[byte]()), - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some, - value: some(valueEth.u256 * 1000000000000000000.u256), - to: some(to)) + data: Opt.some(newSeq[byte]()), + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1), + value: Opt.some(valueEth.u256 * 1000000000000000000.u256), + to: Opt.some(to)) web3.send(tr) type @@ -535,7 +535,7 @@ func ethToWei(eth: UInt256): UInt256 = proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} = result = await newWeb3(web3Url) if privateKey.len != 0: - result.privateKey = some(keys.PrivateKey.fromHex(privateKey)[]) + result.privateKey = Opt.some(keys.PrivateKey.fromHex(privateKey)[]) else: let accounts = await result.provider.eth_accounts() doAssert(accounts.len > 0) diff --git a/research/fakeee.nim b/research/fakeee.nim index 55f6a2842..c88ecc02a 100644 --- a/research/fakeee.nim +++ b/research/fakeee.nim @@ -57,7 +57,7 @@ proc setupEngineAPI*(server: RpcServer) = # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#engine_forkchoiceupdatedv1 server.rpc("engine_forkchoiceUpdatedV1") do( update: ForkchoiceStateV1, - payloadAttributes: Option[PayloadAttributesV1]) -> ForkchoiceUpdatedResponse: + payloadAttributes: Opt[PayloadAttributesV1]) -> ForkchoiceUpdatedResponse: info "engine_forkchoiceUpdatedV1", update, payloadAttributes @@ -68,7 +68,7 @@ proc setupEngineAPI*(server: RpcServer) = # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/shanghai.md#engine_forkchoiceupdatedv2 server.rpc("engine_forkchoiceUpdatedV2") do( - forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV2]) -> ForkchoiceUpdatedResponse: + forkchoiceState: ForkchoiceStateV1, payloadAttributes: Opt[PayloadAttributesV2]) -> ForkchoiceUpdatedResponse: info "engine_forkchoiceUpdatedV2", forkchoiceState, payloadAttributes diff --git a/research/wss_sim.nim b/research/wss_sim.nim index 735eb6cf6..d93401f7c 100644 --- a/research/wss_sim.nim +++ b/research/wss_sim.nim @@ -134,7 +134,7 @@ cli do(validatorsDir: string, secretsDir: string, headBlockHash = payload.block_hash, safeBlockHash = payload.block_hash, finalizedBlockHash = ZERO_HASH, - payloadAttributes = none(consensusFork.PayloadAttributes)) + payloadAttributes = Opt.none(consensusFork.PayloadAttributes)) if status != PayloadExecutionStatus.valid: continue diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index 7820fb557..e3a1dba83 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -118,8 +118,6 @@ proc build_empty_merge_execution_payload(state: bellatrix.BeaconState): bellatrix.ExecutionPayloadForSigning(executionPayload: payload, blockValue: Wei.zero) -from stew/saturating_arith import saturate - proc build_empty_execution_payload( state: bellatrix.BeaconState, feeRecipient: Eth1Address): bellatrix.ExecutionPayloadForSigning = @@ -129,8 +127,8 @@ proc build_empty_execution_payload( latest = state.latest_execution_payload_header timestamp = compute_timestamp_at_slot(state, state.slot) randao_mix = get_randao_mix(state, get_current_epoch(state)) - base_fee = calcEip1599BaseFee(GasInt.saturate latest.gas_limit, - GasInt.saturate latest.gas_used, + base_fee = calcEip1599BaseFee(latest.gas_limit, + latest.gas_used, latest.base_fee_per_gas) var payload = bellatrix.ExecutionPayloadForSigning( diff --git a/vendor/nim-eth b/vendor/nim-eth index c3f9160fd..9b6497ed8 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit c3f9160fd23010f65b1d4756cfd5c04272c20264 +Subproject commit 9b6497ed8a05ba25ee47142f3fc1f61742b51a6c diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 46b4b4c8b..b705f8164 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 46b4b4c8bc42013196a6290ee53029131f97931a +Subproject commit b705f816439f0068ece8c234336bc7093222d00f