Feature/output indexing#106
Open
mpolitzer wants to merge 8 commits into
Open
Conversation
This reverts commit 20eba47.
8f162a0 to
61a08cd
Compare
023f62a to
b140fa0
Compare
b140fa0 to
97d2a2a
Compare
a1a6354 to
704b787
Compare
This is the first of two commits that restructure the library into
independent modules: rollup, io, abi, buf, and (upcoming) codec.
Rollup module
- Remove `cmt_rollup_advance_t`, `cmt_rollup_inspect_t`, and
`cmt_rollup_finish_t` — `cmt_rollup_advance_t` gets reintroduced in
the codec module (next commit).
- Replace typed emit functions (`emit_voucher`, `emit_delegate_call_voucher`,
`emit_notice`) with a single generic `cmt_rollup_emit_output()` that
takes raw length+data. The ABI envelope encoding is deferred to the
codec layer.
- Simplify `emit_report()` and `emit_exception()` to take `(size_t, const
void*)` instead of `cmt_abi_bytes_t`.
- Collapse `cmt_rollup_finish()` + `cmt_rollup_read_advance_state()` +
`cmt_rollup_read_inspect_state()` into a single blocking call:
`cmt_rollup_wait_for_input(bool accept, cmt_buf_t *out)`.
- Expose internal io and merkle handles via `cmt_rollup_get_io()` and
`cmt_rollup_get_merkle()` accessors.
- Remove `load_merkle()`, `save_merkle()`, and `reset_merkle()` wrappers.
- Drop `fromhost_data` field; buffer sizing is now done at yield time.
IO module
- Rename types for brevity: `cmt_io_driver_t` → `cmt_io_t`,
`cmt_io_driver_ioctl_t` → `cmt_io_ioctl_t`,
`cmt_io_driver_mock_t` → `cmt_io_mock_t`.
- Mock: tighter input-type parsing (sscanf → strtoul with bounds check),
separate error codes for rejected input (-ENOSYS) vs end-of-inputs
(-ENODATA).
ABI module
- Replace `cmt_abi_bytes_t {length, data}` with raw `cmt_buf_t` usage
throughout.
- Rename dynamic-section calls for clarity:
`put_bytes_s/d` → `put_dyn_head/tail`,
`get_bytes_s/d` → `get_dyn_head` / `view_dyn_tail` / `get_dyn_tail`.
- Add `cmt_abi_dyn_state_t` helper struct, `cmt_abi_frame_t` wrapper,
`cmt_abi_reserve_dyn_tail()` / `cmt_abi_commit_dyn_tail()` for
zero-copy dynamic encoding.
- Add `cmt_abi_put_bytesN()` / `cmt_abi_get_bytesN()` for fixed-size
byte arrays (Solidity `bytes<M>`).
- Rename iterator parameters: `me` → `wr`/`rd` throughout.
Buffer module
- `cmt_buf_init()` → `cmt_buf_make()`, returns value instead of using
out-parameter.
- `cmt_buf_split()`: make `lhs` and `rhs` optional (nullable),
change length parameter to unsigned.
- Add `cmt_buf_begin()` convenience accessor.
Merkle module
- Remove `cmt_merkle_reset()`
Debug & utilities
- Hoist the `DBG()` trace macro out of `rollup.c` into the public
`util.h` header as `CMT_DBG()`, so all modules can use it.
Documentation
- Update README and all doc examples to reflect the new API surfaces
(rollup, io, abi, and the upcoming codec module).
704b787 to
7ffb2da
Compare
- EvmAdvance - Notice - CallVoucher - DelegateCallVoucher (removed) - ERC20Transfer - ERC721Transfer - ERC1155SingleTransfer - ERC1155BatchTransfer
7ffb2da to
91dc33e
Compare
91dc33e to
861db43
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes since
main.removal of rollup-http
removal of GIO support
libcmt v2.
updated:
ioctl-echo-loop,rollupandyieldtools.TODO: remove openapi-interfaces
feature/output-indexingChangesBranch:
feature/output-indexing→origin/mainCommits: 8 | Files changed: 78 | +1,934 / −8,478
Removed
rollup-http/— HTTP rollup server, client, echo-dapp, tests (−8,451 lines)The Rust actix-web HTTP server and all associated components:
rollup-http-server/rollup-http-client/echo-dapp/rollup-init/tests/rollup-http-server-tests.rsCI (
main.yml) andDockerfilealso drop rollup-http build/test steps.GIO (Generic I/O) Support (−172 lines)
cmt_gio_request()rollup.h,rollup.ccmt_gio_tstructrollup.hgio_seqmock fieldio-mock.cgio_request()Rust wrappertests/gio.cOld ABI Functions
cmt_abi_put_bytes_s()cmt_abi_put_dyn_head()cmt_abi_put_bytes_d()cmt_abi_put_dyn_tail()cmt_abi_reserve_bytes_d()cmt_abi_reserve_dyn_tail()+cmt_abi_commit_dyn_tail()cmt_abi_get_bytes_s()cmt_abi_get_dyn_head()cmt_abi_get_bytes_d()cmt_abi_view_dyn_tail()/cmt_abi_get_dyn_tail()cmt_abi_bytes_ttypeOld Rollup Functions
cmt_rollup_emit_voucher()cmt_rollup_emit_output()(codec encodes, rollup hashes)cmt_rollup_emit_delegate_call_voucher()cmt_rollup_emit_notice()cmt_rollup_read_advance_state()rxfrom wait_for_inputcmt_rollup_read_inspect_state()rxfrom wait_for_inputcmt_rollup_finish()cmt_rollup_wait_for_input()cmt_rollup_load_merkle()cmt_rollup_get_merkle())cmt_rollup_save_merkle()cmt_rollup_reset_merkle()cmt_merkle_reset()merkle.hOld Types
cmt_rollup_advance_tcmt_evmadvance_args_t(in codec.h)cmt_rollup_inspect_tcmt_buf_t)cmt_rollup_finish_t/cmt_rollup_finish_scmt_rollup_wait_for_input()parameterscmt_io_driver_tcmt_io_tcmt_io_driver_ioctl_tcmt_io_ioctl_tcmt_io_driver_mock_tcmt_io_mock_tioctl-echo-loopCLI Flag--delegate-call-vouchersAdded
Codec Module (
codec.h,codec.c,tests/codec.c) — +494 linesEncoding and decoding for defined output types. Each type gets a struct, encode, and decode function:
cmt_callvoucher_args_t0xbcc29146cmt_notice_args_t0xe5d658c2cmt_evmadvance_args_t0xbf0e3a23cmt_erc1155batchtransfer_args_t0x2f97382ccmt_erc1155singletransfer_args_t0x98b5768ccmt_erc20transfer_args_t0x36dd9fe5cmt_erc721transfer_args_t0xa0470e2bPattern: codec encodes into TX buffer, rollup hashes and emits. Separation of encode (ABI) from proof (merkle).
New ABI API —
dyn_head/dyn_tailpatterncmt_abi_put_dyn_head()cmt_abi_put_dyn_tail()cmt_abi_reserve_dyn_tail()cmt_abi_commit_dyn_tail()cmt_abi_get_dyn_head()cmt_abi_view_dyn_tail()cmt_abi_get_dyn_tail()New types:
cmt_abi_frame_t,cmt_abi_dyn_state_t.New functions for fixed-size bytes:
cmt_abi_put_bytesN(),cmt_abi_get_bytesN().New
util.h— Debug and file helpersCMT_DBG(X)file:line+ errno on failure whenCMT_DEBUG=yescmt_util_debug_enabled()cmt_util_debug()CMT_DBGNew
buf.hFunctionscmt_buf_make()cmt_buf_init())cmt_buf_begin()New
rollup.hAPIcmt_rollup_emit_output()cmt_rollup_get_io()cmt_rollup_get_merkle()cmt_rollup_wait_for_input()cmt_rollup_req_type_tCMT_ROLLUP_REQ_TYPE_ADVANCE(0) /CMT_ROLLUP_REQ_TYPE_INSPECT(1)IO Driver — Yield Constants
New yield reason and reply constants in
io.h.Changed
cmt_io_init()→cmt_io_t(wascmt_io_driver_t)Renamed union:
cmt_io_driver_t→cmt_io_t. All IO accessor functions updated:cmt_io_get_tx(),cmt_io_get_rx(),cmt_io_init(),cmt_io_fini().cmt_rollup_emit_report()/cmt_rollup_emit_exception()— simplified signatureSame for
emit_exception. NULL data = zero-copy mode (emit directly from TX buffer).Merkle Hash Caching
cmt_rollup_wait_for_input()now caches the merkle root hash. Recomputed only whenleaf_countchanges since last call. Controlled viafinish_leaf_countfield initialized toUINT64_C(-1).Mock IO —
CMT_INPUTSenv varRewritten to support new input format:
type:filename,...(e.g.,0:advance.bin,1:inspect.bin).Mock Build Targets
New mock build targets in:
sys-utils/ioctl-echo-loop/Makefilesys-utils/rollup/Makefilesys-utils/yield/MakefileTools Updated
ioctl-echo-loop--vouchers→--call-vouchers; dropped--delegate-call-vouchersrollup.cppcmt_rollup_emit_output()yield.ccmt_io_driver_t→cmt_io_tfunsel.cDoc Examples Updated
All examples in
doc/examples/updated from oldbytes_s/bytes_dAPI to newdyn_head/dyn_tailAPI.abi_decode_002.cadded (multiple dynamic values).pkg-config Template
libcmt.pc.in:@PREFIX@→@ARG_PREFIX@(build system fix).Keccak Endianness
src/keccak.c: fixed endianness in hash computation (__builtin_bswap64(st[i])instead of incorrectly casting the pointer).cmt_rollup_progress()— NULL guard addedReturns
-EINVALwhen called with NULL.Architectural Shift
The rollup API no longer does ABI encoding/decoding — applications use the codec module directly. This gives applications full control over the encoding while keeping the merkle hashing and IO management in the rollup layer.