juice

작성자: convex-dev

Juice 회계 — CVM에서의 연산 및 대역폭 비용. 트랜잭션 실행 비용을 추론하거나, :JUICE 실패를 진단하거나, …할 때 사용합니다.

npx skills add https://github.com/convex-dev/convex --skill juice

Juice Accounting

Juice prices computation and bandwidth. It is a flow: consumed and paid per transaction, never held. Storage is priced separately — see the memory skill.

Normative spec: https://docs.convex.world/docs/cad/juice.

The Calculation

Juice Fees     = Juice Consumed × Juice Price
Juice Consumed = Transaction Size Cost + Σ(cost of each operation executed)

Transaction Size Cost = TRANSACTION_PER_BYTE × storage size of the transaction

TRANSACTION_PER_BYTE is 20, so the size of the submitted transaction is itself a cost, independent of what it does. Compact transaction source is cheaper source.

Allowance

Every transaction carries a juice allowance:

  • Specified by the user, or the maximum available if unspecified
  • Capped at 10,000,000, bounding the cost of any single transaction
  • May not exceed what the origin account can actually pay

On a :JUICE failure the origin is charged the full allowance and every state change is rolled back. Running out is not free — it is the most expensive way for a transaction to fail. When execution cost is uncertain, estimate against a local network before submitting.

Price

Juice price lives in the CVM state and is readable from CVM code as *juice-price*. The genesis price is 10 (Constants.INITIAL_JUICE_PRICE, set 2024 and what Protonet runs; CAD007 was aligned to match in #697). A live network's price is whatever its genesis state carries.

CAD007 also specifies dynamic pricing — the price rising under sustained load and decaying towards a hard floor of 1 — but this is not yet implemented: nothing updates *juice-price* after genesis, so treat the price as constant today. Implementation is tracked in #423.

Dynamic pricing is the intended cryptoeconomic defence: sustaining an attack would mean paying exponentially rising prices, so a burst while prices are low could only delay confirmation, not exclude legitimate transactions.

Pricing New Operations

If you add a CVM op or runtime function, it needs a juice cost.

  • Every op MUST have a fixed positive cost — nothing executes free.
  • An op whose work scales with input size MUST have a cost that scales too.
  • The CVM MUST check sufficient juice before performing O(n) work, and raise :JUICE if it is not there.

That ordering is a security property, not an optimisation. If an attacker can trigger O(n) work having committed less than O(n) of juice, the asymmetry is a denial-of-service vector. Cost should track an upper bound on compute time, storage size or bandwidth — whichever dominates.

Relationship to Memory

A transaction short of memory allowance can buy memory from the pool using its remaining juice — so juice exhaustion can surface as a :MEMORY failure and vice versa. See the memory skill for that interaction.

convex-dev의 다른 스킬

account
convex-dev
Convex 계정을 생성하거나 조회합니다. 사용자가 새 계정을 설정하거나, 계정 세부 정보를 확인하거나, 키를 관리하려 할 때 사용하세요.
build-convex
convex-dev
소스에서 Convex 프로젝트를 빌드합니다. 기여자가 Convex를 컴파일, 테스트 또는 패키징하려는 경우 사용합니다.
cad3-encoding
convex-dev
CAD3 인코딩 형식 — 셀, 임베디드 vs 분기 참조, 값 ID, 유효성 규칙. 인코더, 디코더, 직렬화, 해싱 작업 시 사용하거나…
cad-reference
convex-dev
Convex 아키텍처 문서(CAD)의 색인으로, Convex에 대한 규범적 사양입니다. 프로토콜을 변경하기 전에 어떤 CAD가 하위 시스템을 관장하는지 찾는 데 사용하세요.
cns
convex-dev
Convex Name System (CNS) 이름을 조회하거나 등록합니다. 사용자가 CNS 이름을 조회하거나, 새 이름을 등록하거나, 이름의 대상을 업데이트하려는 경우 사용하세요.
convex-db
convex-dev
Convex DB(래티스 기반 SQL 데이터베이스)를 사용하세요. 사용자가 쿼리를 작성하거나, JDBC 또는 PostgreSQL 클라이언트를 통해 연결하거나, 테이블을 생성하거나, 데이터를 삽입/조회할 때 도움이 필요할 때 사용하세요.
convex-lisp
convex-dev
Convex Lisp 언어 참조 — CVM 규칙, 라이브러리 코드 호출, 액터 정의, juice 및 오류 코드. CVM 소스를 작성하거나 디버깅할 때 사용합니다…
deploy
convex-dev
Convex 네트워크에 액터(스마트 컨트랙트)를 배포합니다. 사용자가 내보낸 함수를 가진 새로운 온체인 액터를 생성하려 할 때 사용하세요.