diff --git a/apps/simplex-store-service/src/StoreService/Names/Worker.hs b/apps/simplex-store-service/src/StoreService/Names/Worker.hs index 1733905160..9390c20675 100644 --- a/apps/simplex-store-service/src/StoreService/Names/Worker.hs +++ b/apps/simplex-store-service/src/StoreService/Names/Worker.hs @@ -26,6 +26,7 @@ import Data.Int (Int64) import Data.Map.Strict (Map) import qualified Data.Map.Strict as M import Data.Text (Text) +import qualified Data.Text as T import Data.Time.Clock (NominalDiffTime, UTCTime, addUTCTime, diffUTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds) import Data.Word (Word64) @@ -237,12 +238,14 @@ committed w@Worker {wkSender} now r@NameRegistration {nrId, nrReveal, nrRevealAf -- | The stored intent is checked before its dry run, whose revert decides at once; no label turn is held across the send. sendRegister :: Worker -> UTCTime -> NameRegistration -> NameReveal -> IO Next -sendRegister w@Worker {wkOrders = OrdersEnv {oeConfig = cfg@NamesConfig {nChain = ChainConfig {cChainId, cSponsor}}}, wkSender} now r@NameRegistration {nrId} rv = +sendRegister w@Worker {wkOrders = OrdersEnv {oeConfig = cfg@NamesConfig {nChain = ChainConfig {cChainId, cSponsor}}}, wkSender} now r@NameRegistration {nrId = regId@(RegistrationId rid)} rv = verifyRegisterIntent (sponsorDomain cChainId cSponsor) (fromInteger $ unixSeconds now) intent >>= \case - -- past its deadline, the commitment it was signed for has lapsed too - Left _ -> judge w now r Nothing + -- past its deadline the commitment has lapsed too; a wrong signer follows a change of the chain settings since the reveal + Left refusal -> do + logWarn $ "names worker: registration " <> rid <> ": its stored intent is refused, " <> T.pack refusal + judge w now r Nothing Right () -> - submitTransaction wkSender (TxRegister nrId) cSponsor (registerWithCreditCalldata intent) >>= \case + submitTransaction wkSender (TxRegister regId) cSponsor (registerWithCreditCalldata intent) >>= \case Right p -> registerSent w now r p Left SEInFlight -> pure Again Left (SEChain (ChainReverted reason)) -> judge w now r reason diff --git a/tests/Bots/StoreService/NamesWorkerTests.hs b/tests/Bots/StoreService/NamesWorkerTests.hs index cf5bd870bd..65225be48a 100644 --- a/tests/Bots/StoreService/NamesWorkerTests.hs +++ b/tests/Bots/StoreService/NamesWorkerTests.hs @@ -545,7 +545,8 @@ testExpiredIntent = withWorker $ \w@W {wCtx = ctx} -> do r <- paidIn ctx aliceOrder (\o -> (openPhase o) {nrRevealBefore = Just (rvDeadline reveal)}) >>= revealed ctx keyA "alicebakery" answerAvailable w True advance ctx $ fromIntegral (rvDeadline reveal - orderSeconds) + 1 - steps w r >>= done + logs <- capturingStderr $ steps w r >>= done + logs `shouldSatisfy` T.isInfixOf "intent expired" nrPhase <$> stored ctx r `shouldReturn` PFailed sent w `shouldReturn` []