From e2d973959da6599af0be3adf52c79d04a56e44ca Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Mon, 8 Jul 2024 13:59:27 +0000 Subject: [PATCH] lower time check, make bannable --- mixing/mixpool/errors.go | 4 ++++ mixing/mixpool/mixpool.go | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mixing/mixpool/errors.go b/mixing/mixpool/errors.go index 6e342f909..f43d57da5 100644 --- a/mixing/mixpool/errors.go +++ b/mixing/mixpool/errors.go @@ -91,6 +91,10 @@ var ( // position of a peer's own PR is outside of the possible bounds of // the previously seen messages. ErrPeerPositionOutOfBounds = newBannableError("peer position cannot be a valid seen PRs index", 0) + + // ErrEarlyKE is returned by AcceptMessage if a key exchange message + // with a stated epoch is sent too early for that epoch time. + ErrEarlyKE = newBannableError("KE received too early for stated epoch", 0) ) // IsBannable returns whether the error condition is such that the peer with diff --git a/mixing/mixpool/mixpool.go b/mixing/mixpool/mixpool.go index 117d8a6b9..697b03c10 100644 --- a/mixing/mixpool/mixpool.go +++ b/mixing/mixpool/mixpool.go @@ -28,7 +28,7 @@ import ( const minconf = 1 const feeRate = 0.0001e8 -const clientTimeoutDuration = 30 * time.Second +const earlyKEDuration = 5 * time.Second type idPubKey = [33]byte @@ -1396,8 +1396,7 @@ func (p *Pool) checkAcceptKE(ke *wire.MsgMixKeyExchange) error { } keEpoch := time.Unix(int64(ke.Epoch), 0) - if keEpoch.Add(clientTimeoutDuration).Before(time.Now()) { - err := fmt.Errorf("KE received too early for stated epoch") + if keEpoch.Add(earlyKEDuration).Before(time.Now()) { return ruleError(err) }