sector 03 / workbench

Workbench

Write the program, prove it on the emulator, lower it the way the chain will, and measure its real gas against the holder. Only then spend gas on the two transactions.

3.1The task

Reading the chain…

The program finds 512 input bytes at 0xE000 and must leave a 32-byte answer at 0xF000, then execute ecall. RAM is 64 KiB and wraps; the image (code, then .data) is loaded at address 0.

3.2Source

Grammar: one instruction per line, label: on its own line, # comments, li and la (always two words), j, .data then .word lists. Registers by ABI name. The full RV32IM set, plus ecall to finish.

3.3Assembly

Not assembled yet.

3.4Reference emulator

The emulator runs the image on a fresh random input built exactly as Dominion.inputOf(seed) builds it, and checks the answer against the hash computed here in JavaScript.

Not run yet.

3.5Lowering

The browser translator emits the same bytes as Lowering on chain. When the contracts are live, the page also asks Lowering.lowerImage and compares.

Not lowered yet.

3.6Measured gas

One eth_call to Dominion.score(address, seed) with a state override that places your lowered runtime at a scratch address. That is the same measurement the race makes, on the current era's task, without deploying anything. The holder is scored on the same seed.

Not measured yet.

3.7Enter the race

Two transactions from the same wallet. commit(id) fixes the program without showing it. Then, at least 2 and at most 250 blocks later, enter(image, codeLen, salt) lowers it and races the holder head to head on an input seeded by the block hash after your commit. A loss reverts and moves nothing.

The id is keccak256(abi.encode(author, keccak256(image), codeLen, salt)). The salt is generated here and kept in this browser's storage with the exact image you committed. Write the salt down or keep this browser: without it the commit cannot be entered. Between the commit and the entry you can already back your own id with a buy (sector 04), before anyone has seen the code.

Saved commits in this browser