Skip to content

Draft: PoW: Publish and persist pow-params line.

wesleyac requested to merge wesleyac/arti:hs-host-pow-publish-and-persist into main

This is a updated version of !2643 (closed). It avoids the KP_hs_id contention (thus far) by not actually constructing the verifiers yet. The plan for checking is as described in !2643 (comment 3138574):

  • Each RendRequestContext has a PowVerifier object that has:
    • Verifier for the current and previous Seed
    • A mpsc::Receiver<Seed> to receive new seed values upon rotation. The PowState holds the mpsc::Sender end of this.
    • A Arc<Mutex<HashSet<(SeedHead, Nonce)>>> of nonces that have been used. This will be initialized in the PowState, and the PowState will deal with cleaning up values with old seeds. (Maybe a Arc<Mutex<HashMap<SeedHead, HashSet<Nonce>>>> would be better to make that easier, whatever)
    • A mpsc::Sender<Effort> to send back to the PowState the fact that a request with a given effort has been processed, updating the centralized bookkeeping in the PowState.
  • When a INTRODUCE2 message comes in, the IptMsgHandler:
    • Checks the seed head against the current and previous seeds, rejecting if not matching
    • Updates the HashSet of Nonces, rejecting the request if the (SeedHead, Nonce) pair was already used.
    • Checks the PoW solve with the correct Verifier
    • If the solve is correct, sends the Effort back to the PowState and proceeds
  • When we create a new IPT, we call PowState::new_verifier, which makes the PowVerifier

This has the advantage of handing the differing TimePeriods very nicely (since a IPT fundamentally is only for a single time period) and making the global locking period as small as possible (just happening when the nonce HashSet check happens). It seems pretty clean overall.

Merge request reports

Loading