Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Chainweb/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,8 @@ data Fork
| Chainweb223Pact
| Chainweb224Pact
| Chainweb225Pact
| Chainweb226Pact
| Pact5Fork
| Chainweb228Pact
| Chainweb229Pact
| Chainweb230Pact
| Chainweb231Pact
| Chainweb31
Expand Down Expand Up @@ -270,10 +268,8 @@ instance HasTextRepresentation Fork where
toText Chainweb223Pact = "chainweb223Pact"
toText Chainweb224Pact = "chainweb224Pact"
toText Chainweb225Pact = "chainweb225Pact"
toText Chainweb226Pact = "chainweb226Pact"
toText Pact5Fork = "pact5"
toText Chainweb228Pact = "chainweb228Pact"
toText Chainweb229Pact = "chainweb229Pact"
toText Chainweb230Pact = "chainweb230Pact"
toText Chainweb231Pact = "chainweb231Pact"
toText Chainweb31 = "Chainweb31"
Expand Down Expand Up @@ -309,10 +305,8 @@ instance HasTextRepresentation Fork where
fromText "chainweb223Pact" = return Chainweb223Pact
fromText "chainweb224Pact" = return Chainweb224Pact
fromText "chainweb225Pact" = return Chainweb225Pact
fromText "chainweb226Pact" = return Chainweb226Pact
fromText "pact5" = return Pact5Fork
fromText "chainweb228Pact" = return Chainweb228Pact
fromText "chainweb229Pact" = return Chainweb229Pact
fromText "chainweb230Pact" = return Chainweb230Pact
fromText "chainweb231Pact" = return Chainweb231Pact
fromText "Chainweb31" = return Chainweb31
Expand Down
66 changes: 45 additions & 21 deletions src/Chainweb/Version/Guards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
-- Maintainer: Edmund Noble <edmund@kadena.io>
-- Stability: experimental
--
-- Functions which dictate changes in block validation at different BlockHeights, based on
-- chainweb versions.
-- Functions which dictate changes in block validation behavior at different
-- BlockHeights, based on chainweb versions.
--
-- Changes either activate at a certain block height and for all subsequent blocks,
-- activate for all subsequent blocks after a certain block height,
-- or activate for all previous blocks before a certain block height.
-- Changes either activate at a certain block height and for all subsequent
-- blocks, activate for all subsequent blocks after a certain block height, or
-- activate for all previous blocks before a certain block height.
--

module Chainweb.Version.Guards
Expand Down Expand Up @@ -44,9 +44,7 @@ module Chainweb.Version.Guards
, chainweb223Pact
, chainweb224Pact
, chainweb225Pact
, chainweb226Pact
, chainweb228Pact
, chainweb229Pact
, chainweb230Pact
, chainweb231Pact
, chainweb31
Expand Down Expand Up @@ -82,6 +80,9 @@ import Pact.Core.Serialise qualified as Pact5
import Pact.Types.KeySet (PublicKeyText, ed25519HexFormat, webAuthnFormat)
import Pact.Types.Scheme (PPKScheme(ED25519, WebAuthn))

-- Gets the height which the fork is associated with.
-- This may not be the first height at which the associated guard is `True`
-- necessarily; check the guard to see how it uses the fork's height.
getForkHeight :: Fork -> ChainwebVersion -> ChainId -> ForkHeight
getForkHeight fork v cid = v ^?! versionForks . at fork . _Just . atChain cid

