Skip to content

Commit

Permalink
Comments and docs on juice usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Jan 2, 2024
1 parent 0c585b7 commit 3d217e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion convex-core/src/main/java/convex/core/lang/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public static Context createInitial(State state, Address origin,long juiceLimit)
* <li>Accumulates used juice fees in globals</li>
* <li>Increments sequence number</li>
* </ul>
* @param t
*
* @param initialState State before transaction execution (after prepare)
* @param juicePrice Juice price of current execution
Expand All @@ -320,10 +321,11 @@ public Context completeTransaction(State initialState, long juicePrice) {
State state=getState();
long executionJuice=this.juice;

// TODO: Extra juice for transaction size??
// Base fixed juice cost per transaction
long trxJuice=Juice.TRANSACTION;

long totalJuice=executionJuice+trxJuice;

long juiceFees=Juice.addMul(0,totalJuice,juicePrice);

// compute memory delta
Expand Down
11 changes: 8 additions & 3 deletions convex-core/src/main/java/convex/core/lang/Juice.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ public class Juice {
*/
public static final long TRANSACTION = 500L;

/**
* UNDER CONSIDERATION, PROBABLY WON'T BE NEEDED
* Juice cost per byte of transaction size executed, added to consumed juice
*/
// public static final long TX_PER_BYTE = 5L;


/**
* Base Juice cost for any sub transaction executed, added to consumed juice
*/
public static final long SUB_TRANSACTION = 50L;
public static final long SUB_TRANSACTION = 100L;

/**
* Juice required to resolve a constant value
Expand Down Expand Up @@ -502,6 +509,4 @@ public static long calcAvailable(long balance, long juicePrice) {
}




}

0 comments on commit 3d217e3

Please sign in to comment.