Cosmic Bull

Realm on pearl-1

duebook_demo

gno.land/r/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/duebook_demo

realmfactory-applicationscheduling

RenderedSourceCall builderState

curated

Persistent-Book host that attacks duebook's exactly-once property from real transactions. Application-factory benchmark #2 — the experiment, not a demo.

Identity

Import pathgno.land/r/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/duebook_demo
Kindrealm (/r/)
Chainpearl-1
Namespaceg1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3
Realm addressg1u0caqzv99d4p6878xwk287edjwdx8exf4whvvc derived, never confirmed against the realm

Provenance

chain-attested
Deployed at height609,644
Deploy transactionbbb5fc50464741a40e1d71bf449c67ccd000c41923b896d7c9bdb748b825af56 look it up on the RPC
Deployerg1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3
Gas used33,097,877
Storage26,462 bytes, deposit 2646200ugnot
Files on chainduebook_demo.gno gnomod.toml
Deployed bytesduebook_demo.gno — 17,382 bytes
sha25657736f0702bb2ee783aa6791a85973c50466cbc5808d307c31af0d6e2f5f0cd9

Do not take the hash above on trust. $download returns the bytes pearl-1 is actually running; this command fetches them and prints their digest, which should equal the one in the table:

curl -sS 'https://pearl.testnets.gno.land/r/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/duebook_demo$download&file=duebook_demo.gno' | shasum -a 256

Expected: 57736f0702bb2ee783aa6791a85973c50466cbc5808d307c31af0d6e2f5f0cd9 — 17,382 bytes. This was checked for all 21 packages while building this site's architecture record; every one matched. Use curl: pearl's edge answers Python's default user-agent with HTTP 403.

API

chain-derived 12 exported functions.

Every function below deep-links to gnoweb's call builder, which generates a ready-to-run gnokey maketx call for it:

CancelDueNowExpirableNowExpireHeightNextIDOpenCountPublishPublishedTotalRenderScheduleStatus

Overview

Package duebook_demo is the reference consumer for the duebook scheduling primitive. It exists to make duebook's central claim falsifiable on a live chain.

That claim is: a deferral claimed in transaction N is refused in transaction N+1, forever. A pure package cannot demonstrate this — a vm/qeval is a single ephemeral evaluation with no state that survives it. Only a realm, called twice, can show it. So this realm is not a decoration on the primitive; it is the experiment.

What it does

Anyone schedules an announcement to be published no earlier than delayBlocks from now. Once due, ANYONE may publish it — publication is deliberately permissionless, so that what protects the announcement from being published twice is duebook's exactly-once Claim and nothing else. If an access-control list were guarding Publish, the experiment would prove nothing about duebook.

The scheduler may cancel at any time before publication. Once the optional time-to-live elapses, the announcement can never be published and anyone may clear it to free a slot.

How it wires duebook correctly

This realm is also the worked example of duebook's consumer contract:

This realm holds no coins and has no admin. Every entrypoint rejects attached coins.

Imports

Constants and variables

const (
	// MinDelayBlocks is the floor on how far ahead an announcement may be
	// scheduled. One block is enough to prove the delay is enforced while
	// keeping the realm exercisable on a live chain.
	MinDelayBlocks = int64(1)

	// MaxDelayBlocks caps scheduling roughly 100 days out at pearl-1's
	// ~3.42s blocks. It also bounds now+delay well inside int64.
	MaxDelayBlocks = int64(2_500_000)

	// MaxTTLBlocks caps how long a due announcement stays publishable.
	MaxTTLBlocks = int64(2_500_000)

	// MaxOpen caps simultaneously scheduled announcements, bounding both
	// storage and the cost of the Due/Expirable scans.
	MaxOpen = 200

	// MaxTextLen bounds one announcement. It is a BYTE length, not a rune
	// count, because its job is to bound storage; a multi-byte script
	// therefore gets fewer than 280 visible characters.
	MaxTextLen = 280

	// MaxPublishedKept is how many recent publications Render shows. The
	// permanent record is the emitted event; this is a bounded window so
	// realm storage cannot grow without limit.
	MaxPublishedKept = 50

	// MaxListed caps how many entries a single query returns.
	MaxListed = 50
)

