diff --git a/beacon_chain/consensus_object_pools/block_clearance.nim b/beacon_chain/consensus_object_pools/block_clearance.nim index 6bc2c7ec31..454da7a90f 100644 --- a/beacon_chain/consensus_object_pools/block_clearance.nim +++ b/beacon_chain/consensus_object_pools/block_clearance.nim @@ -251,9 +251,6 @@ proc addHeadBlockWithParent*( parent = shortLog(parent), checkedParent = shortLog(checkedParent) return err(VerifierError.MissingParent) - template blck(): untyped = signedBlock.message # shortcuts without copy - template blockRoot(): untyped = signedBlock.root - # The block is resolved, now it's time to validate it to ensure that the # blocks we add to the database are clean for the given state let startTick = Moment.now() diff --git a/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim b/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim index 7f81d911f7..6d2b972838 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim @@ -82,34 +82,6 @@ proc existingCurrentSyncCommitteeForPeriod( doAssert strictVerification notin dag.updateFlags syncCommittee -template syncCommitteeRoot(state: ForkyHashedBeaconState): Eth2Digest = - ## Compute a root to uniquely identify `current_sync_committee` and - ## `next_sync_committee`. - withEth2Hash: - h.update state.data.current_sync_committee.hash_tree_root().data - h.update state.data.next_sync_committee.hash_tree_root().data - -proc syncCommitteeRootForPeriod( - dag: ChainDAGRef, - tmpState: var ForkedHashedBeaconState, - period: SyncCommitteePeriod): Opt[Eth2Digest] = - ## Compute a root to uniquely identify `current_sync_committee` and - ## `next_sync_committee` for a given sync committee period. - ## For non-finalized periods, follow the chain as selected by fork choice. - let lowSlot = max(dag.tail.slot, dag.cfg.ALTAIR_FORK_EPOCH.start_slot) - if period < lowSlot.sync_committee_period: - return err() - let - periodStartSlot = period.start_slot - syncCommitteeSlot = max(periodStartSlot, lowSlot) - bsi = ? dag.getExistingBlockIdAtSlot(syncCommitteeSlot) - dag.withUpdatedExistingState(tmpState, bsi) do: - withState(updatedState): - when consensusFork >= ConsensusFork.Altair: - ok forkyState.syncCommitteeRoot - else: raiseAssert "Unreachable" - do: err() - proc initLightClientDataStore*( config: LightClientDataConfig, cfg: RuntimeConfig, diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim index e76f34d1b5..2c1ab38516 100644 --- a/beacon_chain/consensus_object_pools/consensus_manager.nim +++ b/beacon_chain/consensus_object_pools/consensus_manager.nim @@ -114,8 +114,6 @@ proc expectBlock*(self: var ConsensusManager, expectedSlot: Slot): Future[bool] return fut -func `$`(h: BlockHash): string = $h.asEth2Digest - func shouldSyncOptimistically*( optimisticSlot, dagSlot, wallSlot: Slot): bool = ## Determine whether an optimistic execution block hash should be reported diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index 2b827986b7..077cd031a0 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -787,7 +787,7 @@ proc processBlock( let wallTime = self.getBeaconTime() - (afterGenesis, wallSlot) = wallTime.toSlot() + (afterGenesis, _) = wallTime.toSlot() if not afterGenesis: error "Processing block before genesis, clock turned back?" diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index a90ed5735a..674c650b2e 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -280,7 +280,7 @@ proc processBlobSidecar*( let wallTime = self.getCurrentBeaconTime() - (afterGenesis, wallSlot) = wallTime.toSlot() + (_, wallSlot) = wallTime.toSlot() logScope: blob = shortLog(blobSidecar) @@ -302,8 +302,6 @@ proc processBlobSidecar*( debug "Blob validated, putting in blob quarantine" self.blobQuarantine[].put(newClone(blobSidecar)) - var skippedBlocks = false - let block_root = hash_tree_root(block_header) if (let o = self.quarantine[].popBlobless(block_root); o.isSome): let blobless = o.unsafeGet() diff --git a/beacon_chain/nimbus_binary_common.nim b/beacon_chain/nimbus_binary_common.nim index 7defa0d5b9..557bee5838 100644 --- a/beacon_chain/nimbus_binary_common.nim +++ b/beacon_chain/nimbus_binary_common.nim @@ -41,40 +41,41 @@ type raises: [].} # silly chronicles, colors is a compile-time property -proc stripAnsi(v: string): string = - var - res = newStringOfCap(v.len) - i: int - - while i < v.len: - let c = v[i] - if c == '\x1b': - var - x = i + 1 - found = false - - while x < v.len: # look for [..m - let c2 = v[x] - if x == i + 1: - if c2 != '[': - break - else: - if c2 in {'0'..'9'} + {';'}: - discard # keep looking - elif c2 == 'm': - i = x + 1 - found = true - break +when defaultChroniclesStream.outputs.type.arity == 2: + func stripAnsi(v: string): string = + var + res = newStringOfCap(v.len) + i: int + + while i < v.len: + let c = v[i] + if c == '\x1b': + var + x = i + 1 + found = false + + while x < v.len: # look for [..m + let c2 = v[x] + if x == i + 1: + if c2 != '[': + break else: - break - inc x - - if found: # skip adding c - continue - res.add c - inc i - - res + if c2 in {'0'..'9'} + {';'}: + discard # keep looking + elif c2 == 'm': + i = x + 1 + found = true + break + else: + break + inc x + + if found: # skip adding c + continue + res.add c + inc i + + res proc updateLogLevel*(logLevel: string) {.raises: [ValueError].} = # Updates log levels (without clearing old ones) diff --git a/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim b/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim index 31a5e9dd24..50556cabb7 100644 --- a/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim +++ b/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim @@ -28,8 +28,7 @@ proc addMapping*(store: var DynamicFeeRecipientsStore, validator: ValidatorIndex, feeRecipient: Eth1Address, currentEpoch: Epoch) = - var - found, updated = false + var updated = false store.mappings.withValue(validator, entry) do: updated = not (entry[].recipient == feeRecipient) entry[] = Entry(recipient: feeRecipient, addedAt: currentEpoch)