Expand All @@ -105,6 +106,8 @@ before bh (ForkAtBlockHeight bh') = bh < bh'
before _ ForkAtGenesis = False
before _ ForkNever = True

-- Intended for forks that intend to run upgrades at exactly one height, and so
-- can't be "pre-activated" for genesis.
atNotGenesis :: BlockHeight -> ForkHeight -> Bool
atNotGenesis bh (ForkAtBlockHeight bh') = bh == bh'
atNotGenesis _ ForkAtGenesis = error "fork cannot be at genesis"
Expand All @@ -113,15 +116,16 @@ atNotGenesis _ ForkNever = False
-- -------------------------------------------------------------------------- --
-- Header Validation Guards
--
-- The guards in this section encode when changes to validation rules for data
-- The guards in this section encode when changes to validation rules for blocks
-- on the chain become effective.
--
-- Only the following types are allowed as parameters for guards
-- Guards can only take as parameters data that was available when a block was
-- not yet produced. For example, the block creation time, block hash, and nonce
-- of that block are not available, because they were not available before the
-- block was produced.
--
-- * BlockHeader,
-- * ParentHeader,
-- * BlockCreationTime, and
-- * ParentCreationTime
-- In practice, the relevant input data is the `ChainwebVersion`, `ChainId`, and
-- `BlockHeight` of the block under consideration.
--
-- The result is a simple 'Bool'.
--
Expand Down Expand Up @@ -217,79 +221,99 @@ enablePactEvents = checkFork atOrAfter PactEvents
enableSPVBridge :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
enableSPVBridge = checkFork atOrAfter SPVBridge

-- | Should Pact check that keysets have a legal format?
enforceKeysetFormats :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
enforceKeysetFormats = checkFork atOrAfter EnforceKeysetFormats

-- | Should Pact check that the `hash` included with a `Command` is correct?
doCheckTxHash :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
doCheckTxHash = checkFork atOrAfter CheckTxHash

-- | Fork for musl trans funs
pact44NewTrans :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
pact44NewTrans = checkFork atOrAfter Pact44NewTrans

-- | Pact 4.0 features
pact4Coin3 :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
pact4Coin3 = checkFork after Pact4Coin3

-- | Pact 4.2 features
pact42 :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
pact42 = checkFork atOrAfter Pact42

pact5 :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
pact5 = checkFork atOrAfter Pact5Fork

-- | Pact charges gas for the size of transitive module dependencies
chainweb213Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb213Pact = checkFork atOrAfter Chainweb213Pact

-- | Pact 4.3 features
chainweb214Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb214Pact = checkFork after Chainweb214Pact

-- | Pact 4.3.1 features
chainweb215Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb215Pact = checkFork after Chainweb215Pact

-- | Pact 4.4 features, including new expression parser
chainweb216Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb216Pact = checkFork after Chainweb216Pact

-- | Pact 4.5 features, and considering all table names lowercase
chainweb217Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb217Pact = checkFork after Chainweb217Pact

-- | Pact 4.6 features
chainweb218Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb218Pact = checkFork atOrAfter Chainweb218Pact

-- | Pact 4.7 features + new SPV errors without callstacks
chainweb219Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb219Pact = checkFork atOrAfter Chainweb219Pact

-- | Pact 4.8 features
chainweb220Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb220Pact = checkFork atOrAfter Chainweb220Pact

-- Pact 4.9 features + new spv base64 errors that don't depend on legacy library
-- versions
chainweb221Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb221Pact = checkFork atOrAfter Chainweb221Pact

-- | Pact 4.10 features, webauthn keys and signatures
chainweb222Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb222Pact = checkFork atOrAfter Chainweb222Pact

-- | Pact 4.11 features, verifier plugins
chainweb223Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb223Pact = checkFork atOrAfter Chainweb223Pact

-- | Pact 4.12 features, optimized buy/redeem gas transactions reduce gas cost
-- for all transactions
chainweb224Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb224Pact = checkFork atOrAfter Chainweb224Pact

-- | Update Hyperlane verifier plugin to provide a "merkle tree ISM"
chainweb225Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb225Pact = checkFork atOrAfter Chainweb225Pact

chainweb226Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb226Pact = checkFork atOrAfter Chainweb226Pact
-- | Pact 5, an entirely new Pact compiler and interpreter, and comes with some
-- big changes to PactService
pact5 :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
pact5 = checkFork atOrAfter Pact5Fork

-- | Pact 5.1, including a new more succinct serializer for modules
chainweb228Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb228Pact = checkFork atOrAfter Chainweb228Pact

chainweb229Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb229Pact = checkFork atOrAfter Chainweb229Pact

-- | Pact 5.2 and 5.3, including a re-entrancy check for module references
-- Also, a fix for duplicates in `keys`
chainweb230Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb230Pact = checkFork atOrAfter Chainweb230Pact

-- | Pact 5.4, SPV proof root expiry
chainweb231Pact :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb231Pact = checkFork atOrAfter Chainweb231Pact

-- | Fork numbering and voting, continuation proof size gassed
chainweb31 :: ChainwebVersion -> ChainId -> BlockHeight -> Bool
chainweb31 = checkFork atOrAfter Chainweb31

Expand Down
2 changes: 0 additions & 2 deletions src/Chainweb/Version/Mainnet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,8 @@ mainnet = ChainwebVersion
Chainweb223Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 4_577_530) -- 2024-03-07 00:00:00+00:00
Chainweb224Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 4_819_246) -- 2024-05-30 00:00:00+00:00
Chainweb225Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 5_060_924) -- 2024-08-22 00:00:00+00:00
Chainweb226Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 5_302_559) -- 2024-11-14 00:00:00+00:00
Pact5Fork -> AllChains (ForkAtBlockHeight $ BlockHeight 5_555_698) -- 2025-02-10 00:00:00+00:00
Chainweb228Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 5_659_280) -- 2025-03-18 00:00:00+00:00
Chainweb229Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 5_785_923) -- 2025-05-01 00:00:00+00:00
Chainweb230Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 6_027_616) -- 2025-07-24 00:00:00+00:00
Chainweb231Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 6_269_344) -- 2025-10-16 00:00:00+00:00
MigratePlatformShare -> AllChains (ForkAtBlockHeight $ BlockHeight 6_335_858) -- 2025-11-07 04:00:00+00:00
Expand Down
2 changes: 0 additions & 2 deletions src/Chainweb/Version/RecapDevelopment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ recapDevnet = ChainwebVersion
Chainweb223Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 600
Chainweb224Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 610
Chainweb225Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 620
Chainweb226Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 630
Pact5Fork -> AllChains $ ForkAtBlockHeight $ BlockHeight 640
Chainweb228Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 650
Chainweb229Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 660
Chainweb230Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 680
Chainweb231Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 690
Chainweb31 -> AllChains $ ForkAtBlockHeight $ BlockHeight 700
Expand Down
2 changes: 0 additions & 2 deletions src/Chainweb/Version/Testnet04.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ testnet04 = ChainwebVersion
Chainweb223Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 4_100_681 -- 2024-03-06 12:00:00+00:00
Chainweb224Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 4_333_587 -- 2024-05-29 12:00:00+00:00
Chainweb225Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 4_575_072 -- 2024-08-21 12:00:00+00:00
Chainweb226Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 4_816_925 -- 2024-11-13 12:00:00+00:00
Pact5Fork -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_058_738 -- 2025-02-05 12:00:00+00:00
Chainweb228Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_155_146 -- 2025-03-11 00:00:00+00:00
Chainweb229Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_300_466 -- 2025-04-30 12:00:00+00:00
Chainweb230Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_542_190 -- 2025-07-23 12:00:00+00:00
Chainweb231Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_783_985 -- 2025-10-15 12:00:00+00:00
Chainweb31 -> AllChains ForkNever
Expand Down
4 changes: 0 additions & 4 deletions test/lib/Chainweb/Test/TestVersions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,8 @@ slowForks = tabulateHashMap \case
Chainweb223Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 120)
Chainweb224Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 125)
Chainweb225Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 130)
Chainweb226Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 135)
Pact5Fork -> AllChains ForkNever
Chainweb228Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 145)
Chainweb229Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 150)
Chainweb230Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 155)
Chainweb231Pact -> AllChains $ ForkAtBlockHeight (BlockHeight 160)
Chainweb31 -> AllChains $ ForkAtBlockHeight (BlockHeight 165)
Expand Down Expand Up @@ -368,10 +366,8 @@ fastForks = tabulateHashMap $ \case
Chainweb223Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 38
Chainweb224Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 40
Chainweb225Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 42
Chainweb226Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 44
Pact5Fork -> AllChains $ ForkAtBlockHeight $ BlockHeight 46
Chainweb228Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 48
Chainweb229Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 50
Chainweb230Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 52
Chainweb231Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 54
Chainweb31 -> AllChains $ ForkAtBlockHeight $ BlockHeight 56
Expand Down
Loading