Skip to content

Commit

Permalink
better error message on devnet mismatch
Browse files Browse the repository at this point in the history
Change-Id: Ife724b6b4a3d18e840f98dc5adc141b206d48209
  • Loading branch information
chessai authored and edmundnoble committed Nov 22, 2024
1 parent 4cd51b8 commit 8b0dc3e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Chainweb/Version/Registry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,21 @@ lookupVersionByCode code
-- the case that we don't actually need the version, just the code.
lookupVersion & versionCode .~ code
where

lookupVersion :: HasCallStack => ChainwebVersion
lookupVersion = unsafeDupablePerformIO $ do
m <- readIORef versionMap
return $ fromMaybe (error notRegistered) $
HM.lookup code m

notRegistered
| code == _versionCode recapDevnet = "recapDevnet version used but not registered, remember to do so after it's configured"
| code == _versionCode devnet = "devnet version used but not registered, remember to do so after it's configured"
| code == _versionCode pact5Devnet = "Pact 5 devnet version used but not registered, remember to do so after it's configured"
| code == _versionCode recapDevnet = "recapDevnet version used but not registered, remember to do so after it's configured. " <> perhaps
| code == _versionCode devnet = "devnet version used but not registered, remember to do so after it's configured. " <> perhaps
| code == _versionCode pact5Devnet = "Pact 5 devnet version used but not registered, remember to do so after it's configured. " <> perhaps
| otherwise = "version not registered with code " <> show code <> ", have you seen Chainweb.Test.TestVersions.testVersions?"

perhaps = "Perhaps you are attempting to run a different devnet version than a previous run, and you need to delete your db directory before restarting devnet with the new version?"

-- TODO: ideally all uses of this are deprecated. currently in use in
-- ObjectEncoded block header decoder and CutHashes decoder.
lookupVersionByName :: HasCallStack => ChainwebVersionName -> ChainwebVersion
Expand Down

0 comments on commit 8b0dc3e

Please sign in to comment.