Functions

Cancel

func Cancel(cur realm, id int64) string

Crossing function. Callable from a transaction via MsgCall, and from another realm as Cancel(cross(cur), ...).

Cancel withdraws a scheduled announcement before it is published. Only the account that scheduled it may cancel, and only while it is still open — a cancellation that arrives after publication aborts.

DueNow

func DueNow() string

DueNow returns the IDs of announcements publishable at the current height, oldest first, capped at MaxListed.

ExpirableNow

func ExpirableNow() string

ExpirableNow returns the IDs that Expire would accept at the current height, oldest first, capped at MaxListed.

Expire

func Expire(cur realm, id int64) string

Crossing function. Callable from a transaction via MsgCall, and from another realm as Expire(cross(cur), ...).

Expire clears an announcement whose time-to-live has elapsed, freeing its slot against MaxOpen. It is permissionless because an expired announcement can never be published, so there is nothing left to protect and everything to gain from letting anyone tidy up.

Height

func Height() int64

Height returns the chain height this realm is reading as "now".

NextID

func NextID() string

NextID returns the deferral ID the next Schedule will allocate. It only ever increases; that is what makes a consumed ID permanently unusable.

OpenCount

func OpenCount() int

OpenCount returns how many announcements are currently scheduled.

Publish

func Publish(cur realm, id int64) string

Crossing function. Callable from a transaction via MsgCall, and from another realm as Publish(cross(cur), ...).

Publish publishes a scheduled announcement once it is due. It is deliberately permissionless: duebook's exactly-once Claim is the only thing preventing a second publication, which is precisely what this realm exists to demonstrate.

Aborts if the announcement does not exist, is not due yet, has expired, or has already been consumed by a publication or a cancellation.

PublishedTotal

func PublishedTotal() int64

PublishedTotal returns how many announcements have ever been published, including ones since evicted from the rendered window.

Render

func Render(path string) string

Render serves three views, selected by path. Anyone may Schedule, so the default view must not be something a stranger can inflate: it shows only what is publishable right now, capped at MaxListed. The full scheduled table lives behind :open and is capped too, so no view is unbounded and none of them is the landing page by default.

(empty) summary + publishable now + recent publications open every scheduled announcement, up to MaxListed rows about what this realm is and why it exists

Schedule

func Schedule(cur realm, text string, delayBlocks, ttlBlocks int64) string

Crossing function. Callable from a transaction via MsgCall, and from another realm as Schedule(cross(cur), ...).

Schedule registers an announcement to be published no earlier than delayBlocks from the current height, and returns its deferral ID.

ttlBlocks is how long after the due height the announcement stays publishable; 0 means it never expires. The caller becomes the owner and is the only account that may Cancel it.

Status

func Status(id int64) string

Status describes a scheduled announcement: its window, and whether it is publishable right now. Returns "unknown" when the ID was never issued or has already been consumed — duebook keeps no tombstone, so those two cases are indistinguishable by design.


Doc text is reproduced as vm/qdoc returns it. The node markdown-escapes doc comments, so a bracket or angle bracket may carry a backslash the committed source does not have. The source itself is at source and in this repository.

Dependencies

chain-attested
Importschain, chain/runtime, chain/runtime/unsafe, gno.land/p/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/duebook, gno.land/p/nt/avl/v0, gno.land/p/nt/markdown/sanitize/v0, strconv
First-party dependenciesgno.land/p/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/duebook
Used bynone

Known limitations

curated

The manifest records no limitation for this package. That is an absence of a recorded caveat, not a proof that none exists — the deployment record below is the fuller account, and it always carries its own "what was NOT verified live" section.

Source and records

Source filepearl/r/duebook_demo/duebook_demo.gno at commit 6a510c665a53 in the project repository (not public — the digest command above is the check that needs no repository)
Matches the deployed bytesyes — byte-identical
Recordscatalog/primitives.md#application-factory-realms
pearl/DEPLOYMENT.md