Draft: PoW: Publish and persist pow-params line.
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 aPowVerifier
object that has:
Verifier
for the current and previousSeed
- A
mpsc::Receiver<Seed>
to receive new seed values upon rotation. ThePowState
holds thempsc::Sender
end of this.- A
Arc<Mutex<HashSet<(SeedHead, Nonce)>>>
of nonces that have been used. This will be initialized in thePowState
, and thePowState
will deal with cleaning up values with old seeds. (Maybe aArc<Mutex<HashMap<SeedHead, HashSet<Nonce>>>>
would be better to make that easier, whatever)- A
mpsc::Sender<Effort>
to send back to thePowState
the fact that a request with a given effort has been processed, updating the centralized bookkeeping in thePowState
.- 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 thePowState
and proceeds- When we create a new IPT, we call
PowState::new_verifier
, which makes thePowVerifier
This has the advantage of handing the differing
TimePeriod
s 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.