Skip to content

Commit

Permalink
Add enableHyperlane flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Akentev committed Nov 14, 2023
1 parent 45d8971 commit bf26024
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Chainweb/Pact/SPV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ verifySPV bdb bh typ proof = runExceptT $ go typ proof
where
cid = CW._chainId bdb
enableBridge = CW.enableSPVBridge (CW._chainwebVersion bh) cid (_blockHeight bh)
enableHyperlane = CW.enableHyperlane (CW._chainwebVersion bh) cid (_blockHeight bh)

mkSPVResult' cr j
| enableBridge =
Expand Down Expand Up @@ -175,7 +176,7 @@ verifySPV bdb bh typ proof = runExceptT $ go typ proof
PactResult (Right v) ->
mkSPVResult' q v

"HYPERLANE_V3" -> evalHyperlaneCommand o
"HYPERLANE_V3" | enableHyperlane -> evalHyperlaneCommand o

t -> throwError $! "unsupported SPV types: " <> t

Expand Down
3 changes: 3 additions & 0 deletions src/Chainweb/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ data Fork
| Chainweb219Pact
| Chainweb220Pact
| Chainweb221Pact
| Hyperlane
-- always add new forks at the end, not in the middle of the constructors.
deriving stock (Bounded, Generic, Eq, Enum, Ord, Show)
deriving anyclass (NFData, Hashable)
Expand Down Expand Up @@ -222,6 +223,7 @@ instance HasTextRepresentation Fork where
toText Chainweb219Pact = "chainweb219Pact"
toText Chainweb220Pact = "chainweb220Pact"
toText Chainweb221Pact = "chainweb221Pact"
toText Hyperlane = "hyperlane"

fromText "slowEpoch" = return SlowEpoch
fromText "vuln797Fix" = return Vuln797Fix
Expand Down Expand Up @@ -249,6 +251,7 @@ instance HasTextRepresentation Fork where
fromText "chainweb219Pact" = return Chainweb219Pact
fromText "chainweb220Pact" = return Chainweb220Pact
fromText "chainweb221Pact" = return Chainweb221Pact
fromText "hyperlane" = return Hyperlane
fromText t = throwM . TextFormatException $ "Unknown Chainweb fork: " <> t

instance ToJSON Fork where
Expand Down
1 change: 1 addition & 0 deletions src/Chainweb/Version/Development.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ devnet = ChainwebVersion
Chainweb219Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 550
Chainweb220Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 560
Chainweb221Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 580
Hyperlane -> AllChains $ ForkAtBlockHeight $ BlockHeight 600

, _versionUpgrades = foldr (chainZip HM.union) (AllChains mempty)
[ forkUpgrades devnet
Expand Down
5 changes: 5 additions & 0 deletions src/Chainweb/Version/Guards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Chainweb.Version.Guards
, chainweb219Pact
, chainweb220Pact
, chainweb221Pact
, enableHyperlane
, pact44NewTrans
, pactParserVersion
, maxBlockGasLimit
Expand Down Expand Up @@ -238,6 +239,10 @@ chainweb220Pact = checkFork atOrAfter Chainweb220Pact
chainweb221Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb221Pact = checkFork atOrAfter Chainweb221Pact

-- | Bridge support: Hyperlane.
enableHyperlane :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
enableHyperlane = checkFork atOrAfter Hyperlane

pactParserVersion :: ChainwebVersion -> ChainId -> BlockHeight -> PactParserVersion
pactParserVersion v cid bh
| chainweb213Pact v cid bh = PactParserChainweb213
Expand Down
1 change: 1 addition & 0 deletions src/Chainweb/Version/Mainnet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ mainnet = ChainwebVersion
Chainweb219Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 3_774_423) -- 2023-06-02 00:00:00+00:00
Chainweb220Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 4_056_499) -- 2023-09-08 00:00:00+00:00
Chainweb221Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 4_177_889) -- 2023-10-20 00:00:00+00:00
Hyperlane -> AllChains ForkNever -- TODO: add date and block height

, _versionGraphs =
(to20ChainsMainnet, twentyChainGraph) `Above`
Expand Down
1 change: 1 addition & 0 deletions src/Chainweb/Version/Testnet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ testnet = ChainwebVersion
Chainweb219Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 3_299_753 -- 2023-06-01 12:00:00+00:00
Chainweb220Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 3_580_964 -- 2023-09-08 12:00:00+00:00
Chainweb221Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 3_702_250 -- 2023-10-19 12:00:00+00:00
Hyperlane -> AllChains ForkNever -- TODO: add date and block height

, _versionGraphs =
(to20ChainsTestnet, twentyChainGraph) `Above`
Expand Down
2 changes: 2 additions & 0 deletions test/Chainweb/Test/TestVersions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ fastForks = tabulateHashMap $ \case
Chainweb219Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 27
Chainweb220Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 30
Chainweb221Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 33
Hyperlane -> AllChains $ ForkAtBlockHeight $ BlockHeight 36

-- | A test version without Pact or PoW, with only one chain graph.
barebonesTestVersion :: ChainGraph -> ChainwebVersion
Expand Down Expand Up @@ -260,6 +261,7 @@ slowForkingCpmTestVersion g = buildTestVersion $ \v -> v
Chainweb219Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 71)
Chainweb220Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 85)
Chainweb221Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 100)
Hyperlane -> AllChains $ ForkAtBlockHeight (BlockHeight 115)

-- | CPM version (see `cpmTestVersion`) with forks and upgrades quickly enabled.
fastForkingCpmTestVersion :: ChainGraph -> ChainwebVersion
Expand Down

0 comments on commit bf26024

Please sign in to comment.