Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistent renaming of Pacts #25

Merged
merged 1 commit into from
Oct 24, 2023
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
2 changes: 1 addition & 1 deletion pact-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ library
Pact.Core.Literal
Pact.Core.Guards
Pact.Core.Imports
Pact.Core.Pacts.Types
Pact.Core.DefPacts.Types
Pact.Core.Hash
Pact.Core.Type
Pact.Core.Pretty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}

module Pact.Core.Pacts.Types
( PactContinuation(..)
module Pact.Core.DefPacts.Types
( DefPactContinuation(..)
, pcName, pcArgs
, PactStep(..)
, psStep, psRollback, psPactId, psResume
, PactExec(..)
, peStepCount, peYield, peStep, peContinuation, peStepHasRollback, pePactId
, peNestedPactExec
, DefPactStep(..)
, psStep, psRollback, psDefPactId, psResume
, DefPactExec(..)
, peStepCount, peYield, peStep, peContinuation, peStepHasRollback, peDefPactId
, peNestedDefPactExec
, Yield(..)
, Provenance(..)
) where
Expand All @@ -22,13 +22,13 @@ import Pact.Core.Names
import Pact.Core.Hash
import Pact.Core.ChainData

data PactContinuation name v
= PactContinuation
data DefPactContinuation name v
= DefPactContinuation
{ _pcName :: name
, _pcArgs :: [v]
} deriving (Eq, Show)

makeLenses ''PactContinuation
makeLenses ''DefPactContinuation

-- | Provenance datatype contains all of the necessary
-- data to 'endorse' a yield object.
Expand All @@ -46,28 +46,28 @@ data Yield
= Yield
{ _yData :: Map Field PactValue
, _yProvenance :: Maybe Provenance
, _ySourceChain :: Maybe ChainId }
deriving (Show)
, _ySourceChain :: Maybe ChainId
} deriving Show

-- | Internal representation of pacts
data PactExec
= PactExec
data DefPactExec
= DefPactExec
{ _peStepCount :: Int
, _peYield :: Maybe Yield
, _peStep :: Int
, _pePactId :: PactId
, _peContinuation :: PactContinuation FullyQualifiedName PactValue
, _peDefPactId :: DefPactId
, _peContinuation :: DefPactContinuation FullyQualifiedName PactValue
, _peStepHasRollback :: Bool
, _peNestedPactExec :: Map PactId PactExec
, _peNestedDefPactExec :: Map DefPactId DefPactExec
} deriving Show

makeLenses ''PactExec
makeLenses ''DefPactExec

data PactStep = PactStep
data DefPactStep = DefPactStep
{ _psStep :: !Int
, _psRollback :: !Bool
, _psPactId :: !PactId
, _psDefPactId :: !DefPactId
, _psResume :: !(Maybe Yield)
} deriving Show

makeLenses ''PactStep
makeLenses ''DefPactStep
8 changes: 4 additions & 4 deletions pact-core/Pact/Core/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Pact.Core.Environment
( EvalEnv(..)
, eeMsgSigs, eePactDb
, eeHash, eeMsgBody
, eePactStep
, eeDefPactStep
, eePublicData, eeMode, eeFlags
, PactState(..)
, psLoaded
Expand Down Expand Up @@ -57,7 +57,7 @@ import Pact.Core.Guards
import Pact.Core.PactValue ( PactValue, EnvData )
import Pact.Core.Hash
import Pact.Core.Names
import Pact.Core.Pacts.Types
import Pact.Core.DefPacts.Types
import Pact.Core.ChainData

-- | Execution flags specify behavior of the runtime environment,
Expand Down Expand Up @@ -95,7 +95,7 @@ data EvalEnv b i
, _eeMsgBody :: EnvData PactValue
, _eeHash :: Hash
, _eePublicData :: PublicData
, _eePactStep :: Maybe PactStep
, _eeDefPactStep :: Maybe DefPactStep
, _eeMode :: ExecutionMode
-- ^ The pact execution mode: local or transactional
, _eeFlags :: Set ExecutionFlag
Expand Down Expand Up @@ -129,7 +129,7 @@ data EvalState b i
, _esStack :: [StackFrame]
, _esEvents :: [PactEvent PactValue]
, _esLoaded :: Loaded b i
, _esPactExec :: Maybe PactExec
, _esDefPactExec :: Maybe DefPactExec
} deriving Show

instance Default (EvalState b i) where
Expand Down
104 changes: 52 additions & 52 deletions pact-core/Pact/Core/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Pact.Core.Info
import Pact.Core.Pretty(Pretty(..))
import Pact.Core.Hash
import Pact.Core.Persistence
import Pact.Core.Pacts.Types
import Pact.Core.DefPacts.Types

import qualified Pact.Core.Pretty as Pretty

