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.

Skills เพิ่มเติมจาก convex-dev

account
convex-dev
สร้างหรือตรวจสอบบัญชี Convex ใช้เมื่อผู้ใช้ต้องการตั้งค่าบัญชีใหม่ ตรวจสอบรายละเอียดบัญชี หรือจัดการคีย์
build-convex
convex-dev
สร้างโปรเจกต์ Convex จากซอร์สโค้ด ใช้เมื่อผู้มีส่วนร่วมต้องการคอมไพล์ ทดสอบ หรือแพ็กเกจ Convex
cad3-encoding
convex-dev
รูปแบบการเข้ารหัส CAD3 — เซลล์, การอ้างอิงแบบฝังเทียบกับแบบสาขา, รหัสค่า, กฎความถูกต้อง ใช้เมื่อทำงานกับตัวเข้ารหัส, ตัวถอดรหัส, การทำให้เป็นอนุกรม, การแฮช หรือ…
cad-reference
convex-dev
ดัชนีของเอกสารสถาปัตยกรรม Convex (CADs) ซึ่งเป็นข้อกำหนดมาตรฐานของ 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
ปรับใช้ actor (สัญญาอัจฉริยะ) ไปยังเครือข่าย Convex ใช้เมื่อผู้ใช้ต้องการสร้าง actor บนเชนใหม่ที่มีฟังก์ชันที่ส่งออก