Skip to content

Commit

Permalink
Increase number of web3 signer requests before signaling failure to 4. (
Browse files Browse the repository at this point in the history
#6609)

Decrease number of pre-computed slots from 32 to 2.
Add validator field to some log statements.
  • Loading branch information
cheatfate authored Oct 8, 2024
1 parent 3f37caa commit a25afae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
10 changes: 7 additions & 3 deletions beacon_chain/validator_client/duties_service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import "."/[common, api, block_service, selection_proofs]
const
ServiceName = "duties_service"
SUBSCRIPTION_LOOKAHEAD_EPOCHS* = 4'u64
AGGREGATION_PRE_COMPUTE_EPOCHS* = 1'u64
AGGREGATION_PRE_COMPUTE_SLOTS* = 1'u64
# We do pre-computation for current and next slot only. Pre-computation
# is good for low number of validators, but with big count of validators
# number of remote signature requests could overload remote signature
# service.

logScope: service = ServiceName

Expand Down Expand Up @@ -319,7 +323,7 @@ proc pollForAttesterDuties*(service: DutiesServiceRef) {.async.} =
moment = Moment.now()
sigres =
await vc.fillAttestationSelectionProofs(currentSlot,
currentSlot + Epoch(AGGREGATION_PRE_COMPUTE_EPOCHS))
currentSlot + AGGREGATION_PRE_COMPUTE_SLOTS)

if vc.config.distributedEnabled:
debug "Attestation selection proofs have been received",
Expand Down Expand Up @@ -412,7 +416,7 @@ proc pollForSyncCommitteeDuties*(service: DutiesServiceRef) {.async.} =
moment = Moment.now()
sigres =
await vc.fillSyncCommitteeSelectionProofs(currentSlot,
currentSlot + Epoch(AGGREGATION_PRE_COMPUTE_EPOCHS))
currentSlot + AGGREGATION_PRE_COMPUTE_SLOTS)

if vc.config.distributedEnabled:
debug "Sync committee selection proofs have been received",
Expand Down
8 changes: 5 additions & 3 deletions beacon_chain/validator_client/selection_proofs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ proc fillAttestationSelectionProofs*(
if sres.isErr():
warn "Unable to create slot signature using remote signer",
reason = sres.error(), epoch = mreq.slot.epoch(),
slot = mreq.slot
slot = mreq.slot,
validator = validatorLog(mreq.validator)
Opt.none(ValidatorSig)
else:
inc(sigres.signaturesReceived)
Expand Down Expand Up @@ -396,9 +397,10 @@ proc fillSyncCommitteeSelectionProofs*(
if mreq.future.completed():
let sres = Future[SignatureResult](mreq.future).read()
if sres.isErr():
warn "Unable to create slot signature using remote signer",
warn "Unable to create selection proof using remote signer",
reason = sres.error(), epoch = mreq.slot.epoch(),
slot = mreq.slot
slot = mreq.slot,
validator = validatorLog(mreq.validator)
Opt.none(ValidatorSig)
else:
inc(sigres.signaturesReceived)
Expand Down
9 changes: 6 additions & 3 deletions beacon_chain/validators/validator_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export

const
WEB3_SIGNER_DELAY_TOLERANCE = 3.seconds
WEB3_SIGNER_ATTEMPTS_COUNT = 4

declareGauge validators,
"Number of validators attached to the beacon node"
Expand Down Expand Up @@ -469,8 +470,9 @@ proc signWithDistributedKey(v: AttachedValidator,

let
deadline = sleepAsync(WEB3_SIGNER_DELAY_TOLERANCE)
signatureReqs = mapIt(v.clients, it[0].signData(it[1].pubkey, deadline,
2, request))
signatureReqs = mapIt(v.clients,
it[0].signData(it[1].pubkey, deadline, WEB3_SIGNER_ATTEMPTS_COUNT,
request))

await allFutures(signatureReqs)

Expand Down Expand Up @@ -504,7 +506,8 @@ proc signWithSingleKey(v: AttachedValidator,
let
deadline = sleepAsync(WEB3_SIGNER_DELAY_TOLERANCE)
(client, info) = v.clients[0]
res = await client.signData(info.pubkey, deadline, 2, request)
res = await client.signData(
info.pubkey, deadline, WEB3_SIGNER_ATTEMPTS_COUNT, request)

if not(deadline.finished()): await cancelAndWait(deadline)
if res.isErr():
Expand Down

0 comments on commit a25afae

Please sign in to comment.