Expand Down Expand Up @@ -273,43 +273,43 @@ data EvalError
| NoSuchKeySet KeySetName
-- ^ No such keyset
| YieldOutsiteDefPact
-- ^ Yield a value outside a running PactExec
| NoActivePactExec
-- ^ No Active PactExec in the environment
| NoYieldInPactStep PactStep
-- ^ No Yield available in PactStep
| InvalidPactStepSupplied PactStep PactExec
-- ^ Supplied PactStep requests an invalid step
| DefPactIdMissmatch PactId PactId
-- ^ Yield a value outside a running DefPactExec
| NoActiveDefPactExec
-- ^ No Active DefPactExec in the environment
| NoYieldInDefPactStep DefPactStep
-- ^ No Yield available in DefPactStep
| InvalidDefPactStepSupplied DefPactStep DefPactExec
-- ^ Supplied DefPactStep requests an invalid step
| DefPactIdMissmatch DefPactId DefPactId
-- ^ Requested PactId does not match context PactId
| CCDefPactContinuationError PactStep PactExec PactExec
| CCDefPactContinuationError DefPactStep DefPactExec DefPactExec
-- ^ Crosschain DefPact contunation must be at least 2 steps before CC continuation step
-- with <ccExec> <dbExec>
| NoPreviousDefPactExecutionFound PactStep
| NoPreviousDefPactExecutionFound DefPactStep
-- ^ No previouse DefPact execution could be found in the environment or database
| DefPactAlreadyCompleted PactStep
| DefPactAlreadyCompleted DefPactStep
-- ^ DefPact already completed
| NestedDefPactParentStepCountMissmatch PactId Int Int
| NestedDefPactParentStepCountMissmatch DefPactId Int Int
-- ^ Nested DefPact <stepcount> does not match <parent step count>
| NestedDefPactParentRollbackMissmatch PactId Bool Bool
| NestedDefPactParentRollbackMissmatch DefPactId Bool Bool
-- ^ Nested DefPact <rollback> does not match <parent rollback>
| NestedDefPactNeverStarted PactStep
| NestedDefPactNeverStarted DefPactStep
-- ^ Nested DefPact never started at prior step
| NestedDefPactDoubleExecution PactStep
| NestedDefPactDoubleExecution DefPactStep
-- ^ Nested DefPact is executed twice
| MultipleOrNestedDefPactExecFound PactExec
-- ^ Unexpected PactExec found in the environment
| DefPactStepNotFound PactStep Int
| MultipleOrNestedDefPactExecFound DefPactExec
-- ^ Unexpected DefPactExec found in the environment
| DefPactStepNotFound DefPactStep Int
-- ^ The expected step could not be found in the DefPact
| PactStepHasNoRollback PactStep
-- ^ The requested PactStep has no rollback
| PactStepNotInEnvironment
-- ^ PactStep is not in the environment
| DefPactStepHasNoRollback DefPactStep
-- ^ The requested DefPactStep has no rollback
| DefPactStepNotInEnvironment
-- ^ DefPactStep is not in the environment
| NoDefPactIdAndExecEnvSupplied
-- ^ No PactId supplied and no PactExec found in the environment
| DefPactRollbackMissmatch PactStep PactExec
-- ^ No DefPactId supplied and no DefPactExec found in the environment
| DefPactRollbackMissmatch DefPactStep DefPactExec
-- ^ DefPact rollback missmatch
| DefPactStepMissmatch PactStep PactExec
| DefPactStepMissmatch DefPactStep DefPactExec
-- ^ DefPact missmatch
| CannotUpgradeInterface ModuleName
-- ^ Interface cannot be upgrade
Expand All @@ -329,9 +329,9 @@ data EvalError
| NativeIsTopLevelOnly NativeName
| EventDoesNotMatchModule ModuleName
| InvalidEventCap FullyQualifiedName
| NestedDefpactsNotAdvanced PactId
| NestedDefpactsNotAdvanced DefPactId
| ExpectedPactValue
| NotInPactExecution
| NotInDefPactExecution
deriving Show


