Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Morley.Michelson.Interpret
Description
Module, containing function to interpret Michelson instructions against given context and input stack.
Synopsis
- data ContractEnv = ContractEnv {
- ceNow :: Timestamp
- ceMaxSteps :: RemainingSteps
- ceBalance :: Mutez
- ceContracts :: Map ContractAddress ContractState
- ceSelf :: ContractAddress
- ceSource :: L1Address
- ceSender :: L1Address
- ceAmount :: Mutez
- ceVotingPowers :: VotingPowers
- ceChainId :: ChainId
- ceOperationHash :: Maybe OperationHash
- ceLevel :: Natural
- ceErrorSrcPos :: ErrorSrcPos
- ceMinBlockTime :: Natural
- data InterpreterState = InterpreterState {}
- data MichelsonFailed ext where
- MichelsonFailedWith :: (SingI t, ConstantScope t) => Value t -> MichelsonFailed ext
- MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed ext
- MichelsonGasExhaustion :: MichelsonFailed ext
- MichelsonFailedTestAssert :: Text -> MichelsonFailed ext
- MichelsonUnsupported :: Text -> MichelsonFailed ext
- MichelsonExt :: ext -> MichelsonFailed ext
- data MichelsonFailureWithStack ext = MichelsonFailureWithStack {}
- newtype RemainingSteps = RemainingSteps Word64
- data SomeItStack where
- SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack
- newtype MorleyLogs = MorleyLogs {
- unMorleyLogs :: [Text]
- buildMorleyLogs :: MorleyLogsBuilder -> MorleyLogs
- newtype MorleyLogsBuilder = MorleyLogsBuilder (Endo [Text])
- interpret :: Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> GlobalCounter -> BigMapCounter -> ContractEnv -> ContractReturn st
- interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec Value out)
- interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec StkEl out)
- type ContractReturn st = (Either (MichelsonFailureWithStack Void) ([Operation], Value st), (InterpreterState, MorleyLogs))
- mkInitStack :: Value param -> Value st -> Rec StkEl (ContractInp param st)
- fromFinalStack :: Rec StkEl (ContractOut st) -> ([Operation], Value st)
- newtype InterpretError ext = InterpretError (MichelsonFailureWithStack ext, MorleyLogs)
- data InterpretResult where
- InterpretResult :: StorageScope st => {..} -> InterpretResult
- type EvalM m = EvalM' Void m
- class Monad m => InterpreterStateMonad m where
- getInterpreterState :: m InterpreterState
- putInterpreterState :: InterpreterState -> m ()
- stateInterpreterState :: (InterpreterState -> (a, InterpreterState)) -> m a
- modifyInterpreterState :: (InterpreterState -> InterpreterState) -> m ()
- newtype StkEl t = StkEl {}
- type InstrRunner m = forall inp out. Instr inp out -> Rec StkEl inp -> m (Rec StkEl out)
- runInstr :: EvalM m => InstrRunner m
- runInstrNoGas :: EvalM m => InstrRunner m
- runUnpack :: forall t. UnpackedValScope t => ByteString -> Either UnpackError (Value t)
- initInterpreterState :: GlobalCounter -> BigMapCounter -> ContractEnv -> InterpreterState
- handleContractReturn :: StorageScope st => ContractReturn st -> Either (InterpretError Void) InterpretResult
- runInstrImpl :: forall ext m. EvalM' ext m => InstrRunner m -> InstrRunner m
- assignBigMapIds :: MonadState BigMapCounter m => Bool -> Value t -> m (Value t)
- _MorleyLogs :: Iso' MorleyLogs [Text]
Documentation
data ContractEnv Source #
Environment for contract execution.
Constructors
ContractEnv | |
Fields
|
data InterpreterState Source #
Constructors
InterpreterState | |
Instances
data MichelsonFailed ext where Source #
Errors that can be thrown by the interpreter. The ext
type variable
allow the downstreams consumer to add additional exceptions.
Constructors
MichelsonFailedWith | |
Fields
| |
MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed ext | |
MichelsonGasExhaustion :: MichelsonFailed ext | |
MichelsonFailedTestAssert :: Text -> MichelsonFailed ext | |
MichelsonUnsupported :: Text -> MichelsonFailed ext | |
MichelsonExt :: ext -> MichelsonFailed ext |
Instances
Show ext => Show (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret Methods showsPrec :: Int -> MichelsonFailed ext -> ShowS # show :: MichelsonFailed ext -> String # showList :: [MichelsonFailed ext] -> ShowS # | |
NFData ext => NFData (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret Methods rnf :: MichelsonFailed ext -> () # | |
Buildable ext => Buildable (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret Methods build :: MichelsonFailed ext -> Builder # | |
Eq ext => Eq (MichelsonFailed ext) Source # | |
Defined in Morley.Michelson.Interpret Methods (==) :: MichelsonFailed ext -> MichelsonFailed ext -> Bool # (/=) :: MichelsonFailed ext -> MichelsonFailed ext -> Bool # |
data MichelsonFailureWithStack ext Source #
Carries a MichelsonFailed
ext
error and the ErrorSrcPos
at which it was raised
Constructors
MichelsonFailureWithStack | |
Fields
|
Instances
newtype RemainingSteps Source #
Constructors
RemainingSteps Word64 |
Instances
data SomeItStack where Source #
Constructors
SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack |
newtype MorleyLogs Source #
Morley logs appearing as interpreter result.
Constructors
MorleyLogs | |
Fields
|
Instances
newtype MorleyLogsBuilder Source #
Morley logs accumulator, for incremental building.
Constructors
MorleyLogsBuilder (Endo [Text]) |
Instances
interpret :: Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> GlobalCounter -> BigMapCounter -> ContractEnv -> ContractReturn st Source #
interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec Value out) Source #
Interpret an instruction in vacuum, putting no extra constraints on its execution.
Mostly for testing purposes.
interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec StkEl out) Source #
Interpret an instruction in vacuum, putting no extra constraints on its execution while preserving its annotations.
Mostly for testing purposes.
type ContractReturn st = (Either (MichelsonFailureWithStack Void) ([Operation], Value st), (InterpreterState, MorleyLogs)) Source #
mkInitStack :: Value param -> Value st -> Rec StkEl (ContractInp param st) Source #
fromFinalStack :: Rec StkEl (ContractOut st) -> ([Operation], Value st) Source #
newtype InterpretError ext Source #
Constructors
InterpretError (MichelsonFailureWithStack ext, MorleyLogs) |
Instances
data InterpretResult where Source #
Constructors
InterpretResult | |
Fields
|
Instances
Show InterpretResult Source # | |
Defined in Morley.Michelson.Interpret Methods showsPrec :: Int -> InterpretResult -> ShowS # show :: InterpretResult -> String # showList :: [InterpretResult] -> ShowS # |
class Monad m => InterpreterStateMonad m where Source #
Minimal complete definition
Nothing
Methods
getInterpreterState :: m InterpreterState Source #
putInterpreterState :: InterpreterState -> m () Source #
stateInterpreterState :: (InterpreterState -> (a, InterpreterState)) -> m a Source #
modifyInterpreterState :: (InterpreterState -> InterpreterState) -> m () Source #
Instances
runInstr :: EvalM m => InstrRunner m Source #
Function to change amount of remaining steps stored in State monad.
runInstrNoGas :: EvalM m => InstrRunner m Source #
runUnpack :: forall t. UnpackedValScope t => ByteString -> Either UnpackError (Value t) Source #
Unpacks given raw data into a typed value.
Internals
handleContractReturn :: StorageScope st => ContractReturn st -> Either (InterpretError Void) InterpretResult Source #
runInstrImpl :: forall ext m. EvalM' ext m => InstrRunner m -> InstrRunner m Source #
Function to interpret Michelson instruction(s) against given stack.
The ext
type variable specifies additional exceptions that can be thrown from the inner
runner function (via MichelsonExt
). In Morley, it's set to Void
, but downstream consumers
may use other type here.
Arguments
:: MonadState BigMapCounter m | |
=> Bool | If true, assign a new ID even if the bigmap already has one. Otherwise, assign IDs only to bigmaps that don't have one yet. |
-> Value t | |
-> m (Value t) |
All big_maps stored in a chain have a globally unique ID.
We use this function to assign a new ID whenever a big_map is created.
Prisms
_MorleyLogs :: Iso' MorleyLogs [Text] Source #