diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index d8684372e..680a9fa59 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -670,7 +670,7 @@ proc popFirst(chain: var Eth1Chain) = chain.blocksByHash.del removed.hash.asBlockHash eth1_chain_len.set chain.blocks.len.int64 -func getDepositsRoot*(m: DepositsMerkleizer): Eth2Digest = +func getDepositsRoot*(m: var DepositsMerkleizer): Eth2Digest = mixInLength(m.getFinalHash, int m.totalChunks) proc addBlock*(chain: var Eth1Chain, newBlock: Eth1Block) = @@ -1783,7 +1783,7 @@ proc getBlockProposalData*(chain: var Eth1Chain, deposits.add data depositRoots.add hash_tree_root(data) - var scratchMerkleizer = copy chain.finalizedDepositsMerkleizer + var scratchMerkleizer = chain.finalizedDepositsMerkleizer if chain.advanceMerkleizer(scratchMerkleizer, stateDepositIdx): let proofs = scratchMerkleizer.addChunksAndGenMerkleProofs(depositRoots) for i in 0 ..< totalDepositsInNewBlock: @@ -1844,7 +1844,7 @@ proc init*(T: type Eth1Chain, cfg: cfg, finalizedBlockHash: finalizedBlockHash, finalizedDepositsMerkleizer: m, - headMerkleizer: copy m) + headMerkleizer: m) proc new*(T: type ELManager, cfg: RuntimeConfig, @@ -1877,7 +1877,7 @@ proc safeCancel(fut: var Future[void]) = func clear(chain: var Eth1Chain) = chain.blocks.clear() chain.blocksByHash.clear() - chain.headMerkleizer = copy chain.finalizedDepositsMerkleizer + chain.headMerkleizer = chain.finalizedDepositsMerkleizer chain.hasConsensusViolation = false proc doStop(m: ELManager) {.async.} = diff --git a/beacon_chain/spec/deposit_snapshots.nim b/beacon_chain/spec/deposit_snapshots.nim index e9907e39d..a905edfb1 100644 --- a/beacon_chain/spec/deposit_snapshots.nim +++ b/beacon_chain/spec/deposit_snapshots.nim @@ -1,3 +1,12 @@ +# beacon_chain +# Copyright (c) 2018-2023 Status Research & Development GmbH +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + from stew/objects import isZeroMemory import ./eth2_merkleization @@ -35,11 +44,11 @@ template getDepositCountU64*(d: OldDepositContractSnapshot | func getDepositRoot*(d: OldDepositContractSnapshot | DepositTreeSnapshot): Eth2Digest = - let merk = DepositsMerkleizer.init(d.depositContractState) + var merk = DepositsMerkleizer.init(d.depositContractState) let hash = merk.getFinalHash() # TODO: mixInLength should accept unsigned int instead of int as # this right now cuts in half the theoretical number of deposits. - return mixInLength(hash, int(merk.totalChunks)) + return mixInLength(hash, int(merk.getChunkCount())) func isValid*(d: DepositTreeSnapshot, wantedDepositRoot: Eth2Digest): bool = ## `isValid` requires the snapshot to be self-consistent and diff --git a/vendor/nim-ssz-serialization b/vendor/nim-ssz-serialization index a5767c1b4..edf07d4f7 160000 --- a/vendor/nim-ssz-serialization +++ b/vendor/nim-ssz-serialization @@ -1 +1 @@ -Subproject commit a5767c1b4992dca3e5bd72557aadd4df0f183bf8 +Subproject commit edf07d4f7e0cb27afd207aa183c23cf448082d1b