Skip to content

Commit

Permalink
feat: implement signatureFromBytes from utils package
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkeil committed May 8, 2024
1 parent 75e19a6 commit 90a9272
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
16 changes: 3 additions & 13 deletions packages/beacon-node/src/chain/bls/jobItem.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
CoordType,
Signature,
PublicKey,
aggregatePublicKeys,
aggregateSignatures,
randomBytesNonZero,
} from "@chainsafe/blst";
import {PublicKey, aggregatePublicKeys, aggregateSignatures, randomBytesNonZero} from "@chainsafe/blst";
import {signatureFromBytes} from "@lodestar/utils";
import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition";
import {LinkedList} from "../../util/array.js";
import {Metrics} from "../../metrics/metrics.js";
Expand Down Expand Up @@ -76,11 +70,7 @@ export function jobItemWorkReq(job: JobQueueItem, metrics: Metrics | null): BlsW
// and not a problem in the near future
// this is monitored on v1.11.0 https://github.com/ChainSafe/lodestar/pull/5912#issuecomment-1700320307
const timer = metrics?.blsThreadPool.signatureDeserializationMainThreadDuration.startTimer();
const signatures = job.sets.map((set) => {
const sig = Signature.deserialize(set.signature, CoordType.affine);
sig.sigValidate();
return sig;
});
const signatures = job.sets.map((set) => signatureFromBytes(set.signature));
timer?.();

const randomness: Uint8Array[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
getBlockRootAtSlot,
} from "@lodestar/state-transition";
import {IForkChoice, EpochDifference} from "@lodestar/fork-choice";
import {toHex, MapDef} from "@lodestar/utils";
import {toHex, MapDef, signatureFromBytesNoCheck} from "@lodestar/utils";
import {intersectUint8Arrays, IntersectResult} from "../../util/bitArray.js";
import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js";
import {pruneBySlot} from "./utils.js";
import {InsertOutcome} from "./types.js";

type DataRootHex = string;
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/opPools/attestationPool.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Signature, aggregateSignatures} from "@chainsafe/blst";
import {BitArray} from "@chainsafe/ssz";
import {phase0, Slot, RootHex} from "@lodestar/types";
import {MapDef} from "@lodestar/utils";
import {MapDef, signatureFromBytesNoCheck} from "@lodestar/utils";
import {IClock} from "../../util/clock.js";
import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js";
import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js";
import {pruneBySlot} from "./utils.js";

/**
* The number of slots that will be stored in the pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {Signature, aggregateSignatures} from "@chainsafe/blst";
import {BitArray, toHexString} from "@chainsafe/ssz";
import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
import {altair, Root, Slot, SubcommitteeIndex} from "@lodestar/types";
import {MapDef} from "@lodestar/utils";
import {MapDef, signatureFromBytesNoCheck} from "@lodestar/utils";
import {IClock} from "../../util/clock.js";
import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js";
import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js";
import {pruneBySlot} from "./utils.js";

/**
* SyncCommittee signatures are only useful during a single slot according to our peer's clocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {BitArray, toHexString} from "@chainsafe/ssz";
import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
import {altair, Slot, Root, ssz} from "@lodestar/types";
import {G2_POINT_AT_INFINITY} from "@lodestar/state-transition";
import {MapDef} from "@lodestar/utils";
import {MapDef, signatureFromBytesNoCheck} from "@lodestar/utils";
import {InsertOutcome, OpPoolError, OpPoolErrorCode} from "./types.js";
import {pruneBySlot, signatureFromBytesNoCheck} from "./utils.js";
import {pruneBySlot} from "./utils.js";

/**
* SyncCommittee aggregates are only useful for the next block they have signed.
Expand Down

0 comments on commit 90a9272

Please sign in to comment.