package tezos-protocol-013-PtJakart
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=43723d096307603703a1a89ed1b2eb202b365f5e7824b96b0cbf813b343a6cf7
sha512=b2a637f2e965000d3d49ad85277ca24d6cb07a1a7cf2bc69d296d8b03ad78c3eaa8e21e94b9162e62c2e11649cd03bc845b2a3dafe623b91065df69d47dc8e4f
doc/tezos-protocol-013-PtJakart.raw/Tezos_raw_protocol_013_PtJakart/Script_cache/index.html
Module Tezos_raw_protocol_013_PtJakart.Script_cache
Source
This module manages the cache for smart contracts.
This cache must be consistent with the on-disk representation of the smart contracts. In particular, update
must be called each time a contract storage is updated.
Each cached script has a unique identifier in the cache.
The cache holds the unparsed and the internal representation of the contract.
val find :
Alpha_context.context ->
Alpha_context.Contract.t ->
(Alpha_context.context * identifier * cached_contract option)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
find ctxt contract
returns (ctxt', identifier, script)
where:
ctxt'
isctxt
with less gas;identifier
is the identifier identifying thecontract
in the cache;script = None
if there is no such contract inctxt
;script = Some (unparsed_script, ir_script)
whereunparsed_script
is the contract source code and storage;script_ir
is a typed internal representation of the contract, i.e., the abstract syntax tree of its code as well as its storage.
This function consumes gas depending on the cache. If the contract is not in the cache, then the function also consumes the gas of Contract.get_script
and Script_ir_translator.parse_script
.
val update :
Alpha_context.context ->
identifier ->
cached_contract ->
int ->
Alpha_context.context
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
update ctxt identifier unparsed_script ir_script size
refreshes the cached contract identified by identifier
with a new unparsed_script
, a new ir_script
, and a new size.
val entries :
Alpha_context.context ->
(Alpha_context.Contract.t * int) list
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
entries ctxt
returns the contracts in the cache as well as their respective size. The list is sorted by date of last modification: the least recently updated entry comes first.
contract_rank ctxt contract
returns the number of contracts older than contract
in the cache of ctxt
. This function returns None
if contract
does not exist in the cache of ctxt
.
size ctxt
is an overapproximation of the cache size in memory (in bytes).
size_limit ctxt
is the maximal size of the cache (in bytes).
val insert :
Alpha_context.context ->
Alpha_context.Contract.t ->
cached_contract ->
int ->
Alpha_context.context
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
insert
is a variant of update
which identifies the contract to update by its address (of type Contract.t
) instead of its cache identifier.