diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index f829c1dba3..b30d012aec 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -1287,7 +1287,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( doAssert sizeof(uint64) == sizeof(data.gasUsed) if data.nonce.isNone: return nil - let blockHeader = ExecutionBlockHeader( + let blockHeader = eth_types.Header( parentHash: data.parentHash.asEth2Digest.to(Hash32), ommersHash: data.sha3Uncles.asEth2Digest.to(Hash32), coinbase: distinctBase(data.miner).to(EthAddress), @@ -1308,7 +1308,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( if data.withdrawalsRoot.isSome: Opt.some(data.withdrawalsRoot.get.asEth2Digest.to(Hash32)) else: - Opt.none(ExecutionHash256), + Opt.none(Hash32), blobGasUsed: if data.blobGasUsed.isSome: Opt.some distinctBase(data.blobGasUsed.get) @@ -1323,12 +1323,12 @@ proc ETHExecutionBlockHeaderCreateFromJson( if data.parentBeaconBlockRoot.isSome: Opt.some data.parentBeaconBlockRoot.get.asEth2Digest.to(Hash32) else: - Opt.none(ExecutionHash256), + Opt.none(Hash32), requestsRoot: if data.requestsRoot.isSome: Opt.some(data.requestsRoot.get.asEth2Digest.to(Hash32)) else: - Opt.none(ExecutionHash256)) + Opt.none(Hash32)) if rlpHash(blockHeader) != executionHash[]: return nil @@ -1345,7 +1345,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( # Construct withdrawal let - wd = ExecutionWithdrawal( + wd = eth_types.EthWithdrawal( index: distinctBase(data.index), validatorIndex: distinctBase(data.validatorIndex), address: distinctBase(data.address).to(EthAddress), @@ -1379,7 +1379,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( # Construct deposit request let - req = ExecutionDepositRequest( + req = eth_types.EthDepositRequest( pubkey: distinctBase(data.pubkey).to(Bytes48), withdrawalCredentials: distinctBase(data.withdrawalCredentials).to(Bytes32), amount: distinctBase(data.amount), @@ -1411,7 +1411,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( # Construct withdrawal request let - req = ExecutionWithdrawalRequest( + req = eth_types.EthWithdrawalRequest( sourceAddress: distinctBase(data.sourceAddress).to(EthAddress), validatorPubkey: distinctBase(data.validatorPubkey).to(Bytes48), amount: distinctBase(data.amount)) @@ -1439,7 +1439,7 @@ proc ETHExecutionBlockHeaderCreateFromJson( # Construct consolidation request let - req = ExecutionConsolidationRequest( + req = eth_types.EthConsolidationRequest( sourceAddress: distinctBase(data.sourceAddress).to(EthAddress), sourcePubkey: distinctBase(data.sourcePubkey).to(Bytes48), targetPubkey: distinctBase(data.targetPubkey).to(Bytes48)) @@ -1755,7 +1755,7 @@ proc ETHTransactionsCreateFromJson( if distinctBase(authorization.yParity) > 1: return nil let - tx = ExecutionTransaction( + tx = eth_types.EthTransaction( txType: txType, chainId: data.chainId.get(0.Quantity).ChainId, nonce: distinctBase(data.nonce), @@ -2560,15 +2560,15 @@ proc ETHReceiptsCreateFromJson( if distinctBase(data.cumulativeGasUsed) > int64.high.uint64: return nil let - rec = ExecutionReceipt( + rec = eth_types.EthReceipt( receiptType: txType, isHash: data.root.isSome, status: distinctBase(data.status.get(1.Quantity)) != 0'u64, hash: if data.root.isSome: - ExecutionHash256(distinctBase(data.root.get)) + Hash32(distinctBase(data.root.get)) else: - default(ExecutionHash256), + default(Hash32), cumulativeGasUsed: distinctBase(data.cumulativeGasUsed).GasInt, logsBloom: distinctBase(data.logsBloom).to(Bloom), logs: data.logs.mapIt(Log( diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index aea181560b..9560a9a93e 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -35,15 +35,6 @@ func toGwei*(eth: Ether): Gwei = distinctBase(eth) * ETH_TO_GWEI type - 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.Header - FinalityCheckpoints* = object justified*: Checkpoint finalized*: Checkpoint @@ -444,18 +435,18 @@ template append*(w: var RlpWriter, v: bellatrix.Transaction) = w.appendRawBytes(distinctBase v) template append*(w: var RlpWriter, withdrawal: capella.Withdrawal) = - w.appendRecordType(ExecutionWithdrawal( + w.appendRecordType(EthWithdrawal( index: withdrawal.index, validatorIndex: withdrawal.validator_index, address: EthAddress withdrawal.address.data, amount: distinctBase(withdrawal.amount))) proc computeTransactionsTrieRoot( - payload: ForkyExecutionPayload): ExecutionHash256 = + payload: ForkyExecutionPayload): EthHash32 = orderedTrieRoot(payload.transactions.asSeq) func append*(w: var RlpWriter, request: electra.DepositRequest) = - w.append ExecutionDepositRequest( + w.append EthDepositRequest( pubkey: Bytes48 request.pubkey.blob, withdrawalCredentials: Bytes32 request.withdrawal_credentials.data, amount: distinctBase(request.amount), @@ -463,20 +454,20 @@ func append*(w: var RlpWriter, request: electra.DepositRequest) = index: request.index) func append*(w: var RlpWriter, request: electra.WithdrawalRequest) = - w.append ExecutionWithdrawalRequest( + w.append EthWithdrawalRequest( sourceAddress: Address request.source_address.data, validatorPubkey: Bytes48 request.validator_pubkey.blob, amount: distinctBase(request.amount)) func append*(w: var RlpWriter, request: electra.ConsolidationRequest) = - w.append ExecutionConsolidationRequest( + w.append EthConsolidationRequest( sourceAddress: Address request.source_address.data, sourcePubkey: Bytes48 request.source_pubkey.blob, targetPubkey: Bytes48 request.target_pubkey.blob) # https://eips.ethereum.org/EIPS/eip-7685 proc computeRequestsTrieRoot( - requests: electra.ExecutionRequests): ExecutionHash256 = + requests: electra.ExecutionRequests): EthHash32 = let n = requests.deposits.len + requests.withdrawals.len + @@ -494,7 +485,7 @@ proc computeRequestsTrieRoot( b.rootHash() -proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = +proc blockToBlockHeader*(blck: ForkyBeaconBlock): EthHeader = template payload: auto = blck.body.execution_payload static: # `GasInt` is signed. We only use it for hashing. @@ -507,7 +498,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = when typeof(payload).kind >= ConsensusFork.Capella: Opt.some orderedTrieRoot(payload.withdrawals.asSeq) else: - Opt.none(ExecutionHash256) + Opt.none(EthHash32) blobGasUsed = when typeof(payload).kind >= ConsensusFork.Deneb: Opt.some payload.blob_gas_used @@ -520,16 +511,16 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = Opt.none(uint64) parentBeaconBlockRoot = when typeof(payload).kind >= ConsensusFork.Deneb: - Opt.some ExecutionHash256(blck.parent_root.data) + Opt.some EthHash32(blck.parent_root.data) else: - Opt.none(ExecutionHash256) + Opt.none(EthHash32) requestsRoot = when typeof(payload).kind >= ConsensusFork.Electra: Opt.some blck.body.execution_requests.computeRequestsTrieRoot() else: - Opt.none(ExecutionHash256) + Opt.none(EthHash32) - ExecutionBlockHeader( + EthHeader( parentHash : payload.parent_hash.to(Hash32), ommersHash : EMPTY_UNCLE_HASH, coinbase : EthAddress payload.fee_recipient.data, diff --git a/beacon_chain/spec/helpers_el.nim b/beacon_chain/spec/helpers_el.nim index 8b9e1c807d..9b91cc5e95 100644 --- a/beacon_chain/spec/helpers_el.nim +++ b/beacon_chain/spec/helpers_el.nim @@ -13,9 +13,9 @@ import "."/[helpers, state_transition_block] func readExecutionTransaction( - txBytes: bellatrix.Transaction): Result[ExecutionTransaction, string] = + txBytes: bellatrix.Transaction): Result[EthTransaction, string] = try: - ok rlp.decode(distinctBase(txBytes), ExecutionTransaction) + ok rlp.decode(distinctBase(txBytes), EthTransaction) except RlpError as exc: err("Invalid transaction: " & exc.msg)