Expand Down Expand Up @@ -373,29 +373,29 @@ instance Pretty EvalError where
-- NoSuchKeySet _ -> error ""
YieldOutsiteDefPact ->
"Try to yield a value outside a running DefPact execution"
NoActivePactExec ->
NoActiveDefPactExec ->
"No active DefPact execution in the environment"
NoYieldInPactStep (PactStep step _ i _) ->
NoYieldInDefPactStep (DefPactStep step _ i _) ->
Pretty.hsep ["No yield in DefPactStep:", "Step: " <> pretty step, "DefPactId: " <> pretty i]
InvalidPactStepSupplied (PactStep step _ _ _) pe ->
InvalidDefPactStepSupplied (DefPactStep step _ _ _) pe ->
Pretty.hsep
[ "PactStep does not match DefPact properties:"
[ "DefPactStep does not match DefPact properties:"
, "requested: "<> pretty step
, "step count:" <> pretty (_peStepCount pe)]
DefPactIdMissmatch reqId envId ->
Pretty.hsep
[ "Requested PactId:", pretty reqId
, "does not match context PactId:", pretty envId
[ "Requested DefPactId:", pretty reqId
, "does not match context DefPactId:", pretty envId
]
CCDefPactContinuationError pactStep _ccExec _dbExec ->
Pretty.hsep
[ "Crosschain DefPact continuation error:"
, "PactId:" <> pretty (_psStep pactStep)
, "DefPactId:" <> pretty (_psStep pactStep)
]
NestedDefPactParentRollbackMissmatch pid rollback parentRollback ->
Pretty.hsep
[ "Nested DefPact execution failed, parameter missmatch:"
, "PactId: " <> pretty pid
, "DefPactId: " <> pretty pid
, "Rollback: " <> pretty rollback
, "Parent rollback:" <> pretty parentRollback
]
Expand All @@ -407,35 +407,35 @@ instance Pretty EvalError where
, "Parent step count: " <> pretty parentStepCount
]
NoPreviousDefPactExecutionFound ps ->
Pretty.hsep ["No previous DefPact exeuction found for PactId: ", pretty (_psPactId ps)]
Pretty.hsep ["No previous DefPact exeuction found for DefPactId: ", pretty (_psDefPactId ps)]
DefPactAlreadyCompleted ps -> Pretty.hsep
[ "Requested DefPact already completed: ", "PactId:" <> pretty (_psPactId ps)]
[ "Requested DefPact already completed: ", "DefPactId:" <> pretty (_psDefPactId ps)]
NestedDefPactNeverStarted ps -> Pretty.hsep
["Requested nested DefPact never started:", "PactId: " <> pretty (_psPactId ps)]
["Requested nested DefPact never started:", "DefPactId: " <> pretty (_psDefPactId ps)]
NestedDefPactDoubleExecution ps -> Pretty.hsep
["Requested nested DefPact double execution:", "PactId: " <> pretty (_psPactId ps)]
["Requested nested DefPact double execution:", "DefPactId: " <> pretty (_psDefPactId ps)]
MultipleOrNestedDefPactExecFound pe -> Pretty.hsep
["DefPact execution context already in the environment: ", "PactId: " <> pretty (_pePactId pe)]
["DefPact execution context already in the environment: ", "DefPactId: " <> pretty (_peDefPactId pe)]
DefPactStepNotFound ps maxSteps -> Pretty.hsep
[ "Requested DefPact step exceeds available steps:"
, "requested: " <> pretty (_psStep ps)
, "available: " <> pretty maxSteps
]
PactStepHasNoRollback ps -> Pretty.hsep
["Step has no rollback:", "PactId: " <> pretty (_psPactId ps)]
PactStepNotInEnvironment -> "No PactStep in the environment"
NoDefPactIdAndExecEnvSupplied -> "No PactId or execution environment supplied"
DefPactStepHasNoRollback ps -> Pretty.hsep
["Step has no rollback:", "DefPactId: " <> pretty (_psDefPactId ps)]
DefPactStepNotInEnvironment -> "No DefPactStep in the environment"
NoDefPactIdAndExecEnvSupplied -> "No DefPactId or execution environment supplied"
DefPactRollbackMissmatch ps pe -> Pretty.hsep
[ "Rollback missmatch in PactStep and DefPact exeuction environment:"
, "PactId: " <> pretty (_psPactId ps)
[ "Rollback missmatch in DefPactStep and DefPact exeuction environment:"
, "DefPactId: " <> pretty (_psDefPactId ps)
, "step rollback: " <> pretty (_psRollback ps)
, "PactExec rollback: " <> pretty (_peStepHasRollback pe)
, "DefPactExec rollback: " <> pretty (_peStepHasRollback pe)
]
DefPactStepMissmatch ps pe -> Pretty.hsep
[ "Step missmatch in PactStep and DefPact exeuction environment:"
, "PactId: " <> pretty (_psPactId ps)
[ "Step missmatch in DefPactStep and DefPact exeuction environment:"
, "DefPactId: " <> pretty (_psDefPactId ps)
, "step: " <> pretty (_psStep ps)
, "PactExec step: " <> pretty (_peStep pe + 1)
, "DefPactExec step: " <> pretty (_peStep pe + 1)
]
e -> pretty (show e)
-- CannotUpgradeInterface _ -> error ""
Expand All @@ -454,7 +454,7 @@ instance Pretty EvalError where
-- InvalidEventCap _ -> error ""
-- NestedDefpactsNotAdvanced _ -> error ""
-- ExpectedPactValue -> error ""
-- NotInPactExecution -> error ""
-- NotInDefPactExecution -> error ""

instance Exception EvalError

Expand Down
2 changes: 1 addition & 1 deletion pact-core/Pact/Core/Guards.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ data CapabilityGuard name term
= CapabilityGuard
{ _cgName :: !name
, _cgArgs :: ![term]
, _cgPactId :: !(Maybe PactId) }
, _cgPactId :: !(Maybe DefPactId) }
deriving (Eq, Ord, Show, Functor, Foldable, Traversable)

data Guard name term
Expand Down
Loading
Loading