Package convex.core.lang
Class Juice
java.lang.Object
convex.core.lang.Juice
Static class defining juice costs for executable operations.
"LISP programmers know the value of everything and the cost of nothing." -
Alan Perlis
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic long
Juice cost for accepting an offer of Convex coins.protected static long
static long
Juice for an apply operation Bit of cost to allow for parameter construction.protected static long
static long
Juice cost for an 'assoc'protected static long
protected static long
Juice for creation of a blobprotected static long
protected static long
Juice required to build a data structure.protected static long
Juice required per element changed when building a data structure.static long
Juice required to call an Actor Slightly expensive for context switching?static long
Juice for a very cheap operation.static long
Juice cost to compile a Constant valuestatic long
Juice cost to compile a Constant valuestatic long
Juice cost to compile a general AST nodestatic long
Juice required to execute a Cond expression Pretty cheap, nothing nasty here (though conditions / results themselves might get pricey).static long
Juice required to resolve a constant value Very cheap, no allocs / lookup.static long
static long
Juice required to define a value in the current environment.static long
Juice for a contract deployment Make this quite expensive, mainly to deter lots of willy-nilly deployingstatic long
Juice required to execute a Do block Very cheap, no allocs.static long
Juice for general object equality comparison Pretty cheap.protected static long
Probably should be expensive?static long
Juice cost to expand a constantstatic long
Juice cost to expand a sequenceprotected static long
protected static long
static long
Juice for a cryptographic hash Expensive.protected static long
static long
Juice required to create a lambda Sort of expensive - might allocate a bunch of stuff for the closure?static long
Juice required to execute a Let block Fairly cheap but some parameter munging required.static long
static long
Juice required to look up a value in the local environment.static long
Juice required to look up a value in the dynamic environment.static long
Juice required to look up a symbol with a regular Addressprotected static long
static long
Juice cost for extracting metadata from a Syntax object.static long
Juice for numeric comparison Pretty cheap.static long
Make this quite expensive.static long
static long
Juice for a recur form Fairly cheap, might have to construct some temp structures for recur arguments.protected static long
static long
Juice required to execute an exceptional return (return, halt, rollback etc.) Pretty cheap, one alloc and a bit of exceptional value handling.static long
Juice cost to schedulestatic long
Default future schedule juice (10 per hour) This makes scheduling a few hours / days ahead cheap but year is quite expensive (~87,600).static long
static long
Variable Juice cost for set comparisonstatic long
Juice for a simple built-in core function.static long
static long
protected static long
Juice for storing a new constant value permanently in on-chain state Charged per node storedprotected static long
Juice for constructing a String Fairly cheap, since mostly in fast code, but charge extra for additional chars.protected static long
protected static long
static long
Juice cost for constructing a Syntax Object.static long
-
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
CONSTANT
public static final long CONSTANTJuice required to resolve a constant value Very cheap, no allocs / lookup.- See Also:
- Constant Field Values
-
DEF
public static final long DEFJuice required to define a value in the current environment. We make this somewhat expensive - we want to discourage over-use as a general rule since it writes to global chain state. However memory accounting helps discourage superfluous defs, so it only needs to reflect execution cost.- See Also:
- Constant Field Values
-
LOOKUP
public static final long LOOKUPJuice required to look up a value in the local environment.- See Also:
- Constant Field Values
-
LOOKUP_DYNAMIC
public static final long LOOKUP_DYNAMICJuice required to look up a value in the dynamic environment. Potentially a bit pricey since read only, but might hit storage so.....- See Also:
- Constant Field Values
-
LOOKUP_SYM
public static final long LOOKUP_SYMJuice required to look up a symbol with a regular Address- See Also:
- Constant Field Values
-
DO
public static final long DOJuice required to execute a Do block Very cheap, no allocs.- See Also:
- Constant Field Values
-
LET
public static final long LETJuice required to execute a Let block Fairly cheap but some parameter munging required. Might revisit binding costs?- See Also:
- Constant Field Values
-
COND_OP
public static final long COND_OPJuice required to execute a Cond expression Pretty cheap, nothing nasty here (though conditions / results themselves might get pricey).- See Also:
- Constant Field Values
-
LAMBDA
public static final long LAMBDAJuice required to create a lambda Sort of expensive - might allocate a bunch of stuff for the closure?- See Also:
- Constant Field Values
-
CALL_OP
public static final long CALL_OPJuice required to call an Actor Slightly expensive for context switching?- See Also:
- Constant Field Values
-
BUILD_DATA
protected static final long BUILD_DATAJuice required to build a data structure. Make a bit expensive?- See Also:
- Constant Field Values
-
BUILD_PER_ELEMENT
protected static final long BUILD_PER_ELEMENTJuice required per element changed when building a data structure. Map entries count as two elements. We need to be a bit harsh on this! Risk of consuming too much heap space, might also result in multiple allocs for tree structures.- See Also:
- Constant Field Values
-
MAP
protected static final long MAP- See Also:
- Constant Field Values
-
REDUCE
protected static final long REDUCE- See Also:
- Constant Field Values
-
EQUALS
public static final long EQUALSJuice for general object equality comparison Pretty cheap.- See Also:
- Constant Field Values
-
NUMERIC_COMPARE
public static final long NUMERIC_COMPAREJuice for numeric comparison Pretty cheap. Bit of casting perhaps.- See Also:
- Constant Field Values
-
APPLY
public static final long APPLYJuice for an apply operation Bit of cost to allow for parameter construction. Might need to revisit for bigger sequences?- See Also:
- Constant Field Values
-
HASH
public static final long HASHJuice for a cryptographic hash Expensive.- See Also:
- Constant Field Values
-
CHEAP_OP
public static final long CHEAP_OPJuice for a very cheap operation. O(1), no new cell allocations or non-trivial lookups.- See Also:
- Constant Field Values
-
SIMPLE_FN
public static final long SIMPLE_FNJuice for a simple built-in core function. Simple operations are assumed to require no expensive resource access, and operate with O(1) allocations- See Also:
- Constant Field Values
-
STR
protected static final long STRJuice for constructing a String Fairly cheap, since mostly in fast code, but charge extra for additional chars.- See Also:
- Constant Field Values
-
STR_PER_CHAR
protected static final long STR_PER_CHAR- See Also:
- Constant Field Values
-
STORE
protected static final long STOREJuice for storing a new constant value permanently in on-chain state Charged per node stored- See Also:
- Constant Field Values
-
FETCH
protected static final long FETCH- See Also:
- Constant Field Values
-
ARITHMETIC
protected static final long ARITHMETIC- See Also:
- Constant Field Values
-
ADDRESS
protected static final long ADDRESS- See Also:
- Constant Field Values
-
BALANCE
protected static final long BALANCE- See Also:
- Constant Field Values
-
BLOB
protected static final long BLOBJuice for creation of a blob- See Also:
- Constant Field Values
-
BLOB_PER_BYTE
protected static final long BLOB_PER_BYTE- See Also:
- Constant Field Values
-
GET
protected static final long GET- See Also:
- Constant Field Values
-
KEYWORD
protected static final long KEYWORD- See Also:
- Constant Field Values
-
SYMBOL
protected static final long SYMBOL- See Also:
- Constant Field Values
-
TRANSFER
public static final long TRANSFER- See Also:
- Constant Field Values
-
SIMPLE_MACRO
public static final long SIMPLE_MACRO- See Also:
- Constant Field Values
-
RECUR
public static final long RECURJuice for a recur form Fairly cheap, might have to construct some temp structures for recur arguments.- See Also:
- Constant Field Values
-
DEPLOY_CONTRACT
public static final long DEPLOY_CONTRACTJuice for a contract deployment Make this quite expensive, mainly to deter lots of willy-nilly deploying- See Also:
- Constant Field Values
-
EVAL
protected static final long EVALProbably should be expensive?- See Also:
- Constant Field Values
-
COMPILE_CONSTANT
public static final long COMPILE_CONSTANTJuice cost to compile a Constant value- See Also:
- Constant Field Values
-
COMPILE_LOOKUP
public static final long COMPILE_LOOKUPJuice cost to compile a Constant value- See Also:
- Constant Field Values
-
COMPILE_NODE
public static final long COMPILE_NODEJuice cost to compile a general AST node- See Also:
- Constant Field Values
-
EXPAND_CONSTANT
public static final long EXPAND_CONSTANTJuice cost to expand a constant- See Also:
- Constant Field Values
-
EXPAND_SEQUENCE
public static final long EXPAND_SEQUENCEJuice cost to expand a sequence- See Also:
- Constant Field Values
-
SCHEDULE
public static final long SCHEDULEJuice cost to schedule- See Also:
- Constant Field Values
-
SCHEDULE_MILLIS_PER_JUICE_UNIT
public static final long SCHEDULE_MILLIS_PER_JUICE_UNITDefault future schedule juice (10 per hour) This makes scheduling a few hours / days ahead cheap but year is quite expensive (~87,600). Also places an upper bound on advance schedules. TODO: review this- See Also:
- Constant Field Values
-
RETURN
public static final long RETURNJuice required to execute an exceptional return (return, halt, rollback etc.) Pretty cheap, one alloc and a bit of exceptional value handling.- See Also:
- Constant Field Values
-
ACCEPT
public static final long ACCEPTJuice cost for accepting an offer of Convex coins. We make this a little expensive because it involves updating two separate accounts.- See Also:
- Constant Field Values
-
SYNTAX
public static final long SYNTAXJuice cost for constructing a Syntax Object. Fairly lightweight.- See Also:
- Constant Field Values
-
META
public static final long METAJuice cost for extracting metadata from a Syntax object.- See Also:
- Constant Field Values
-
ASSOC
public static final long ASSOCJuice cost for an 'assoc'- See Also:
- Constant Field Values
-
SET_COMPARE_PER_ELEMENT
public static final long SET_COMPARE_PER_ELEMENTVariable Juice cost for set comparison- See Also:
- Constant Field Values
-
CREATE_ACCOUNT
public static final long CREATE_ACCOUNT- See Also:
- Constant Field Values
-
QUERY
public static final long QUERY- See Also:
- Constant Field Values
-
LOG
public static final long LOG- See Also:
- Constant Field Values
-
SPECIAL
public static final long SPECIAL- See Also:
- Constant Field Values
-
SET_BANG
public static final long SET_BANG- See Also:
- Constant Field Values
-
PEER_UPDATE
public static final long PEER_UPDATEMake this quite expensive. Discourage spamming Peer updates- See Also:
- Constant Field Values
-
-
Constructor Details
-
Juice
public Juice()
-
-
Method Details
-
addMul
public static final long addMul(long a, long b, long c)Saturating multiply and add: result = a + (b * c) Returns Long.MAX_VALUE on overflow.- Parameters:
a
- First number (to be added)b
- Second number (to be multiplied)c
- Thirst number (to be multiplied)- Returns:
- long result, capped at Long.MAX_VALUE
-
mul
public static final long mul(long a, long b)Saturating multiply. Returns Long.MAX_VALUE on overflow.- Parameters:
a
- First numberb
- Second number- Returns:
- long result, capped at Long.MAX_VALUE
-
add
public static final long add(long a, long b)Saturating addition. Returns Long.MAX_VALUE on overflow.- Parameters:
a
- First numberb
- Second number- Returns:
- long result, capped at Long.MAX_VALUE
-