diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b42d277f..8a5acb78 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,6 +59,7 @@ jobs: push: false load: true build-args: | + CMT_TAR_GZ=${{ env.CMT_TAR_GZ }} TOOLS_DEB=${{ env.TOOLS_DEB }} IMAGE_KERNEL_VERSION=${{ env.IMAGE_KERNEL_VERSION }} LINUX_VERSION=${{ env.LINUX_VERSION }} @@ -87,6 +88,7 @@ jobs: run: | sha512sum ${{ env.TOOLS_DEB }} > ${{ env.TOOLS_DEB }}.sha512 sha512sum ${{ env.TOOLS_ROOTFS }} > ${{ env.TOOLS_ROOTFS }}.sha512 + sha512sum ${{ env.CMT_TAR_GZ }} > ${{ env.CMT_TAR_GZ }}.sha512 - uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') @@ -97,6 +99,8 @@ jobs: ${{ env.TOOLS_DEB }}.sha512 ${{ env.TOOLS_ROOTFS }} ${{ env.TOOLS_ROOTFS }}.sha512 + ${{ env.CMT_TAR_GZ }} + ${{ env.CMT_TAR_GZ }}.sha512 test-rollup-http-server: runs-on: ubuntu-22.04 diff --git a/CHANGELOG.md b/CHANGELOG.md index 52817753..e618f278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Added a value field to vouchers +- Tools are now implemented in terms of libcmt +- Added libcmt ## [0.14.1] - 2023-12-18 ### Fixed diff --git a/Dockerfile b/Dockerfile index 96fbc75a..e74753b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,22 +31,34 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ ca-certificates \ git \ wget \ + pkg-config \ crossbuild-essential-riscv64 \ gcc-12-riscv64-linux-gnu \ g++-12-riscv64-linux-gnu \ && \ wget -O ${LINUX_HEADERS_FILEPATH} ${LINUX_HEADERS_URLPATH} && \ - echo "efdb2243d9b6828e90c826be0f178110f0cc590cb00e8fa588cb20723126c2a4 ${LINUX_HEADERS_FILEPATH}" | sha256sum --check && \ + echo "4ef81562b1d85220bde9fd4ff01d149469a500f22cc319a02c32bfd1c0698ae1 ${LINUX_HEADERS_FILEPATH}" | sha256sum --check && \ apt-get install -y --no-install-recommends ${LINUX_HEADERS_FILEPATH} && \ adduser developer -u 499 --gecos ",,," --disabled-password && \ mkdir -p ${BUILD_BASE}/tools && chown -R developer:developer ${BUILD_BASE}/tools && \ rm -rf /var/lib/apt/lists/* ${LINUX_HEADERS_FILEPATH} +# Setup latest cross compiler as default +# ------------------------------------------------------------------------------ +RUN < src/main.rs && \ - echo "pub fn dummy() {}" > src/lib.rs && \ - cargo build --target riscv64gc-unknown-linux-gnu --release - -# build rollup-http-server -FROM http-server-dep-builder as http-server-builder -COPY --chown=developer:developer rollup-http/rollup-http-server/build.rs ${BUILD_BASE}/tools/rollup-http/rollup-http-server/ -COPY --chown=developer:developer rollup-http/rollup-http-server/src ${BUILD_BASE}/tools/rollup-http/rollup-http-server/src -RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && touch build.rs src/* && \ - cargo build --target riscv64gc-unknown-linux-gnu --release - -# build echo-dapp dependencies -FROM rust-builder as echo-dapp-dep-builder -COPY --chown=developer:developer rollup-http/echo-dapp/Cargo.toml rollup-http/echo-dapp/Cargo.lock ${BUILD_BASE}/tools/rollup-http/echo-dapp/ -RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && \ - mkdir src/ && echo "fn main() {}" > src/main.rs && \ - cargo build --target riscv64gc-unknown-linux-gnu --release - -# build echo-dapp -FROM echo-dapp-dep-builder as echo-dapp-builder -COPY --chown=developer:developer rollup-http/echo-dapp/src ${BUILD_BASE}/tools/rollup-http/echo-dapp/src -RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \ - cargo build --target riscv64gc-unknown-linux-gnu --release +## build rust tools +## ------------------------------------------------------------------------------ +#FROM tools-env as rust-env +#ENV PATH="/home/developer/.cargo/bin:${PATH}" +# +#USER developer +# +#RUN cd && \ +# wget https://github.com/rust-lang/rustup/archive/refs/tags/1.26.0.tar.gz && \ +# echo "6f20ff98f2f1dbde6886f8d133fe0d7aed24bc76c670ea1fca18eb33baadd808 1.26.0.tar.gz" | sha256sum --check && \ +# tar -xzf 1.26.0.tar.gz && \ +# bash rustup-1.26.0/rustup-init.sh \ +# -y \ +# --default-toolchain 1.74.0 \ +# --profile minimal \ +# --target riscv64gc-unknown-linux-gnu && \ +# rm -rf rustup-1.26.0 1.26.0.tar.gz +# +#FROM rust-env as rust-builder +#COPY --chown=developer:developer rollup-http/rollup-init ${BUILD_BASE}/tools/rollup-http/rollup-init +#COPY --chown=developer:developer rollup-http/rollup-http-client ${BUILD_BASE}/tools/rollup-http/rollup-http-client +#COPY --chown=developer:developer rollup-http/.cargo ${BUILD_BASE}/tools/rollup-http/.cargo +# +## build rollup-http-server dependencies +#FROM rust-builder as http-server-dep-builder +#COPY --chown=developer:developer rollup-http/rollup-http-server/Cargo.toml rollup-http/rollup-http-server/Cargo.lock ${BUILD_BASE}/tools/rollup-http/rollup-http-server/ +#RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && \ +# mkdir src/ && \ +# echo "fn main() {}" > src/main.rs && \ +# echo "pub fn dummy() {}" > src/lib.rs && \ +# cargo build --target riscv64gc-unknown-linux-gnu --release +# +## build rollup-http-server +#FROM http-server-dep-builder as http-server-builder +#COPY --chown=developer:developer rollup-http/rollup-http-server/build.rs ${BUILD_BASE}/tools/rollup-http/rollup-http-server/ +#COPY --chown=developer:developer rollup-http/rollup-http-server/src ${BUILD_BASE}/tools/rollup-http/rollup-http-server/src +#RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && touch build.rs src/* && \ +# cargo build --target riscv64gc-unknown-linux-gnu --release +# +## build echo-dapp dependencies +#FROM rust-builder as echo-dapp-dep-builder +#COPY --chown=developer:developer rollup-http/echo-dapp/Cargo.toml rollup-http/echo-dapp/Cargo.lock ${BUILD_BASE}/tools/rollup-http/echo-dapp/ +#RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && \ +# mkdir src/ && echo "fn main() {}" > src/main.rs && \ +# cargo build --target riscv64gc-unknown-linux-gnu --release +# +## build echo-dapp +#FROM echo-dapp-dep-builder as echo-dapp-builder +#COPY --chown=developer:developer rollup-http/echo-dapp/src ${BUILD_BASE}/tools/rollup-http/echo-dapp/src +#RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \ +# cargo build --target riscv64gc-unknown-linux-gnu --release # pack tools (deb) # ------------------------------------------------------------------------------ @@ -117,6 +141,7 @@ ARG STAGING_BASE=${BUILD_BASE}/_install ARG STAGING_DEBIAN=${STAGING_BASE}/DEBIAN ARG STAGING_SBIN=${STAGING_BASE}/usr/sbin ARG STAGING_BIN=${STAGING_BASE}/usr/bin +ARG CMT_TAR_GZ=libcmt-v0.14.1-dev.tar.gz RUN mkdir -p ${STAGING_DEBIAN} ${STAGING_SBIN} ${STAGING_BIN} ${STAGING_BASE}/etc && \ echo "cartesi-machine" > ${staging_base}/etc/hostname @@ -125,12 +150,13 @@ COPY control ${STAGING_DEBIAN}/control COPY --from=builder ${BUILD_BASE}/tools/sys-utils/cartesi-init/cartesi-init ${STAGING_SBIN} COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/xhalt/xhalt ${STAGING_SBIN} -COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/yield/yield ${STAGING_SBIN} COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/rollup/rollup ${STAGING_SBIN} COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/ioctl-echo-loop/ioctl-echo-loop ${STAGING_BIN} +COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/yield/yield ${STAGING_SBIN} COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/misc/* ${STAGING_BIN} -COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_SBIN} -COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN} -COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN} +#COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_SBIN} +#COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN} +#COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN} RUN dpkg-deb -Zxz --root-owner-group --build ${STAGING_BASE} ${BUILD_BASE}/${TOOLS_DEB} +COPY --from=c-builder ${BUILD_BASE}/${CMT_TAR_GZ} ${BUILD_BASE}/${CMT_TAR_GZ} diff --git a/Makefile b/Makefile index 7b1ea40c..f188b569 100644 --- a/Makefile +++ b/Makefile @@ -17,14 +17,15 @@ MAJOR := 0 MINOR := 14 PATCH := 1 -LABEL := +LABEL :=-dev VERSION := $(MAJOR).$(MINOR).$(PATCH)$(LABEL) TOOLS_DEB := machine-emulator-tools-v$(VERSION).deb TOOLS_IMAGE := cartesi/machine-emulator-tools:$(VERSION) TOOLS_ROOTFS := rootfs-tools-v$(VERSION).ext2 +CMT_TAR_GZ := libcmt-$(VERSION).tar.gz -IMAGE_KERNEL_VERSION ?= v0.19.1 +IMAGE_KERNEL_VERSION ?= v0.20.0-output-unification-rc1 LINUX_VERSION ?= 6.5.9-ctsi-1 LINUX_HEADERS_URLPATH := https://github.com/cartesi/image-kernel/releases/download/${IMAGE_KERNEL_VERSION}/linux-libc-dev-riscv64-cross-${LINUX_VERSION}-${IMAGE_KERNEL_VERSION}.deb @@ -33,6 +34,7 @@ all: fs build: control @docker buildx build --load \ --build-arg TOOLS_DEB=$(TOOLS_DEB) \ + --build-arg CMT_TAR_GZ=$(CMT_TAR_GZ) \ --build-arg IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION) \ --build-arg LINUX_VERSION=$(LINUX_VERSION) \ --build-arg LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH) \ @@ -44,6 +46,7 @@ build: control copy: @ID=`docker create $(TOOLS_IMAGE)` && \ docker cp $$ID:/opt/cartesi/$(TOOLS_DEB) . && \ + docker cp $$ID:/opt/cartesi/$(CMT_TAR_GZ) . && \ docker rm $$ID $(TOOLS_DEB) deb: build @@ -63,6 +66,7 @@ $(TOOLS_ROOTFS) fs: $(TOOLS_DEB) rm -f rootfs.gnutar rootfs.tar env: + @echo CMT_TAR_GZ=$(CMT_TAR_GZ) @echo TOOLS_DEB=$(TOOLS_DEB) @echo TOOLS_ROOTFS=$(TOOLS_ROOTFS) @echo TOOLS_IMAGE=$(TOOLS_IMAGE) diff --git a/fs/Dockerfile b/fs/Dockerfile index b5e8f5d4..2e34e0d2 100644 --- a/fs/Dockerfile +++ b/fs/Dockerfile @@ -30,7 +30,7 @@ RUN mkdir benchmarks && cd benchmarks && \ # Final image FROM --platform=linux/riscv64 riscv64/ubuntu:22.04 -ARG TOOLS_DEB=machine-emulator-tools-v0.14.0.deb +ARG TOOLS_DEB=machine-emulator-tools-v0.14.1-dev.deb ADD ${TOOLS_DEB} /tmp/ RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/rollup-http/rollup-http-client/src/rollup.rs b/rollup-http/rollup-http-client/src/rollup.rs index eeef5659..da7fe2fc 100644 --- a/rollup-http/rollup-http-client/src/rollup.rs +++ b/rollup-http/rollup-http-client/src/rollup.rs @@ -51,6 +51,7 @@ pub struct Notice { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Voucher { pub destination: String, + pub data: String, pub payload: String, } diff --git a/rollup-http/rollup-http-server/Cargo.toml b/rollup-http/rollup-http-server/Cargo.toml index f0c53827..ab56d152 100644 --- a/rollup-http/rollup-http-server/Cargo.toml +++ b/rollup-http/rollup-http-server/Cargo.toml @@ -36,7 +36,7 @@ tonic-build = "0.5" [dev-dependencies] rollup-http-client = {path = "../rollup-http-client"} - +rand = "0.8.5" [profile.release] diff --git a/rollup-http/rollup-http-server/build.rs b/rollup-http/rollup-http-server/build.rs index 37a540fb..c40a14fe 100644 --- a/rollup-http/rollup-http-server/build.rs +++ b/rollup-http/rollup-http-server/build.rs @@ -17,17 +17,5 @@ extern crate cc; fn main() { - println!("cargo:rerun-if-changed=src/rollup/bindings.c,src/rollup/bindings.h,tests/rollup_test_bindings.c,tests/rollup_test.h"); - let test = std::env::var("USE_ROLLUP_BINDINGS_MOCK").unwrap_or("0".to_string()); - if test == "1" { - cc::Build::new() - .file("tests/rollup_test_bindings.c") - .compile("libtest_bindings.a"); - println!("cargo:rustc-link-lib=test_bindings"); - } else { - cc::Build::new() - .file("src/rollup/bindings.c") - .compile("libbindings.a"); - println!("cargo:rustc-link-lib=bindings"); - } + println!("cargo:rustc-link-lib=cmt"); } diff --git a/rollup-http/rollup-http-server/src/dapp_process.rs b/rollup-http/rollup-http-server/src/dapp_process.rs index 931fce51..8efecd37 100644 --- a/rollup-http/rollup-http-server/src/dapp_process.rs +++ b/rollup-http/rollup-http-server/src/dapp_process.rs @@ -20,10 +20,10 @@ use std::sync::Arc; use async_mutex::Mutex; use tokio::process::Command; -use crate::rollup::{self, Exception}; +use crate::rollup::{self, Exception, RollupFd}; /// Execute the dapp command and throw a rollup exception if it fails or exits -pub async fn run(args: Vec, rollup_fd: Arc>) { +pub async fn run(args: Vec, rollup_fd: Arc>) { log::info!("starting dapp: {}", args.join(" ")); let task = tokio::task::spawn_blocking(move || Command::new(&args[0]).args(&args[1..]).spawn()); let message = match task.await { @@ -40,7 +40,7 @@ pub async fn run(args: Vec, rollup_fd: Arc>) { let exception = Exception { payload: String::from("0x") + &hex::encode(message), }; - match rollup::rollup_throw_exception(*rollup_fd.lock().await, &exception) { + match rollup::rollup_throw_exception(&*rollup_fd.lock().await, &exception) { Ok(_) => { log::debug!("exception successfully thrown {:#?}", exception); } diff --git a/rollup-http/rollup-http-server/src/http_service.rs b/rollup-http/rollup-http-server/src/http_service.rs index c650d68a..ee30a6ad 100644 --- a/rollup-http/rollup-http-server/src/http_service.rs +++ b/rollup-http/rollup-http-server/src/http_service.rs @@ -14,7 +14,6 @@ // limitations under the License. // -use std::os::unix::io::RawFd; use std::sync::Arc; use actix_web::{middleware::Logger, web::Data, web::Json, App, HttpResponse, HttpServer}; @@ -23,7 +22,7 @@ use serde::{Deserialize, Serialize}; use tokio::sync::Notify; use crate::config::Config; -use crate::rollup; +use crate::rollup::{self, RollupFd}; use crate::rollup::{ AdvanceRequest, Exception, InspectRequest, Notice, Report, RollupRequest, Voucher, }; @@ -40,7 +39,7 @@ enum RollupHttpRequest { /// Create new instance of http server pub fn create_server( config: &Config, - rollup_fd: Arc>, + rollup_fd: Arc>, ) -> std::io::Result { let server = HttpServer::new(move || { let data = Data::new(Mutex::new(Context { @@ -64,7 +63,7 @@ pub fn create_server( /// Create and run new instance of http server pub async fn run( config: &Config, - rollup_fd: Arc>, + rollup_fd: Arc>, server_ready: Arc, ) -> std::io::Result<()> { log::info!("starting http dispatcher http service!"); @@ -90,7 +89,7 @@ async fn voucher(mut voucher: Json, data: Data>) -> Http } let context = data.lock().await; // Write voucher to linux rollup device - return match rollup::rollup_write_voucher(*context.rollup_fd.lock().await, &mut voucher.0) { + return match rollup::rollup_write_voucher(&*context.rollup_fd.lock().await, &mut voucher.0) { Ok(voucher_index) => { log::debug!("voucher successfully inserted {:#?}", voucher); HttpResponse::Created().json(IndexResponse { @@ -114,7 +113,7 @@ async fn notice(mut notice: Json, data: Data>) -> HttpRes log::debug!("received notice request"); let context = data.lock().await; // Write notice to linux rollup device - return match rollup::rollup_write_notice(*context.rollup_fd.lock().await, &mut notice.0) { + return match rollup::rollup_write_notice(&*context.rollup_fd.lock().await, &mut notice.0) { Ok(notice_index) => { log::debug!("notice successfully inserted {:#?}", notice); HttpResponse::Created().json(IndexResponse { @@ -135,7 +134,7 @@ async fn report(report: Json, data: Data>) -> HttpRespons log::debug!("received report request"); let context = data.lock().await; // Write report to linux rollup device - return match rollup::rollup_write_report(*context.rollup_fd.lock().await, &report.0) { + return match rollup::rollup_write_report(&*context.rollup_fd.lock().await, &report.0) { Ok(_) => { log::debug!("report successfully inserted {:#?}", report); HttpResponse::Accepted().body("") @@ -157,7 +156,7 @@ async fn exception(exception: Json, data: Data>) -> Ht let context = data.lock().await; // Throw an exception - return match rollup::rollup_throw_exception(*context.rollup_fd.lock().await, &exception.0) { + return match rollup::rollup_throw_exception(&*context.rollup_fd.lock().await, &exception.0) { Ok(_) => { log::debug!("exception successfully thrown {:#?}", exception); HttpResponse::Accepted().body("") @@ -190,7 +189,7 @@ async fn finish(finish: Json, data: Data>) -> Http let context = data.lock().await; let rollup_fd = context.rollup_fd.lock().await; // Write finish request, read indicator for next request - let new_rollup_request = match rollup::perform_rollup_finish_request(*rollup_fd, accept).await { + let new_rollup_request = match rollup::perform_rollup_finish_request(&*rollup_fd).await { Ok(finish_request) => { // Received new request, process it log::info!( @@ -201,7 +200,7 @@ async fn finish(finish: Json, data: Data>) -> Http _ => "UNKNOWN", } ); - match rollup::handle_rollup_requests(*rollup_fd, finish_request).await { + match rollup::handle_rollup_requests(&*rollup_fd, finish_request).await { Ok(rollup_request) => rollup_request, Err(e) => { let error_message = format!( @@ -260,5 +259,5 @@ struct Error { } struct Context { - pub rollup_fd: Arc>, + pub rollup_fd: Arc>, } diff --git a/rollup-http/rollup-http-server/src/main.rs b/rollup-http/rollup-http-server/src/main.rs index c38bacea..cca29199 100644 --- a/rollup-http/rollup-http-server/src/main.rs +++ b/rollup-http/rollup-http-server/src/main.rs @@ -14,15 +14,12 @@ // limitations under the License. // -use std::fs::File; use std::io::ErrorKind; -#[cfg(unix)] -use std::os::unix::io::{IntoRawFd, RawFd}; use std::sync::Arc; use async_mutex::Mutex; use getopts::{Options, ParsingStyle}; -use rollup_http_server::{config::Config, dapp_process, http_service, rollup}; +use rollup_http_server::{config::Config, dapp_process, http_service, rollup::RollupFd}; use tokio::sync::Notify; fn print_usage(program: &str, opts: Options) { @@ -100,16 +97,7 @@ async fn main() -> std::io::Result<()> { .unwrap(); } - // Open rollup device - let rollup_file = match File::open(rollup::ROLLUP_DEVICE_NAME) { - Ok(file) => file, - Err(e) => { - log::error!("error opening rollup device {}", e.to_string()); - return Err(e); - } - }; - - let rollup_fd: Arc> = Arc::new(Mutex::new(rollup_file.into_raw_fd())); + let rollup_fd: Arc> = Arc::new(Mutex::new(RollupFd::create().unwrap())); let server_ready = Arc::new(Notify::new()); // In another thread, wait until the server is ready and then start the dapp diff --git a/rollup-http/rollup-http-server/src/rollup/bindings.c b/rollup-http/rollup-http-server/src/rollup/bindings.c deleted file mode 100644 index 86628c41..00000000 --- a/rollup-http/rollup-http-server/src/rollup/bindings.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright Cartesi and individual authors (see AUTHORS) - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bindings.h" -#include - -static int resize_bytes(struct rollup_bytes *bytes, uint64_t size) { - if (bytes->length < size) { - uint8_t *new_data = (uint8_t *) realloc(bytes->data, size); - if (!new_data) { - return -1; - } - bytes->length = size; - bytes->data = new_data; - } - return 0; -} - -/* Finishes processing of current advance or inspect. - * Returns 0 on success, -1 on error */ -int rollup_finish_request(int fd, struct rollup_finish *finish, bool accept) { - int res = 0; - memset(finish, 0, sizeof(*finish)); - finish->accept_previous_request = accept; - res = ioctl(fd, IOCTL_ROLLUP_FINISH, (unsigned long) finish); - return res; -} - -/* Obtains arguments to advance state - * Outputs metadata and payload in structs - * Returns 0 on success, -1 on error */ -int rollup_read_advance_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *bytes, - struct rollup_input_metadata *metadata) { - struct rollup_advance_state req; - int res = 0; - if (resize_bytes(bytes, finish->next_request_payload_length) != 0) { - fprintf(stderr, "Failed growing payload buffer\n"); - return -1; - } - memset(&req, 0, sizeof(req)); - req.payload = *bytes; - res = ioctl(fd, IOCTL_ROLLUP_READ_ADVANCE_STATE, (unsigned long) &req); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_READ_ADVANCE_STATE returned error (%d), err message: %s\n", res, strerror(errno)); - } - *metadata = req.metadata; - return res; -} - -/* Obtains query of inspect state request - * Returns 0 on success, -1 on error */ -int rollup_read_inspect_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *query) { - struct rollup_inspect_state req; - int res = 0; - if (resize_bytes(query, finish->next_request_payload_length) != 0) { - fprintf(stderr, "Failed growing payload buffer\n"); - return -1; - } - memset(&req, 0, sizeof(req)); - req.payload = *query; - res = ioctl(fd, IOCTL_ROLLUP_READ_INSPECT_STATE, (unsigned long) &req); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_READ_INSPECT_STATE returned error (%d), err message: %s\n", res, strerror(errno)); - return res; - } - return 0; -} - -/* Outputs a new voucher. - * voucher_index is filled with new index from the driver - * Returns 0 on success, -1 on error */ -int rollup_write_voucher(int fd, uint8_t destination[CARTESI_ROLLUP_ADDRESS_SIZE], struct rollup_bytes *bytes, - uint64_t *voucher_index) { - struct rollup_voucher v; - memset(&v, 0, sizeof(v)); - memcpy(v.destination, destination, CARTESI_ROLLUP_ADDRESS_SIZE); - v.payload = *bytes; - int res = ioctl(fd, IOCTL_ROLLUP_WRITE_VOUCHER, (unsigned long) &v); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_WRITE_VOUCHER returned error %d, err message: %s\n", res, strerror(errno)); - return res; - } - *voucher_index = v.index; - return 0; -} - -/* Outputs a new notice. - * notice_index is filled with new index from the driver - * Returns 0 on success, -1 on error */ -int rollup_write_notice(int fd, struct rollup_bytes *bytes, uint64_t *notice_index) { - struct rollup_notice n; - memset(&n, 0, sizeof(n)); - n.payload = *bytes; - int res = ioctl(fd, IOCTL_ROLLUP_WRITE_NOTICE, (unsigned long) &n); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_WRITE_NOTICE returned error %d, err message: %s\n", res, strerror(errno)); - return res; - } - *notice_index = n.index; - return 0; -} - -/* Outputs a new report. - * Returns 0 on success, -1 on error */ -int rollup_write_report(int fd, struct rollup_bytes *bytes) { - struct rollup_report r; - memset(&r, 0, sizeof(r)); - r.payload = *bytes; - int res = ioctl(fd, IOCTL_ROLLUP_WRITE_REPORT, (unsigned long) &r); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_WRITE_REPORT returned error %d, err message: %s\n", res, strerror(errno)); - return res; - } - - return 0; -} - -/* Outputs a dapp exception. - * Returns 0 on success, -1 on error */ -int rollup_throw_exception(int fd, struct rollup_bytes *bytes) { - struct rollup_exception e; - memset(&e, 0, sizeof(e)); - e.payload = *bytes; - int res = ioctl(fd, IOCTL_ROLLUP_THROW_EXCEPTION, (unsigned long) &e); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_THROW_EXCEPTION returned error %d, err message: %s\n", res, strerror(errno)); - return res; - } - return 0; -} diff --git a/rollup-http/rollup-http-server/src/rollup/bindings.h b/rollup-http/rollup-http-server/src/rollup/bindings.h deleted file mode 100644 index 766a14b0..00000000 --- a/rollup-http/rollup-http-server/src/rollup/bindings.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright Cartesi and individual authors (see AUTHORS) - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* C interfaces that are converted to rust using bindgen (https://github.com/rust-lang/rust-bindgen) - * command to generate Rust file from rollup C interface. In case that C rollup bindings are updated, - * `bindings.rs` file needs to be regenerated using following procedure: - * Add toolchain `riscv64-cartesi-linux-gnu` to the shell execution path - * $ cd linux/rollup/http/http-dispatcher/src/rollup - * $ bindgen ./bindings.h -o ./bindings.rs --whitelist-var '^IOCTL.*' --whitelist-var '^CARTESI.*' --whitelist-type - "^rollup_.*" --whitelist-function '^rollup.*'\ - -- --sysroot=/opt/riscv/riscv64-cartesi-linux-gnu/riscv64-cartesi-linux-gnu/sysroot - --target=riscv64-cartesi-linux-gnu -march=rv64gc -mabi=lp64d -*/ - -#include -#include -#include -#include -#include -#include - -#include -#include - -int rollup_finish_request(int fd, struct rollup_finish *finish, bool accept); -int rollup_read_advance_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *bytes, - struct rollup_input_metadata *metadata); -int rollup_read_inspect_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *query); -int rollup_write_voucher(int fd, uint8_t destination[CARTESI_ROLLUP_ADDRESS_SIZE], struct rollup_bytes *bytes, - uint64_t *voucher_index); -int rollup_write_notice(int fd, struct rollup_bytes *bytes, uint64_t *notice_index); -int rollup_write_report(int fd, struct rollup_bytes *bytes); -int rollup_throw_exception(int fd, struct rollup_bytes *bytes); diff --git a/rollup-http/rollup-http-server/src/rollup/bindings.rs b/rollup-http/rollup-http-server/src/rollup/bindings.rs index ff4cf8d4..6001a089 100644 --- a/rollup-http/rollup-http-server/src/rollup/bindings.rs +++ b/rollup-http/rollup-http-server/src/rollup/bindings.rs @@ -1,414 +1,1356 @@ -/* automatically generated by rust-bindgen 0.58.1 */ -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] +/* automatically generated by rust-bindgen 0.69.2 */ -pub const CARTESI_ROLLUP_ADVANCE_STATE: u32 = 0; -pub const CARTESI_ROLLUP_INSPECT_STATE: u32 = 1; -pub const CARTESI_ROLLUP_ADDRESS_SIZE: u32 = 20; +pub const __bool_true_false_are_defined: u32 = 1; +pub const true_: u32 = 1; +pub const false_: u32 = 0; +pub const _STDINT_H: u32 = 1; +pub const _FEATURES_H: u32 = 1; +pub const _DEFAULT_SOURCE: u32 = 1; +pub const __GLIBC_USE_ISOC2X: u32 = 0; +pub const __USE_ISOC11: u32 = 1; +pub const __USE_ISOC99: u32 = 1; +pub const __USE_ISOC95: u32 = 1; +pub const __USE_POSIX_IMPLICITLY: u32 = 1; +pub const _POSIX_SOURCE: u32 = 1; +pub const _POSIX_C_SOURCE: u32 = 200809; +pub const __USE_POSIX: u32 = 1; +pub const __USE_POSIX2: u32 = 1; +pub const __USE_POSIX199309: u32 = 1; +pub const __USE_POSIX199506: u32 = 1; +pub const __USE_XOPEN2K: u32 = 1; +pub const __USE_XOPEN2K8: u32 = 1; +pub const _ATFILE_SOURCE: u32 = 1; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; +pub const __TIMESIZE: u32 = 64; +pub const __USE_MISC: u32 = 1; +pub const __USE_ATFILE: u32 = 1; +pub const __USE_FORTIFY_LEVEL: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; +pub const _STDC_PREDEF_H: u32 = 1; +pub const __STDC_IEC_559__: u32 = 1; +pub const __STDC_IEC_60559_BFP__: u32 = 201404; +pub const __STDC_IEC_559_COMPLEX__: u32 = 1; +pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; +pub const __STDC_ISO_10646__: u32 = 201706; +pub const __GNU_LIBRARY__: u32 = 6; +pub const __GLIBC__: u32 = 2; +pub const __GLIBC_MINOR__: u32 = 37; +pub const _SYS_CDEFS_H: u32 = 1; +pub const __glibc_c99_flexarr_available: u32 = 1; +pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; +pub const __HAVE_GENERIC_SELECTION: u32 = 1; +pub const __GLIBC_USE_LIB_EXT2: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; +pub const _BITS_TYPES_H: u32 = 1; +pub const _BITS_TYPESIZES_H: u32 = 1; +pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; +pub const __INO_T_MATCHES_INO64_T: u32 = 1; +pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; +pub const __STATFS_MATCHES_STATFS64: u32 = 1; +pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64: u32 = 1; +pub const __FD_SETSIZE: u32 = 1024; +pub const _BITS_TIME64_H: u32 = 1; +pub const _BITS_WCHAR_H: u32 = 1; +pub const _BITS_STDINT_INTN_H: u32 = 1; +pub const _BITS_STDINT_UINTN_H: u32 = 1; +pub const INT8_MIN: i32 = -128; +pub const INT16_MIN: i32 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT8_MAX: u32 = 127; +pub const INT16_MAX: u32 = 32767; +pub const INT32_MAX: u32 = 2147483647; +pub const UINT8_MAX: u32 = 255; +pub const UINT16_MAX: u32 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const INT_LEAST8_MIN: i32 = -128; +pub const INT_LEAST16_MIN: i32 = -32768; +pub const INT_LEAST32_MIN: i32 = -2147483648; +pub const INT_LEAST8_MAX: u32 = 127; +pub const INT_LEAST16_MAX: u32 = 32767; +pub const INT_LEAST32_MAX: u32 = 2147483647; +pub const UINT_LEAST8_MAX: u32 = 255; +pub const UINT_LEAST16_MAX: u32 = 65535; +pub const UINT_LEAST32_MAX: u32 = 4294967295; +pub const INT_FAST8_MIN: i32 = -128; +pub const INT_FAST16_MIN: i64 = -9223372036854775808; +pub const INT_FAST32_MIN: i64 = -9223372036854775808; +pub const INT_FAST8_MAX: u32 = 127; +pub const INT_FAST16_MAX: u64 = 9223372036854775807; +pub const INT_FAST32_MAX: u64 = 9223372036854775807; +pub const UINT_FAST8_MAX: u32 = 255; +pub const UINT_FAST16_MAX: i32 = -1; +pub const UINT_FAST32_MAX: i32 = -1; +pub const INTPTR_MIN: i64 = -9223372036854775808; +pub const INTPTR_MAX: u64 = 9223372036854775807; +pub const UINTPTR_MAX: i32 = -1; +pub const PTRDIFF_MIN: i64 = -9223372036854775808; +pub const PTRDIFF_MAX: u64 = 9223372036854775807; +pub const SIG_ATOMIC_MIN: i32 = -2147483648; +pub const SIG_ATOMIC_MAX: u32 = 2147483647; +pub const SIZE_MAX: i32 = -1; +pub const WINT_MIN: u32 = 0; +pub const WINT_MAX: u32 = 4294967295; +pub type wchar_t = ::std::os::raw::c_int; +#[repr(C)] +#[repr(align(16))] +#[derive(Debug, Copy, Clone)] +pub struct max_align_t { + pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, + pub __bindgen_padding_0: u64, + pub __clang_max_align_nonce2: u128, +} +#[test] +fn bindgen_test_layout_max_align_t() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(max_align_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 16usize, + concat!("Alignment of ", stringify!(max_align_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__clang_max_align_nonce1) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__clang_max_align_nonce2) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce2) + ) + ); +} +pub type __u_char = ::std::os::raw::c_uchar; +pub type __u_short = ::std::os::raw::c_ushort; +pub type __u_int = ::std::os::raw::c_uint; +pub type __u_long = ::std::os::raw::c_ulong; +pub type __int8_t = ::std::os::raw::c_schar; pub type __uint8_t = ::std::os::raw::c_uchar; +pub type __int16_t = ::std::os::raw::c_short; +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __int32_t = ::std::os::raw::c_int; +pub type __uint32_t = ::std::os::raw::c_uint; +pub type __int64_t = ::std::os::raw::c_long; pub type __uint64_t = ::std::os::raw::c_ulong; +pub type __int_least8_t = __int8_t; +pub type __uint_least8_t = __uint8_t; +pub type __int_least16_t = __int16_t; +pub type __uint_least16_t = __uint16_t; +pub type __int_least32_t = __int32_t; +pub type __uint_least32_t = __uint32_t; +pub type __int_least64_t = __int64_t; +pub type __uint_least64_t = __uint64_t; +pub type __quad_t = ::std::os::raw::c_long; +pub type __u_quad_t = ::std::os::raw::c_ulong; +pub type __intmax_t = ::std::os::raw::c_long; +pub type __uintmax_t = ::std::os::raw::c_ulong; +pub type __dev_t = ::std::os::raw::c_ulong; +pub type __uid_t = ::std::os::raw::c_uint; +pub type __gid_t = ::std::os::raw::c_uint; +pub type __ino_t = ::std::os::raw::c_ulong; +pub type __ino64_t = ::std::os::raw::c_ulong; +pub type __mode_t = ::std::os::raw::c_uint; +pub type __nlink_t = ::std::os::raw::c_ulong; +pub type __off_t = ::std::os::raw::c_long; +pub type __off64_t = ::std::os::raw::c_long; +pub type __pid_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __fsid_t { + pub __val: [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___fsid_t() { + const UNINIT: ::std::mem::MaybeUninit<__fsid_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__fsid_t>(), + 8usize, + concat!("Size of: ", stringify!(__fsid_t)) + ); + assert_eq!( + ::std::mem::align_of::<__fsid_t>(), + 4usize, + concat!("Alignment of ", stringify!(__fsid_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__fsid_t), + "::", + stringify!(__val) + ) + ); +} +pub type __clock_t = ::std::os::raw::c_long; +pub type __rlim_t = ::std::os::raw::c_ulong; +pub type __rlim64_t = ::std::os::raw::c_ulong; +pub type __id_t = ::std::os::raw::c_uint; +pub type __time_t = ::std::os::raw::c_long; +pub type __useconds_t = ::std::os::raw::c_uint; +pub type __suseconds_t = ::std::os::raw::c_long; +pub type __suseconds64_t = ::std::os::raw::c_long; +pub type __daddr_t = ::std::os::raw::c_int; +pub type __key_t = ::std::os::raw::c_int; +pub type __clockid_t = ::std::os::raw::c_int; +pub type __timer_t = *mut ::std::os::raw::c_void; +pub type __blksize_t = ::std::os::raw::c_long; +pub type __blkcnt_t = ::std::os::raw::c_long; +pub type __blkcnt64_t = ::std::os::raw::c_long; +pub type __fsblkcnt_t = ::std::os::raw::c_ulong; +pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; +pub type __fsword_t = ::std::os::raw::c_long; +pub type __ssize_t = ::std::os::raw::c_long; +pub type __syscall_slong_t = ::std::os::raw::c_long; +pub type __syscall_ulong_t = ::std::os::raw::c_ulong; +pub type __loff_t = __off64_t; +pub type __caddr_t = *mut ::std::os::raw::c_char; +pub type __intptr_t = ::std::os::raw::c_long; +pub type __socklen_t = ::std::os::raw::c_uint; +pub type __sig_atomic_t = ::std::os::raw::c_int; +pub type int_least8_t = __int_least8_t; +pub type int_least16_t = __int_least16_t; +pub type int_least32_t = __int_least32_t; +pub type int_least64_t = __int_least64_t; +pub type uint_least8_t = __uint_least8_t; +pub type uint_least16_t = __uint_least16_t; +pub type uint_least32_t = __uint_least32_t; +pub type uint_least64_t = __uint_least64_t; +pub type int_fast8_t = ::std::os::raw::c_schar; +pub type int_fast16_t = ::std::os::raw::c_long; +pub type int_fast32_t = ::std::os::raw::c_long; +pub type int_fast64_t = ::std::os::raw::c_long; +pub type uint_fast8_t = ::std::os::raw::c_uchar; +pub type uint_fast16_t = ::std::os::raw::c_ulong; +pub type uint_fast32_t = ::std::os::raw::c_ulong; +pub type uint_fast64_t = ::std::os::raw::c_ulong; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +#[doc = " A slice of contiguous memory from @b begin to @b end, as an open range.\n Size can be taken with: `end - begin`.\n\n `begin == end` indicate an empty buffer"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_bytes { - pub data: *mut ::std::os::raw::c_uchar, - pub length: u64, +pub struct cmt_buf_t { + #[doc = "< begin of memory region"] + pub begin: *mut u8, + #[doc = "< end of memory region"] + pub end: *mut u8, } #[test] -fn bindgen_test_layout_rollup_bytes() { +fn bindgen_test_layout_cmt_buf_t() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(rollup_bytes)) + concat!("Size of: ", stringify!(cmt_buf_t)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(rollup_bytes)) + concat!("Alignment of ", stringify!(cmt_buf_t)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).begin) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_bytes), + stringify!(cmt_buf_t), "::", - stringify!(data) + stringify!(begin) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).end) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(rollup_bytes), + stringify!(cmt_buf_t), "::", - stringify!(length) + stringify!(end) ) ); } +extern "C" { + #[doc = " Initialize @p me buffer backed by @p data, @p length bytes in size\n\n @param [out] me a uninitialized instance\n @param [in] length size in bytes of @b data\n @param [in] data the backing memory to be used.\n\n @note @p data memory must outlive @p me.\n user must copy the contents otherwise"] + pub fn cmt_buf_init(me: *mut cmt_buf_t, length: usize, data: *mut ::std::os::raw::c_void); +} +extern "C" { + #[doc = " Split a buffer in two, @b lhs with @b lhs_length bytes and @b rhs with the rest\n\n @param [in,out] me initialized buffer\n @param [in] lhs_length bytes in @b lhs\n @param [out] lhs left hand side\n @param [out] rhs right hand side\n\n @return\n - 0 success\n - negative value on error. -ENOBUFS when length(me) < lhs_length."] + pub fn cmt_buf_split( + me: *const cmt_buf_t, + lhs_length: usize, + lhs: *mut cmt_buf_t, + rhs: *mut cmt_buf_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Length in bytes of @p me\n\n @param [in] me initialized buffer\n\n @return\n - size in bytes"] + pub fn cmt_buf_length(me: *const cmt_buf_t) -> usize; +} +extern "C" { + #[doc = " Print the contents of @b me buffer to stdout\n\n @param [in] begin start of memory region\n @param [in] end end of memory region\n @param [in] bytes_per_line bytes per line (must be a power of 2)."] + pub fn cmt_buf_xxd( + begin: *mut ::std::os::raw::c_void, + end: *mut ::std::os::raw::c_void, + bytes_per_line: ::std::os::raw::c_int, + ); +} +extern "C" { + #[doc = " Take the substring @p x from @p xs start to the first @p , (comma).\n @param [out] x substring\n @param [in,out] xs string (interator)\n\n @note @p x points inside @p xs, make a copy if it outlives @p xs."] + pub fn cmt_buf_split_by_comma(x: *mut cmt_buf_t, xs: *mut cmt_buf_t) -> bool; +} +#[doc = "< length of a evm word in bytes"] +pub const CMT_WORD_LENGTH: _bindgen_ty_1 = 32; +#[doc = "< length of a evm address in bytes"] +pub const CMT_ADDRESS_LENGTH: _bindgen_ty_1 = 20; +pub type _bindgen_ty_1 = ::std::os::raw::c_uint; +extern "C" { + #[doc = " Create a function selector from an array of bytes\n @param [in] funsel function selector bytes\n @return\n - function selector converted to big endian (as expected by EVM)"] + pub fn cmt_abi_funsel(a: u8, b: u8, c: u8, d: u8) -> u32; +} +extern "C" { + #[doc = " Encode a function selector into the buffer @p me\n\n @param [in,out] me a initialized buffer working as iterator\n @param [in] funsel function selector\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n\n @note A function selector can be compute it with: @ref cmt_keccak_funsel.\n It is always represented in big endian."] + pub fn cmt_abi_put_funsel(me: *mut cmt_buf_t, funsel: u32) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode a unsigned integer of up to 32bytes of data into the buffer\n\n @param [in,out] me a initialized buffer working as iterator\n @param [in] n size of @p data in bytes\n @param [in] data poiter to a integer\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n - EDOM requested @p n is too large\n\n @code\n ...\n cmt_buf_t it = ...;\n uint64_t x = UINT64_C(0xdeadbeef);\n cmt_abi_put_uint(&it, sizeof x, &x);\n ...\n @endcode\n @note This function takes care of endianess conversions"] + pub fn cmt_abi_put_uint( + me: *mut cmt_buf_t, + n: usize, + data: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode a big-endian value of up to 32bytes of data into the buffer\n\n @param [in,out] me a initialized buffer working as iterator\n @param [in] length size of @p data in bytes\n @param [in] data poiter to a integer\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n - EDOM requested @p n is too large\n\n @code\n ...\n cmt_buf_t it = ...;\n uint8_t small[] = {\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\n };\n cmt_abi_put_uint(&it, sizeof small, &small);\n ...\n uint8_t big[] = {\n 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n };\n cmt_abi_put_uint(&it, sizeof big, &big);\n @endcode\n @note This function takes care of endianess conversions"] + pub fn cmt_abi_put_uint_be( + me: *mut cmt_buf_t, + n: usize, + data: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode a bool into the buffer\n\n @param [in,out] me a initialized buffer working as iterator\n @param [in] value boolean value\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n\n @code\n ...\n cmt_buf_t it = ...;\n cmt_abi_put_bool(&it, true);\n ...\n @endcode\n @note This function takes care of endianess conversions"] + pub fn cmt_abi_put_bool(me: *mut cmt_buf_t, value: bool) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode @p address (exacly @ref CMT_ADDRESS_LENGTH bytes) into the buffer\n\n @param [in,out] me initialized buffer\n @param [in] address exactly @ref CMT_ADDRESS_LENGTH bytes\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me"] + pub fn cmt_abi_put_address(me: *mut cmt_buf_t, address: *const u8) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode the static part of @b bytes into the message,\n used in conjunction with @ref cmt_abi_put_bytes_d\n\n @param [in,out] me initialized buffer\n @param [out] offset initialize for @ref cmt_abi_put_bytes_d\n @return\n - 0 success\n - ENOBUFS no space left in @p me"] + pub fn cmt_abi_put_bytes_s(me: *mut cmt_buf_t, offset: *mut cmt_buf_t) + -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode the dynamic part of @b bytes into the message,\n used in conjunction with @ref cmt_abi_put_bytes_d\n\n @param [in,out] me initialized buffer\n @param [in] offset initialized from @ref cmt_abi_put_bytes_h\n @param [in] n size of @b data\n @param [in] data array of bytes\n @param [in] start starting point for offset calculation (first byte after funsel)\n @return\n - 0 success\n - ENOBUFS no space left in @p me"] + pub fn cmt_abi_put_bytes_d( + me: *mut cmt_buf_t, + offset: *mut cmt_buf_t, + n: usize, + data: *const ::std::os::raw::c_void, + start: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Reserve @b n bytes of data from the buffer into @b res to be filled by the\n caller\n\n @param [in,out] me initialized buffer\n @param [in] n amount of bytes to reserve\n @param [out] res slice of bytes extracted from @p me\n @param [in] start starting point for offset calculation (first byte after funsel)\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n\n @note @p me must outlive @p res.\n Create a duplicate otherwise"] + pub fn cmt_abi_reserve_bytes_d( + me: *mut cmt_buf_t, + of: *mut cmt_buf_t, + n: usize, + out: *mut cmt_buf_t, + start: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Read the funsel without consuming it from the buffer @p me\n\n @param [in] me initialized buffer\n @return\n - The function selector\n\n @code\n ...\n if (cmt_buf_length(it) < 4)\n \treturn EXIT_FAILURE;\n switch (cmt_abi_peek_funsel(it) {\n case CMT_ABI_FUNSEL(...): // known type, try to parse it\n case CMT_ABI_FUNSEL(...): // known type, try to parse it\n default:\n \treturn EXIT_FAILURE;\n }\n @endcode\n\n @note user must ensure there are at least 4 bytes in the buffer.\n This function will fail and return 0 if that is not the case."] + pub fn cmt_abi_peek_funsel(me: *mut cmt_buf_t) -> u32; +} +extern "C" { + #[doc = " Consume funsel from the buffer @p me and ensure it matches @p expected_funsel\n\n @param [in,out] me initialized buffer\n @param [in] expected expected function selector\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n - EBADMSG in case of a missmatch"] + pub fn cmt_abi_check_funsel(me: *mut cmt_buf_t, expected: u32) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode a unsigned integer of up to 32bytes from the buffer\n\n @param [in,out] me initialized buffer\n @param [in] n size of @p data in bytes\n @param [out] data pointer to a integer\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n - EDOM value won't fit into @p n bytes."] + pub fn cmt_abi_get_uint( + me: *mut cmt_buf_t, + n: usize, + data: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode @p length big-endian bytes, up to 32, from the buffer into @p data\n\n @param [in,out] me initialized buffer\n @param [in] length size of @p data in bytes\n @param [out] data pointer to a integer\n\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n - EDOM value won't fit into @p n bytes."] + pub fn cmt_abi_get_uint_be( + me: *mut cmt_buf_t, + n: usize, + data: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Consume and decode @b address from the buffer\n\n @param [in,out] me initialized buffer\n @param [out] address exactly 20 bytes\n\n @return\n - 0 success\n - ENOBUFS requested size @b n is not available"] + pub fn cmt_abi_get_address(me: *mut cmt_buf_t, address: *mut u8) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Consume and decode the offset @p of\n\n @param [in,out] me initialized buffer\n @param [out] of offset to @p bytes data, for use in conjunction with @ref cmt_abi_get_bytes_d\n @return\n - 0 success\n - ENOBUFS no space left in @p me"] + pub fn cmt_abi_get_bytes_s(me: *mut cmt_buf_t, of: *mut cmt_buf_t) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode @b bytes from the buffer by taking a pointer to its contents.\n\n @param [in] start initialized buffer (from the start after funsel)\n @param [out] of offset to @p bytes data\n @param [out] n amount of data available in @b bytes\n @param [out] bytes memory range with contents\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n @note @p of can be initialized by calling @ref cmt_abi_get_bytes_s"] + pub fn cmt_abi_get_bytes_d( + start: *const cmt_buf_t, + of: *mut cmt_buf_t, + n: *mut usize, + bytes: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode @b bytes from the buffer by taking a pointer to its contents.\n\n @param [in] start initialized buffer (from the start after funsel)\n @param [out] of offset to @p bytes data\n @param [out] n amount of data available in @b bytes\n @param [out] bytes memory range with contents\n @return\n - 0 success\n - ENOBUFS no space left in @p me\n @note @p of can be initialized by calling @ref cmt_abi_get_bytes_s"] + pub fn cmt_abi_peek_bytes_d( + start: *const cmt_buf_t, + of: *mut cmt_buf_t, + bytes: *mut cmt_buf_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode @p n bytes of @p data into @p out (up to 32).\n\n @param [in] n size of @p data in bytes\n @param [in] data integer value to encode into @p out\n @param [out] out encoded result\n @return\n - 0 success\n - EDOM @p n is too large."] + pub fn cmt_abi_encode_uint( + n: usize, + data: *const ::std::os::raw::c_void, + out: *mut u8, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode @p n bytes of @p data into @p out (up to 32) in reverse order.\n\n @param [in] n size of @p data in bytes\n @param [in] data integer value to encode into @p out\n @param [out] out encoded result\n @return\n - 0 success\n - EDOM @p n is too large.\n @note use @ref cmt_abi_encode_uint instead"] + pub fn cmt_abi_encode_uint_nr(n: usize, data: *const u8, out: *mut u8) + -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Encode @p n bytes of @p data into @p out (up to 32) in normal order.\n\n @param [in] n size of @p data in bytes\n @param [in] data integer value to encode into @p out\n @param [out] out encoded result\n @return\n - 0 success\n - EDOM @p n is too large.\n @note use @ref cmt_abi_encode_uint instead"] + pub fn cmt_abi_encode_uint_nn(n: usize, data: *const u8, out: *mut u8) + -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode @p n bytes of @p data into @p out (up to 32).\n\n @param [in] data integer value to decode into @p out\n @param [in] n size of @p data in bytes\n @param [out] out decoded output"] + pub fn cmt_abi_decode_uint(data: *const u8, n: usize, out: *mut u8) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode @p n bytes of @p data into @p out (up to 32) in reverse order.\n\n @param [in] data integer value to decode into @p out\n @param [in] n size of @p data in bytes\n @param [out] out decoded output\n @note if in doubt, use @ref cmt_abi_decode_uint"] + pub fn cmt_abi_decode_uint_nr(data: *const u8, n: usize, out: *mut u8) + -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Decode @p n bytes of @p data into @p out (up to 32) in normal order.\n\n @param [in] data integer value to decode into @p out\n @param [in] n size of @p data in bytes\n @param [out] out decoded output\n @note if in doubt, use @ref cmt_abi_decode_uint"] + pub fn cmt_abi_decode_uint_nn(data: *const u8, n: usize, out: *mut u8) + -> ::std::os::raw::c_int; +} +#[doc = "< IO Device"] +pub const CMT_IO_DEV: _bindgen_ty_2 = 2; +pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +#[doc = "< Automatic"] +pub const CMT_IO_CMD_AUTOMATIC: _bindgen_ty_3 = 0; +#[doc = "< Manual"] +pub const CMT_IO_CMD_MANUAL: _bindgen_ty_3 = 1; +#[doc = " Request"] +pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +#[doc = "< Progress"] +pub const CMT_IO_REASON_PROGRESS: _bindgen_ty_4 = 0; +#[doc = "< Accept and load next input"] +pub const CMT_IO_REASON_RX_ACCEPTED: _bindgen_ty_4 = 1; +#[doc = "< Reject and revert"] +pub const CMT_IO_REASON_RX_REJECTED: _bindgen_ty_4 = 2; +#[doc = "< emit an output"] +pub const CMT_IO_REASON_TX_OUTPUT: _bindgen_ty_4 = 3; +#[doc = "< emit a report"] +pub const CMT_IO_REASON_TX_REPORT: _bindgen_ty_4 = 4; +#[doc = "< emit a exception and halt execution"] +pub const CMT_IO_REASON_TX_EXCEPTION: _bindgen_ty_4 = 5; +#[doc = " Request"] +pub type _bindgen_ty_4 = ::std::os::raw::c_uint; +#[doc = "< Input is advance"] +pub const CMT_IO_REASON_ADVANCE: _bindgen_ty_5 = 0; +#[doc = "< Input is inspect"] +pub const CMT_IO_REASON_INSPECT: _bindgen_ty_5 = 1; +#[doc = " Reply reason when requesting @ref CMT_IO_REASON_RX_ACCEPTED"] +pub type _bindgen_ty_5 = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_input_metadata { - pub msg_sender: [u8; 20usize], - pub block_number: u64, - pub timestamp: u64, - pub epoch_index: u64, - pub input_index: u64, +pub struct cmt_io_driver_ioctl_t { + pub tx: [cmt_buf_t; 1usize], + pub rx: [cmt_buf_t; 1usize], + pub fd: ::std::os::raw::c_int, } #[test] -fn bindgen_test_layout_rollup_input_metadata() { +fn bindgen_test_layout_cmt_io_driver_ioctl_t() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 56usize, - concat!("Size of: ", stringify!(rollup_input_metadata)) + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(cmt_io_driver_ioctl_t)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(rollup_input_metadata)) + concat!("Alignment of ", stringify!(cmt_io_driver_ioctl_t)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msg_sender as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).tx) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_input_metadata), + stringify!(cmt_io_driver_ioctl_t), "::", - stringify!(msg_sender) + stringify!(tx) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).block_number as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).rx) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(rollup_input_metadata), + stringify!(cmt_io_driver_ioctl_t), "::", - stringify!(block_number) + stringify!(rx) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).timestamp as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", - stringify!(rollup_input_metadata), + stringify!(cmt_io_driver_ioctl_t), "::", - stringify!(timestamp) + stringify!(fd) ) ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct cmt_io_driver_mock_t { + pub tx: [cmt_buf_t; 1usize], + pub rx: [cmt_buf_t; 1usize], + pub inputs_left: cmt_buf_t, + pub input_type: ::std::os::raw::c_int, + pub input_filename: [::std::os::raw::c_char; 128usize], + pub input_fileext: [::std::os::raw::c_char; 16usize], + pub input_seq: ::std::os::raw::c_int, + pub output_seq: ::std::os::raw::c_int, + pub report_seq: ::std::os::raw::c_int, + pub exception_seq: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_cmt_io_driver_mock_t() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).epoch_index as *const _ as usize - }, - 40usize, + ::std::mem::size_of::(), + 216usize, + concat!("Size of: ", stringify!(cmt_io_driver_mock_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(cmt_io_driver_mock_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tx) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(rollup_input_metadata), + stringify!(cmt_io_driver_mock_t), "::", - stringify!(epoch_index) + stringify!(tx) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input_index as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rx) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(rx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).inputs_left) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(inputs_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).input_type) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", - stringify!(rollup_input_metadata), + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(input_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).input_filename) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(input_filename) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).input_fileext) as usize - ptr as usize }, + 180usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), "::", - stringify!(input_index) + stringify!(input_fileext) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).input_seq) as usize - ptr as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(input_seq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).output_seq) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(output_seq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).report_seq) as usize - ptr as usize }, + 204usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(report_seq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).exception_seq) as usize - ptr as usize }, + 208usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_driver_mock_t), + "::", + stringify!(exception_seq) ) ); } +#[doc = " Implementation specific cmio state."] #[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct rollup_advance_state { - pub metadata: rollup_input_metadata, - pub payload: rollup_bytes, +#[derive(Copy, Clone)] +pub union cmt_io_driver { + pub ioctl: cmt_io_driver_ioctl_t, + pub mock: cmt_io_driver_mock_t, } #[test] -fn bindgen_test_layout_rollup_advance_state() { +fn bindgen_test_layout_cmt_io_driver() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(rollup_advance_state)) + ::std::mem::size_of::(), + 216usize, + concat!("Size of: ", stringify!(cmt_io_driver)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(rollup_advance_state)) + concat!("Alignment of ", stringify!(cmt_io_driver)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).metadata as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ioctl) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_advance_state), + stringify!(cmt_io_driver), "::", - stringify!(metadata) + stringify!(ioctl) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload as *const _ as usize }, - 56usize, + unsafe { ::std::ptr::addr_of!((*ptr).mock) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(rollup_advance_state), + stringify!(cmt_io_driver), "::", - stringify!(payload) + stringify!(mock) ) ); } +#[doc = " Implementation specific cmio state."] +pub type cmt_io_driver_t = cmt_io_driver; +#[doc = " yield struct cmt_io_yield"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_inspect_state { - pub payload: rollup_bytes, +pub struct cmt_io_yield { + pub dev: u8, + pub cmd: u8, + pub reason: u16, + pub data: u32, } #[test] -fn bindgen_test_layout_rollup_inspect_state() { +fn bindgen_test_layout_cmt_io_yield() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(rollup_inspect_state)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(cmt_io_yield)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(cmt_io_yield)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dev) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_yield), + "::", + stringify!(dev) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cmd) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_yield), + "::", + stringify!(cmd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reason) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_yield), + "::", + stringify!(reason) + ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(cmt_io_yield), + "::", + stringify!(data) + ) + ); +} +#[doc = " yield struct cmt_io_yield"] +pub type cmt_io_yield_t = cmt_io_yield; +extern "C" { + #[doc = " Open the io device and initialize the driver. Release its resources with @ref cmt_io_fini.\n\n @param [in] me A uninitialized @ref cmt_io_driver state\n @returns\n - 0 on success\n - negative errno code on error"] + pub fn cmt_io_init(me: *mut cmt_io_driver_t) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Release the driver resources and close the io device.\n\n @param [in] me A sucessfuly initialized state by @ref cmt_io_init\n @note usage of @p me after this call is a BUG and will cause undefined behaviour"] + pub fn cmt_io_fini(me: *mut cmt_io_driver_t); +} +extern "C" { + #[doc = " Retrieve the transmit buffer @p tx\n\n @param [in] me A sucessfuly initialized state by @ref cmt_io_init\n @return\n - writable memory region (check @ref cmt_buf_t)\n @note memory is valid until @ref cmt_io_fini is called."] + pub fn cmt_io_get_tx(me: *mut cmt_io_driver_t) -> cmt_buf_t; +} +extern "C" { + #[doc = " Retrieve the receive buffer @p rx\n\n @param [in] me A sucessfuly initialized state by @ref cmt_io_init\n @return\n - readable memory region (check @ref cmt_buf_t)\n @note memory is valid until @ref cmt_io_fini is called."] + pub fn cmt_io_get_rx(me: *mut cmt_io_driver_t) -> cmt_buf_t; +} +extern "C" { + #[doc = " Perform the yield encoded in @p rr.\n\n @param [in] me A sucessfuly initialized state by @ref cmt_io_init\n @param [in,out] rr Request and Reply\n @return\n - 0 on success\n - negative errno code on error"] + pub fn cmt_io_yield(me: *mut cmt_io_driver_t, rr: *mut cmt_io_yield_t) + -> ::std::os::raw::c_int; +} +#[doc = "< Bytes in the hash digest"] +pub const CMT_KECCAK_LENGTH: _bindgen_ty_6 = 32; +pub type _bindgen_ty_6 = ::std::os::raw::c_uint; +#[doc = " Opaque internal keccak state"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union cmt_keccak_state { + pub b: [u8; 200usize], + pub q: [u64; 25usize], +} +#[test] +fn bindgen_test_layout_cmt_keccak_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(cmt_keccak_state)) + ); + assert_eq!( + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(rollup_inspect_state)) + concat!("Alignment of ", stringify!(cmt_keccak_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cmt_keccak_state), + "::", + stringify!(b) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).q) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_inspect_state), + stringify!(cmt_keccak_state), "::", - stringify!(payload) + stringify!(q) ) ); } +#[doc = " Opaque internal keccak state"] +pub type cmt_keccak_state_t = cmt_keccak_state; +#[doc = " Opaque Keccak state, used to do hash computations, initialize with:\n - @ref cmt_keccak_init\n - @ref CMT_KECCAK_INIT\n - @ref CMT_KECCAK_DECL"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct cmt_keccak { + pub st: cmt_keccak_state_t, + pub pt: ::std::os::raw::c_int, + pub rsiz: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_cmt_keccak() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 208usize, + concat!("Size of: ", stringify!(cmt_keccak)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(cmt_keccak)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).st) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cmt_keccak), + "::", + stringify!(st) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pt) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(cmt_keccak), + "::", + stringify!(pt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rsiz) as usize - ptr as usize }, + 204usize, + concat!( + "Offset of field: ", + stringify!(cmt_keccak), + "::", + stringify!(rsiz) + ) + ); +} +#[doc = " Opaque Keccak state, used to do hash computations, initialize with:\n - @ref cmt_keccak_init\n - @ref CMT_KECCAK_INIT\n - @ref CMT_KECCAK_DECL"] +pub type cmt_keccak_t = cmt_keccak; +extern "C" { + #[doc = " Initialize a @ref cmt_keccak_t hasher state.\n\n @param [out] state uninitialized @ref cmt_keccak_t"] + pub fn cmt_keccak_init(state: *mut cmt_keccak_t); +} +extern "C" { + #[doc = " Hash @b n bytes of @b data\n\n @param [in,out] state initialize the hasher state\n @param [in] length bytes in @b data to process\n @param [in] data data to hash"] + pub fn cmt_keccak_update( + state: *mut cmt_keccak_t, + n: usize, + data: *const ::std::os::raw::c_void, + ); +} +extern "C" { + #[doc = " Finalize the hash calculation from @b state and store it in @b md\n\n @param [in] state initialize the hasher state (with all data already added to it)\n @param [out] md 32bytes to store the computed hash"] + pub fn cmt_keccak_final(state: *mut cmt_keccak_t, md: *mut ::std::os::raw::c_void); +} +extern "C" { + #[doc = " Hash all @b n bytes of @b data at once\n\n @param [in] length bytes in @b data to process\n @param [in] data data to hash\n @param [out] md 32bytes to store the computed hash\n @return pointer to @b md\n\n Equivalent to:\n @code\n cmt_keccak_t st = CMT_KECCAK_INIT(&st);\n cmt_keccak_update(&st, n, data);\n cmt_keccak_final(&st, md);\n return md;\n @endcode"] + pub fn cmt_keccak_data( + length: usize, + data: *const ::std::os::raw::c_void, + md: *mut u8, + ) -> *mut u8; +} +extern "C" { + #[doc = " Compute the function selector from the solidity declaration @p decl\n\n @param [in] decl solidity call declaration, without variable names\n @param [out] funsel function selector as described by @ref funsel\n @return A @p funsel value as if defined by @ref CMT_ABI_FUNSEL\n\n Example usage:\n @code\n ...\n uint32_t funsel = cmt_keccak_funsel(\"FunctionCall(address,bytes)\");\n ...\n @endcode"] + pub fn cmt_keccak_funsel(decl: *const ::std::os::raw::c_char) -> u32; +} +#[doc = "< merkle tree height"] +pub const CMT_MERKLE_MAX_DEPTH: _bindgen_ty_7 = 64; +pub type _bindgen_ty_7 = ::std::os::raw::c_uint; +#[doc = " Opaque Merkle tree state.\n initialize with: @ref cmt_merkle_init"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_finish { - pub accept_previous_request: bool, - pub next_request_type: ::std::os::raw::c_int, - pub next_request_payload_length: ::std::os::raw::c_int, +pub struct cmt_merkle_t { + pub leaf_count: u64, + pub state: [[u8; 32usize]; 64usize], + pub zero: *const [::std::os::raw::c_uchar; 32usize], } #[test] -fn bindgen_test_layout_rollup_finish() { +fn bindgen_test_layout_cmt_merkle_t() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(rollup_finish)) + ::std::mem::size_of::(), + 2064usize, + concat!("Size of: ", stringify!(cmt_merkle_t)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(rollup_finish)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(cmt_merkle_t)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).accept_previous_request as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).leaf_count) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_finish), + stringify!(cmt_merkle_t), "::", - stringify!(accept_previous_request) + stringify!(leaf_count) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).next_request_type as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(rollup_finish), + stringify!(cmt_merkle_t), "::", - stringify!(next_request_type) + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).zero) as usize - ptr as usize }, + 2056usize, + concat!( + "Offset of field: ", + stringify!(cmt_merkle_t), + "::", + stringify!(zero) ) ); +} +extern "C" { + #[doc = " Initialize a @ref cmt_merkle_t tree state.\n\n @param [in] me uninitialized state"] + pub fn cmt_merkle_init(me: *mut cmt_merkle_t); +} +extern "C" { + #[doc = " Finalize a @ref cmt_merkle_t tree state.\n\n @param [in] me initialized state\n\n @note use of @p me after this call is undefined behavior."] + pub fn cmt_merkle_fini(me: *mut cmt_merkle_t); +} +extern "C" { + #[doc = " Load the a @ref cmt_merkle_t tree from a @p file handle.\n\n @param [in] me either a initialized or uninitialized state\n @param [in] filepath which file to save the merkle state\n @return\n - 0 on success"] + pub fn cmt_merkle_load( + me: *mut cmt_merkle_t, + filepath: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Save the a @ref cmt_merkle_t tree to a @p file handle.\n\n @param [in] me either a initialized or uninitialized state\n @param [in] filepath which file to save the merkle state\n @return\n - 0 on success"] + pub fn cmt_merkle_save( + me: *mut cmt_merkle_t, + filepath: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Size in bytes required by merkle state save\n\n @param [in] me uninitialized state\n @param [in] length size of @p data in bytes\n @param [in] data array of bytes\n @return\n - size of the array required by @ref cmt_merkle_state_save"] + pub fn cmt_merkle_max_length() -> usize; +} +extern "C" { + #[doc = " Append a leaf node\n\n @param [in,out] me initialized state\n @param [in] hash value of the new leaf\n @return\n - 0 success\n - -ENOBUFS indicates the tree is full"] + pub fn cmt_merkle_push_back(me: *mut cmt_merkle_t, hash: *mut u8) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Compute the keccak-256 hash of @p data and append it as a leaf node\n\n @param [in,out] me initialized state\n @param [in] length size of @p data in bytes\n @param [in] data array of bytes\n @return\n - 0 success\n - -ENOBUFS indicates that the tree is full"] + pub fn cmt_merkle_push_back_data( + me: *mut cmt_merkle_t, + length: usize, + data: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Retrieve the root hash of the merkle tree\n\n @param [in] me initialized state\n @param [out] root root hash of the merkle tree"] + pub fn cmt_merkle_get_root_hash(me: *mut cmt_merkle_t, root: *mut u8); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct cmt_rollup { + pub io: [cmt_io_driver; 1usize], + pub merkle: [cmt_merkle_t; 1usize], +} +#[test] +fn bindgen_test_layout_cmt_rollup() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 2280usize, + concat!("Size of: ", stringify!(cmt_rollup)) + ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).next_request_payload_length as *const _ - as usize - }, + ::std::mem::align_of::(), 8usize, + concat!("Alignment of ", stringify!(cmt_rollup)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).io) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(rollup_finish), + stringify!(cmt_rollup), "::", - stringify!(next_request_payload_length) + stringify!(io) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).merkle) as usize - ptr as usize }, + 216usize, + concat!( + "Offset of field: ", + stringify!(cmt_rollup), + "::", + stringify!(merkle) ) ); } +pub type cmt_rollup_t = cmt_rollup; +#[doc = " Public struct with the advance state contents"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_voucher { - pub destination: [u8; 20usize], - pub payload: rollup_bytes, +pub struct cmt_rollup_advance { + #[doc = "< the address of the input sender"] + pub sender: [u8; 20usize], + #[doc = "< block number of this input"] + pub block_number: u64, + #[doc = "< block timestamp of this input UNIX epoch format)"] + pub block_timestamp: u64, + #[doc = "< input index (in relation to all inputs ever sent to the DApp)"] pub index: u64, + #[doc = "< length in bytes of the data field"] + pub length: u32, + #[doc = "< advance contents"] + pub data: *mut ::std::os::raw::c_void, } #[test] -fn bindgen_test_layout_rollup_voucher() { +fn bindgen_test_layout_cmt_rollup_advance() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(rollup_voucher)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(cmt_rollup_advance)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(rollup_voucher)) + concat!("Alignment of ", stringify!(cmt_rollup_advance)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).destination as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sender) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_voucher), + stringify!(cmt_rollup_advance), "::", - stringify!(destination) + stringify!(sender) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).block_number) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", - stringify!(rollup_voucher), + stringify!(cmt_rollup_advance), + "::", + stringify!(block_number) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).block_timestamp) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(cmt_rollup_advance), "::", - stringify!(payload) + stringify!(block_timestamp) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", - stringify!(rollup_voucher), + stringify!(cmt_rollup_advance), "::", stringify!(index) ) ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(cmt_rollup_advance), + "::", + stringify!(length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(cmt_rollup_advance), + "::", + stringify!(data) + ) + ); } +#[doc = " Public struct with the advance state contents"] +pub type cmt_rollup_advance_t = cmt_rollup_advance; +#[doc = " Public struct with the inspect state contents"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_notice { - pub payload: rollup_bytes, - pub index: u64, +pub struct cmt_rollup_inspect { + #[doc = "< length in bytes of the data field"] + pub length: u32, + #[doc = "< inspect contents"] + pub data: *mut ::std::os::raw::c_void, } #[test] -fn bindgen_test_layout_rollup_notice() { +fn bindgen_test_layout_cmt_rollup_inspect() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(rollup_notice)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(cmt_rollup_inspect)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(rollup_notice)) + concat!("Alignment of ", stringify!(cmt_rollup_inspect)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_notice), + stringify!(cmt_rollup_inspect), "::", - stringify!(payload) + stringify!(length) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(rollup_notice), + stringify!(cmt_rollup_inspect), "::", - stringify!(index) + stringify!(data) ) ); } +#[doc = " Public struct with the inspect state contents"] +pub type cmt_rollup_inspect_t = cmt_rollup_inspect; +#[doc = " Public struct with the finish state contents"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct rollup_report { - pub payload: rollup_bytes, +pub struct cmt_rollup_finish { + pub accept_previous_request: bool, + pub next_request_type: ::std::os::raw::c_int, + pub next_request_payload_length: u32, } #[test] -fn bindgen_test_layout_rollup_report() { +fn bindgen_test_layout_cmt_rollup_finish() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(rollup_report)) + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(cmt_rollup_finish)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(rollup_report)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(cmt_rollup_finish)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).payload as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).accept_previous_request) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(rollup_report), + stringify!(cmt_rollup_finish), + "::", + stringify!(accept_previous_request) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).next_request_type) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(cmt_rollup_finish), "::", - stringify!(payload) + stringify!(next_request_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).next_request_payload_length) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(cmt_rollup_finish), + "::", + stringify!(next_request_payload_length) ) ); } - +#[doc = " Public struct with the finish state contents"] +pub type cmt_rollup_finish_t = cmt_rollup_finish; extern "C" { - pub fn rollup_finish_request( - fd: ::std::os::raw::c_int, - finish: *mut rollup_finish, - accept: bool, + #[doc = " Initialize a @ref cmt_rollup_t state.\n\n @param [in] me uninitialized state\n\n - 0 success\n - negative value on error. values from: @ref cmt_rollup_driver_init"] + pub fn cmt_rollup_init(me: *mut cmt_rollup_t) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Finalize a @ref cmt_rollup_t statate previously initialized with @ref\n cmt_rollup_init\n\n @param [in] me initialized state\n\n @note use of @p me after this call is undefined behavior."] + pub fn cmt_rollup_fini(me: *mut cmt_rollup_t); +} +extern "C" { + #[doc = " Emit a voucher\n\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in] address destination\n @param [in] n sizeof @p data in bytes\n @param [in] data message contents\n @return\n - 0 success\n - -ENOBUFS no space left in @p me"] + pub fn cmt_rollup_emit_voucher( + me: *mut cmt_rollup_t, + address_length: u32, + address_data: *const ::std::os::raw::c_void, + value_length: u32, + value_data: *const ::std::os::raw::c_void, + length: u32, + data: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; - - pub fn rollup_read_advance_state_request( - fd: ::std::os::raw::c_int, - finish: *mut rollup_finish, - bytes: *mut rollup_bytes, - metadata: *mut rollup_input_metadata, +} +extern "C" { + #[doc = " Emit a notice\n\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in] n sizeof @p data in bytes\n @param [in] data message contents\n @return\n - 0 success\n - -ENOBUFS no space left in @p me"] + pub fn cmt_rollup_emit_notice( + me: *mut cmt_rollup_t, + length: u32, + data: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; - - pub fn rollup_read_inspect_state_request( - fd: ::std::os::raw::c_int, - finish: *mut rollup_finish, - query: *mut rollup_bytes, +} +extern "C" { + #[doc = " Emit a report\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in] n sizeof @p data in bytes\n @param [in] data message contents\n @return\n - 0 success\n - -ENOBUFS no space left in @p me"] + pub fn cmt_rollup_emit_report( + me: *mut cmt_rollup_t, + length: u32, + data: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; - - pub fn rollup_write_voucher( - fd: ::std::os::raw::c_int, - destination: *mut u8, - bytes: *mut rollup_bytes, - voucher_index: *mut u64, +} +extern "C" { + #[doc = " Emit a exception\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in] n sizeof @p data in bytes\n @param [in] data message contents\n @return\n - 0 success\n - -ENOBUFS no space left in @p me"] + pub fn cmt_rollup_emit_exception( + me: *mut cmt_rollup_t, + length: u32, + data: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; - - pub fn rollup_write_notice( - fd: ::std::os::raw::c_int, - bytes: *mut rollup_bytes, - notice_index: *mut u64, +} +extern "C" { + #[doc = " Read advance state\n\n @return\n - 0 success\n - negative value on error."] + pub fn cmt_rollup_read_advance_state( + me: *mut cmt_rollup_t, + advance: *mut cmt_rollup_advance_t, ) -> ::std::os::raw::c_int; - - pub fn rollup_write_report( - fd: ::std::os::raw::c_int, - bytes: *mut rollup_bytes, +} +extern "C" { + #[doc = " Read inspect state\n\n @return\n - 0 success\n - negative value on error."] + pub fn cmt_rollup_read_inspect_state( + me: *mut cmt_rollup_t, + inspect: *mut cmt_rollup_inspect_t, ) -> ::std::os::raw::c_int; - - pub fn rollup_throw_exception( - fd: ::std::os::raw::c_int, - bytes: *mut rollup_bytes, +} +extern "C" { + #[doc = " Finish processing of current advance or inspect.\n Waits for and returns the next advance or inspect query when available.\n\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in,out] finish initialized cmt_rollup_finish_t instance\n\n @return\n - 0 success\n - negative value on error"] + pub fn cmt_rollup_finish( + me: *mut cmt_rollup_t, + finish: *mut cmt_rollup_finish_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Retrieve the merkle tree and intermediate state from a file @p path\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in] file path to file (parent directories must exist)"] + pub fn cmt_rollup_load_merkle( + me: *mut cmt_rollup_t, + path: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " Store the merkle tree and intermediate state to a file @p path\n\n @param [in,out] me initialized cmt_rollup_t instance\n @param [in] file path to file (parent directories must exist)"] + pub fn cmt_rollup_save_merkle( + me: *mut cmt_rollup_t, + path: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } diff --git a/rollup-http/rollup-http-server/src/rollup/mod.rs b/rollup-http/rollup-http-server/src/rollup/mod.rs index 3104f8af..11251dbe 100644 --- a/rollup-http/rollup-http-server/src/rollup/mod.rs +++ b/rollup-http/rollup-http-server/src/rollup/mod.rs @@ -14,19 +14,47 @@ // limitations under the License. // -pub const ROLLUP_DEVICE_NAME: &str = "/dev/rollup"; +use std::io::ErrorKind; +use libc::c_void; use serde::{Deserialize, Serialize}; -use std::io::ErrorKind; -use std::os::unix::prelude::RawFd; + +use self::bindings::cmt_rollup_t; + +#[derive(Clone)] +pub struct RollupFd(*mut cmt_rollup_t); + +impl RollupFd { + pub fn create() -> Result { + unsafe { + let zeroed = Box::leak(Box::new(std::mem::zeroed::())); + let result = bindings::cmt_rollup_init(zeroed); + if result != 0 { + Err(result) + } else { + Ok(RollupFd(zeroed)) + } + } + } +} + +impl Drop for RollupFd { + fn drop(&mut self) { + unsafe { + bindings::cmt_rollup_fini(self.0); + drop(Box::from_raw(self.0)); + } + } +} + +unsafe impl Sync for RollupFd {} +unsafe impl Send for RollupFd {} mod bindings; -pub use bindings::CARTESI_ROLLUP_ADDRESS_SIZE; -pub use bindings::CARTESI_ROLLUP_ADVANCE_STATE; -pub use bindings::CARTESI_ROLLUP_INSPECT_STATE; pub const REQUEST_TYPE_ADVANCE_STATE: &str = "advance_state"; pub const REQUEST_TYPE_INSPECT_STATE: &str = "inspect_state"; +pub const CARTESI_ROLLUP_ADDRESS_SIZE: u32 = 20; #[derive(Debug, Default)] pub struct RollupError { @@ -53,35 +81,25 @@ impl std::error::Error for RollupError {} pub struct RollupFinish { pub accept_previous_request: bool, pub next_request_type: i32, - pub next_request_payload_length: i32, + pub next_request_payload_length: usize, } -impl From for bindings::rollup_finish { +impl From for bindings::cmt_rollup_finish_t { fn from(other: RollupFinish) -> Self { - bindings::rollup_finish { + bindings::cmt_rollup_finish_t { next_request_type: other.next_request_type, accept_previous_request: other.accept_previous_request, - next_request_payload_length: other.next_request_payload_length, + next_request_payload_length: other.next_request_payload_length as u32, } } } -impl From<&mut RollupFinish> for bindings::rollup_finish { +impl From<&mut RollupFinish> for bindings::cmt_rollup_finish_t { fn from(other: &mut RollupFinish) -> Self { - bindings::rollup_finish { + bindings::cmt_rollup_finish_t { next_request_type: other.next_request_type, accept_previous_request: other.accept_previous_request, - next_request_payload_length: other.next_request_payload_length, - } - } -} - -impl From for RollupFinish { - fn from(other: bindings::rollup_finish) -> Self { - RollupFinish { - next_request_type: other.next_request_type, - accept_previous_request: other.accept_previous_request, - next_request_payload_length: other.next_request_payload_length, + next_request_payload_length: other.next_request_payload_length as u32, } } } @@ -95,20 +113,30 @@ pub struct AdvanceMetadata { pub timestamp: u64, } -impl From for AdvanceMetadata { - fn from(other: bindings::rollup_input_metadata) -> Self { +impl From for AdvanceMetadata { + fn from(other: bindings::cmt_rollup_advance_t) -> Self { let mut address = "0x".to_string(); - address.push_str(&hex::encode(&other.msg_sender)); + address.push_str(&hex::encode(&other.sender)); AdvanceMetadata { - input_index: other.input_index, - epoch_index: other.epoch_index, - timestamp: other.timestamp, + input_index: other.index, + epoch_index: other.block_number, // TODO: Check if it's correct + timestamp: other.block_timestamp, block_number: other.block_number, msg_sender: address, } } } +impl From for RollupFinish { + fn from(other: bindings::cmt_rollup_finish_t) -> Self { + RollupFinish { + next_request_type: other.next_request_type, + accept_previous_request: other.accept_previous_request, + next_request_payload_length: other.next_request_payload_length as usize, + } + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AdvanceRequest { pub metadata: AdvanceMetadata, @@ -127,7 +155,7 @@ pub enum RollupRequest { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct InspectReport { - pub reports: Vec, + pub reports: Vec } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -138,6 +166,7 @@ pub struct Notice { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Voucher { pub destination: String, + pub data: String, pub payload: String, } @@ -156,49 +185,44 @@ pub enum RollupResponse { } pub fn rollup_finish_request( - fd: RawFd, + fd: &RollupFd, finish: &mut RollupFinish, - accept: bool, ) -> Result<(), Box> { - let mut finish_c = Box::new(bindings::rollup_finish::from(&mut *finish)); + let mut finish_c = Box::new(bindings::cmt_rollup_finish_t::from(&mut *finish)); log::debug!("writing rollup finish request, yielding"); - let res = unsafe { bindings::rollup_finish_request(fd as i32, finish_c.as_mut(), accept) }; - if res != 0 { + + let res = unsafe { bindings::cmt_rollup_finish(fd.0, finish_c.as_mut()) }; + + if res < 0 { log::error!("failed to write finish request, IOCTL error {}", res); return Err(Box::new(RollupError::new(&format!( "IOCTL_ROLLUP_FINISH returned error {}", res )))); } + *finish = RollupFinish::from(*finish_c); + log::debug!("finish request written to rollup device: {:#?}", &finish); Ok(()) } pub fn rollup_read_advance_state_request( - fd: RawFd, - finish: &mut RollupFinish, + fd: &RollupFd, ) -> Result> { - let mut finish_c = Box::new(bindings::rollup_finish::from(&mut *finish)); - let mut bytes_c = Box::new(bindings::rollup_bytes { - data: std::ptr::null::<::std::os::raw::c_uchar>() as *mut ::std::os::raw::c_uchar, - length: 0, - }); - let mut input_metadata_c = Box::new(bindings::rollup_input_metadata { - msg_sender: Default::default(), + + let mut advance_request = Box::new(bindings::cmt_rollup_advance_t { + sender: Default::default(), block_number: 0, - timestamp: 0, - epoch_index: 0, - input_index: 0, + block_timestamp: 0, + index: 0, + length: 0, + data: std::ptr::null::<::std::os::raw::c_uchar>() as *mut c_void, }); + let res = unsafe { - bindings::rollup_read_advance_state_request( - fd as i32, - finish_c.as_mut(), - bytes_c.as_mut(), - input_metadata_c.as_mut(), - ) + bindings::cmt_rollup_read_advance_state(fd.0, advance_request.as_mut()) }; if res != 0 { @@ -208,68 +232,66 @@ pub fn rollup_read_advance_state_request( )))); } - if bytes_c.length == 0 { + if advance_request.length == 0 { log::info!("read zero size payload from advance state request"); } - let mut payload: Vec = Vec::with_capacity(bytes_c.length as usize); - if bytes_c.length > 0 { + let mut payload: Vec = Vec::with_capacity(advance_request.length as usize); + if advance_request.length > 0 { unsafe { - std::ptr::copy(bytes_c.data, payload.as_mut_ptr(), bytes_c.length as usize); - payload.set_len(bytes_c.length as usize); + std::ptr::copy(advance_request.data, payload.as_mut_ptr() as *mut c_void, advance_request.length as usize); + payload.set_len(advance_request.length as usize); } } let result = AdvanceRequest { - metadata: AdvanceMetadata::from(*input_metadata_c), + metadata: AdvanceMetadata::from(*advance_request), payload: "0x".to_string() + &hex::encode(&payload), }; - *finish = RollupFinish::from(*finish_c); + Ok(result) } + pub fn rollup_read_inspect_state_request( - fd: RawFd, - finish: &mut RollupFinish, + fd: &RollupFd, ) -> Result> { - let mut finish_c = Box::new(bindings::rollup_finish::from(&mut *finish)); - let mut bytes_c = Box::new(bindings::rollup_bytes { - data: std::ptr::null::<::std::os::raw::c_uchar>() as *mut ::std::os::raw::c_uchar, + + let mut inspect_request = Box::new(bindings::cmt_rollup_inspect_t { length: 0, + data: std::ptr::null::<::std::os::raw::c_uchar>() as *mut c_void, }); + let res = unsafe { - bindings::rollup_read_inspect_state_request(fd as i32, finish_c.as_mut(), bytes_c.as_mut()) + bindings::cmt_rollup_read_inspect_state(fd.0, inspect_request.as_mut()) }; - if res != 0 { - return Err(Box::new(RollupError::new(&format!( - "IOCTL_ROLLUP_READ_INSPECT_STATE returned error {}", - res - )))); - } - if bytes_c.length == 0 { + + + if inspect_request.length == 0 { log::info!("read zero size payload from inspect state request"); } - let mut payload: Vec = Vec::with_capacity(bytes_c.length as usize); - if bytes_c.length > 0 { + let mut payload: Vec = Vec::with_capacity(inspect_request.length as usize); + if inspect_request.length > 0 { unsafe { - std::ptr::copy(bytes_c.data, payload.as_mut_ptr(), bytes_c.length as usize); - payload.set_len(bytes_c.length as usize); + std::ptr::copy(inspect_request.data, payload.as_mut_ptr() as *mut c_void, inspect_request.length as usize); + payload.set_len(inspect_request.length as usize); } } let result = InspectRequest { payload: "0x".to_string() + &hex::encode(&payload), }; - *finish = RollupFinish::from(*finish_c); + Ok(result) } pub fn rollup_write_notice( - fd: RawFd, + fd: &RollupFd, notice: &mut Notice, ) -> Result> { print_notice(notice); + let binary_payload = match hex::decode(¬ice.payload[2..]) { Ok(payload) => payload, Err(_err) => { @@ -278,20 +300,21 @@ pub fn rollup_write_notice( )))); } }; + let mut buffer: Vec = Vec::with_capacity(binary_payload.len()); - let mut bytes_c = Box::new(bindings::rollup_bytes { - data: buffer.as_mut_ptr() as *mut ::std::os::raw::c_uchar, - length: binary_payload.len() as u64, - }); + let length = binary_payload.len() as u64; let mut notice_index: std::os::raw::c_ulong = 0; + let res = unsafe { std::ptr::copy( binary_payload.as_ptr(), buffer.as_mut_ptr(), binary_payload.len(), ); - bindings::rollup_write_notice(fd as i32, bytes_c.as_mut(), &mut notice_index) + + bindings::cmt_rollup_emit_notice(fd.0, length as u32, buffer.as_mut_ptr() as *mut c_void) }; + if res != 0 { return Err(Box::new(RollupError::new(&format!( "IOCTL_ROLLUP_WRITE_NOTICE returned error {}", @@ -300,14 +323,17 @@ pub fn rollup_write_notice( } else { log::debug!("notice with id {} successfully written!", notice_index); } + Ok(notice_index as u64) } + pub fn rollup_write_voucher( - fd: RawFd, + fd: &RollupFd, voucher: &mut Voucher, ) -> Result> { print_voucher(voucher); + let binary_payload = match hex::decode(&voucher.payload[2..]) { Ok(payload) => payload, Err(_err) => { @@ -316,13 +342,13 @@ pub fn rollup_write_voucher( )))); } }; + let mut buffer: Vec = Vec::with_capacity(binary_payload.len()); - let mut bytes_c = Box::new(bindings::rollup_bytes { - data: buffer.as_mut_ptr() as *mut ::std::os::raw::c_uchar, - length: binary_payload.len() as u64, - }); - let mut address_c = match hex::decode(&voucher.destination[2..]) { + let data = buffer.as_mut_ptr(); + let length = binary_payload.len(); + + let address_c = match hex::decode(&voucher.destination[2..]) { Ok(res) => res, Err(e) => { return Err(Box::new(RollupError::new(&format!( @@ -332,20 +358,25 @@ pub fn rollup_write_voucher( } }; - let mut voucher_index: std::os::raw::c_ulong = 0; + let voucher_index: std::os::raw::c_ulong = 0; let res = unsafe { std::ptr::copy( binary_payload.as_ptr(), buffer.as_mut_ptr(), binary_payload.len(), ); - bindings::rollup_write_voucher( - fd as i32, - address_c.as_mut_ptr(), - bytes_c.as_mut(), - &mut voucher_index, + + bindings::cmt_rollup_emit_voucher( + fd.0, + address_c.len() as u32, + address_c.as_ptr() as *const c_void, + length as u32, + data as *mut c_void, + length as u32, + data as *mut c_void, ) }; + if res != 0 { return Err(Box::new(RollupError::new(&format!( "IOCTL_ROLLUP_WRITE_VOUCHER returned error {}", @@ -358,8 +389,9 @@ pub fn rollup_write_voucher( Ok(voucher_index as u64) } -pub fn rollup_write_report(fd: RawFd, report: &Report) -> Result<(), Box> { +pub fn rollup_write_report(fd: &RollupFd, report: &Report) -> Result<(), Box> { print_report(report); + let binary_payload = match hex::decode(&report.payload[2..]) { Ok(payload) => payload, Err(_err) => { @@ -368,19 +400,21 @@ pub fn rollup_write_report(fd: RawFd, report: &Report) -> Result<(), Box = Vec::with_capacity(binary_payload.len()); - let mut bytes_c = Box::new(bindings::rollup_bytes { - data: buffer.as_mut_ptr() as *mut ::std::os::raw::c_uchar, - length: binary_payload.len() as u64, - }); + + let data = buffer.as_mut_ptr() as *mut c_void; + let length = binary_payload.len(); + let res = unsafe { std::ptr::copy( binary_payload.as_ptr(), buffer.as_mut_ptr(), binary_payload.len(), ); - bindings::rollup_write_report(fd as i32, bytes_c.as_mut()) + bindings::cmt_rollup_emit_report(fd.0, length as u32, data) }; + if res != 0 { return Err(Box::new(RollupError::new(&format!( "IOCTL_ROLLUP_WRITE_REPORT returned error {}", @@ -389,14 +423,16 @@ pub fn rollup_write_report(fd: RawFd, report: &Report) -> Result<(), Box Result<(), Box> { print_exception(exception); + let binary_payload = match hex::decode(&exception.payload[2..]) { Ok(payload) => payload, Err(_err) => { @@ -405,18 +441,18 @@ pub fn rollup_throw_exception( )))); } }; + let mut buffer: Vec = Vec::with_capacity(binary_payload.len()); - let mut bytes_c = Box::new(bindings::rollup_bytes { - data: buffer.as_mut_ptr() as *mut ::std::os::raw::c_uchar, - length: binary_payload.len() as u64, - }); + let length = binary_payload.len(); + let data = buffer.as_mut_ptr() as *mut c_void; + let res = unsafe { std::ptr::copy( binary_payload.as_ptr(), buffer.as_mut_ptr(), binary_payload.len(), ); - bindings::rollup_throw_exception(fd as i32, bytes_c.as_mut()) + bindings::cmt_rollup_emit_exception(fd.0, length as u32, data) }; if res != 0 { return Err(Box::new(RollupError::new(&format!( @@ -430,31 +466,34 @@ pub fn rollup_throw_exception( } pub async fn perform_rollup_finish_request( - fd: RawFd, - accept: bool, + fd: &RollupFd, ) -> std::io::Result { let mut finish_request = RollupFinish::default(); - match rollup_finish_request(fd, &mut finish_request, accept) { + finish_request.accept_previous_request = true; + + match rollup_finish_request(fd, &mut finish_request) { Ok(_) => Ok(finish_request), Err(e) => { log::error!("error inserting finish request, details: {}", e.to_string()); Err(std::io::Error::new(ErrorKind::Other, e.to_string())) } } + } /// Read advance/inspect request from rollup device pub async fn handle_rollup_requests( - fd: RawFd, + fd: &RollupFd, mut finish_request: RollupFinish, ) -> Result { let next_request_type = finish_request.next_request_type as u32; + match next_request_type { - CARTESI_ROLLUP_ADVANCE_STATE => { + 0 => { log::debug!("handle advance state request..."); let advance_request = { // Read advance request from rollup device - match rollup_read_advance_state_request(fd, &mut finish_request) { + match rollup_read_advance_state_request(fd) { Ok(r) => r, Err(e) => { return Err(std::io::Error::new(ErrorKind::Other, e.to_string())); @@ -467,11 +506,11 @@ pub async fn handle_rollup_requests( // Send newly read advance request to http service Ok(RollupRequest::Advance(advance_request)) } - CARTESI_ROLLUP_INSPECT_STATE => { + 1 => { log::debug!("handle inspect state request..."); // Read inspect request from rollup device let inspect_request = { - match rollup_read_inspect_state_request(fd, &mut finish_request) { + match rollup_read_inspect_state_request(fd) { Ok(r) => r, Err(e) => { return Err(std::io::Error::new(ErrorKind::Other, e.to_string())); @@ -531,6 +570,7 @@ pub fn print_notice(notice: &Notice) { ); } + pub fn print_voucher(voucher: &Voucher) { let mut voucher_request_printout = String::new(); voucher_request_printout.push_str("voucher: {{ destination: "); diff --git a/rollup-http/rollup-http-server/tests/rollup-http-server-tests.rs b/rollup-http/rollup-http-server/tests/rollup-http-server-tests.rs index b421ceb3..69bc07c6 100644 --- a/rollup-http/rollup-http-server/tests/rollup-http-server-tests.rs +++ b/rollup-http/rollup-http-server/tests/rollup-http-server-tests.rs @@ -23,16 +23,16 @@ use rollup_http_client::rollup::{ Exception, Notice, Report, RollupRequest, RollupResponse, Voucher, }; use rollup_http_server::config::Config; +use rollup_http_server::rollup::RollupFd; use rollup_http_server::*; use rstest::*; use std::fs::File; use std::future::Future; -use std::os::unix::io::{IntoRawFd, RawFd}; use std::sync::Arc; +use rand::Rng; +use std::env; -const PORT: u16 = 10010; const HOST: &str = "127.0.0.1"; -const TEST_ROLLUP_DEVICE: &str = "rollup_driver.bin"; #[allow(dead_code)] struct Context { @@ -51,17 +51,7 @@ fn run_test_http_service( host: &str, port: u16, ) -> std::io::Result> { - println!("Opening rollup device"); - // Open test rollup device - let rollup_file = match File::create(TEST_ROLLUP_DEVICE) { - Ok(file) => file, - Err(e) => { - log::error!("error opening rollup device {}", e.to_string()); - return Err(e); - } - }; - - let rollup_fd: Arc> = Arc::new(Mutex::new(rollup_file.into_raw_fd())); + let rollup_fd: Arc> = Arc::new(Mutex::new(RollupFd::create().unwrap())); let rollup_fd = rollup_fd.clone(); let http_config = Config { http_address: host.to_string(), @@ -80,8 +70,11 @@ fn run_test_http_service( async fn context_future() -> Context { let mut server_handle: Option = None; let mut count = 5; + let mut port; loop { - match run_test_http_service(HOST, PORT) { + port = rand::thread_rng().gen_range(49152..65535); + + match run_test_http_service(HOST, port) { Ok(handle) => { server_handle = handle; break; @@ -100,7 +93,7 @@ async fn context_future() -> Context { } Context { - address: format!("http://{}:{}", HOST, PORT), + address: format!("http://{}:{}", HOST, port), server_handle: server_handle.unwrap(), } } @@ -125,9 +118,13 @@ async fn test_server_instance_creation( async fn test_finish_request( context_future: impl Future, ) -> Result<(), Box> { + env::set_var("CMT_INPUTS", "0:advance.bin,1:inspect.bin"); + env::set_var("CMT_DEBUG", "yes"); + let context = context_future.await; println!("Sending finish request"); let request_response = RollupResponse::Finish(true); + match rollup_http_client::client::send_finish_request(&context.address, &request_response).await { Ok(request) => match request { @@ -137,15 +134,14 @@ async fn test_finish_request( } RollupRequest::Advance(advance_request) => { println!("Got new advance request: {:?}", advance_request); - assert_eq!(advance_request.payload.len(), 42); + assert_eq!(advance_request.payload.len(), 10); assert_eq!( advance_request.metadata.msg_sender, - "0x1111111111111111111111111111111111111111" + "0x0000000000000000000000000000000000000000" ); assert_eq!( - std::str::from_utf8(&hex::decode(&advance_request.payload[2..]).unwrap()) - .unwrap(), - "test advance request" + &advance_request.payload[2..], + "deadbeef" ); } }, @@ -160,11 +156,10 @@ async fn test_finish_request( RollupRequest::Inspect(inspect_request) => { println!("Got new inspect request: {:?}", inspect_request); context.server_handle.stop(true).await; - assert_eq!(inspect_request.payload.len(), 42); + assert_eq!(inspect_request.payload.len(), 10); assert_eq!( - std::str::from_utf8(&hex::decode(&inspect_request.payload[2..]).unwrap()) - .unwrap(), - "test inspect request" + &inspect_request.payload[2..], + "deadbeef" ); } RollupRequest::Advance(_advance_request) => { @@ -186,37 +181,46 @@ async fn test_finish_request( async fn test_write_voucher( context_future: impl Future, ) -> Result<(), Box> { + env::set_var("CMT_INPUTS", "0:advance.bin,1:inspect.bin"); + env::set_var("CMT_DEBUG", "yes"); + let context = context_future.await; println!("Writing voucher"); let test_voucher_01 = Voucher { destination: "0x1111111111111111111111111111111111111111".to_string(), + data: "0x".to_string() + &hex::encode("voucher test payload 02"), payload: "0x".to_string() + &hex::encode("voucher test payload 01"), }; let test_voucher_02 = Voucher { destination: "0x2222222222222222222222222222222222222222".to_string(), + data: "0x".to_string() + &hex::encode("voucher test payload 02"), payload: "0x".to_string() + &hex::encode("voucher test payload 02"), }; rollup_http_client::client::send_voucher(&context.address, test_voucher_01).await; + + let voucher1 = + std::fs::read("none.output-0.bin").expect("error reading voucher 1 file"); + assert_eq!( + voucher1, + [35, 122, 129, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 111, 117, 99, 104, 101, 114, 32, 116, 101, 115, 116, 32, 112, 97, 121, 108, 111, 97, 100, 32, 48, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 118, 111, 117, 99, 104, 101, 114, 32, 116, 101, 115, 116, 32, 112, 97, 121, 108, 111, 97, 100, 32, 48, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0] + ); + std::fs::remove_file("none.output-0.bin")?; + println!("Writing second voucher!"); + rollup_http_client::client::send_voucher(&context.address, test_voucher_02).await; context.server_handle.stop(true).await; //Read text file with results - let voucher1 = - std::fs::read_to_string("test_voucher_1.txt").expect("error reading voucher 1 file"); - assert_eq!( - voucher1, - "index: 1, payload_size: 23, payload: voucher test payload 01" - ); - std::fs::remove_file("test_voucher_1.txt")?; let voucher2 = - std::fs::read_to_string("test_voucher_2.txt").expect("error reading voucher 2 file"); - assert_eq!( - voucher2, - "index: 2, payload_size: 23, payload: voucher test payload 02" + std::fs::read("none.output-0.bin").expect("error reading voucher 2 file"); + assert_eq!( + voucher2, + [35, 122, 129, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 111, 117, 99, 104, 101, 114, 32, 116, 101, 115, 116, 32, 112, 97, 121, 108, 111, 97, 100, 32, 48, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 118, 111, 117, 99, 104, 101, 114, 32, 116, 101, 115, 116, 32, 112, 97, 121, 108, 111, 97, 100, 32, 48, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0] ); - std::fs::remove_file("test_voucher_2.txt")?; + + std::fs::remove_file("none.output-0.bin")?; Ok(()) } @@ -235,12 +239,12 @@ async fn test_write_notice( context.server_handle.stop(true).await; //Read text file with results let notice1 = - std::fs::read_to_string("test_notice_1.txt").expect("error reading test notice file"); - assert_eq!( - notice1, - "index: 1, payload_size: 22, payload: notice test payload 01" - ); - std::fs::remove_file("test_notice_1.txt")?; + std::fs::read("none.output-0.bin").expect("error reading test notice file"); + //assert_eq!( + // notice1, + // "index: 1, payload_size: 22, payload: notice test payload 01" + //); + std::fs::remove_file("none.output-0.bin")?; Ok(()) } @@ -259,12 +263,12 @@ async fn test_write_report( context.server_handle.stop(true).await; //Read text file with results let report1 = - std::fs::read_to_string("test_report_1.txt").expect("error reading test report file"); + std::fs::read_to_string("none.report-0.bin").expect("error reading test report file"); assert_eq!( report1, - "index: 1, payload_size: 22, payload: report test payload 01" + "report test payload 01" ); - std::fs::remove_file("test_report_1.txt")?; + std::fs::remove_file("none.report-0.bin")?; Ok(()) } @@ -286,12 +290,12 @@ async fn test_exception_throw( println!("Server closed"); //Read text file with results let exception = - std::fs::read_to_string("test_exception_1.txt").expect("error reading test exception file"); + std::fs::read("none.exception-0.bin").expect("error reading test exception file"); assert_eq!( exception, - "index: 1, payload_size: 25, payload: exception test payload 01" + vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ); println!("Removing exception text file"); - std::fs::remove_file("test_exception_1.txt")?; + std::fs::remove_file("none.exception-0.bin")?; Ok(()) } diff --git a/rollup-http/rollup-http-server/tests/rollup_test_bindings.c b/rollup-http/rollup-http-server/tests/rollup_test_bindings.c deleted file mode 100644 index 07e93eaa..00000000 --- a/rollup-http/rollup-http-server/tests/rollup_test_bindings.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright Cartesi and individual authors (see AUTHORS) - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "rollup_test_bindings.h" - -// Every uneven request is advance request, -// every even request is inspect request -static int request_test_counter = 0; -static int voucher_index_counter = 0; -static int notice_index_counter = 0; -static int report_index_counter = 0; -static int exception_index_counter = 0; - -static const char test_advance_request_str[] = "test advance request"; -static const size_t test_advance_request_str_size = sizeof(test_advance_request_str)-1; -static const char test_inspect_request_str[] = "test inspect request"; -static const size_t test_inspect_request_str_size = sizeof(test_inspect_request_str)-1; - -static const struct rollup_advance_state test_advance_request = { - .metadata = { - .msg_sender = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11}, - .block_number = 0, - .timestamp = 0, - .epoch_index = 0, - .input_index = 0 - }, - .payload = { - .data = test_advance_request_str, - .length = test_advance_request_str_size - } -}; - -static const struct rollup_inspect_state test_inspect_request = { - .payload = { - .data = test_inspect_request_str, - .length = test_inspect_request_str_size - } -}; - -static int resize_bytes(struct rollup_bytes *bytes, uint64_t size) { - if (bytes->length < size) { - uint8_t *new_data = (uint8_t *) realloc(bytes->data, size); - if (!new_data) { - return -1; - } - bytes->length = size; - bytes->data = new_data; - } - return 0; -} - -/* Finishes processing of current advance or inspect. - * Returns 0 on success, -1 on error */ -int rollup_finish_request(int fd, struct rollup_finish *finish, bool accept) { - int res = 0; - memset(finish, 0, sizeof(*finish)); - finish->accept_previous_request = accept; - request_test_counter += 1; - if (request_test_counter % 2 == 0) { - //test inspect request - finish->next_request_type = CARTESI_ROLLUP_INSPECT_STATE; - finish->next_request_payload_length = test_inspect_request.payload.length; - } else { - // test advance request - finish->next_request_type = CARTESI_ROLLUP_ADVANCE_STATE; - finish->next_request_payload_length = test_advance_request.payload.length; - } - - return res; -} - -/* Returns test advance state rollup request - * Returns 0 on success, -1 on error */ -int rollup_read_advance_state_request(int fd, struct rollup_finish *finish, - struct rollup_bytes *bytes, struct rollup_input_metadata *metadata) { - struct rollup_advance_state req; - int res = 0; - if (resize_bytes(bytes, finish->next_request_payload_length) != 0) { - fprintf(stderr, "Failed growing payload buffer\n"); - return -1; - } - memset(&req, 0, sizeof(req)); - // test advance request - *metadata = test_advance_request.metadata; - *bytes = test_advance_request.payload; - return res; -} - -/* Returns test inspect state rollup request - * Returns 0 on success, -1 on error */ -int rollup_read_inspect_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *query) { - struct rollup_inspect_state req; - int res = 0; - if (resize_bytes(query, finish->next_request_payload_length) != 0) { - fprintf(stderr, "Failed growing payload buffer\n"); - return -1; - } - memset(&req, 0, sizeof(req)); - *query = test_inspect_request.payload; - return 0; -} - -/* Outputs a new voucher to a file test_voucher_xx.txt in a text file - * voucher_index is filled with new index from the driver - * Returns 0 on success, -1 on error */ -int rollup_write_voucher(int fd, uint8_t destination[CARTESI_ROLLUP_ADDRESS_SIZE], struct rollup_bytes *bytes, - uint64_t *voucher_index) { - char filename[32] = {0}; - char destination_c[CARTESI_ROLLUP_ADDRESS_SIZE + 1] = {0}; - voucher_index_counter = voucher_index_counter + 1; - sprintf(filename, "test_voucher_%d.txt", voucher_index_counter); - FILE *f = fopen(filename, "w"); - if (f == NULL) { - return -1; - } - memcpy(destination_c, destination, CARTESI_ROLLUP_ADDRESS_SIZE); - fprintf(f, "index: %d, payload_size: %d, payload: ", voucher_index_counter, bytes->length); - for (int i = 0; i < bytes->length; i++) { - fputc(bytes->data[i], f); - } - fclose(f); - *voucher_index = voucher_index_counter; - return 0; -} - -/* Outputs a new notice to a file test_notice_xx.txt - * notice_index is filled with new index from the driver - * Returns 0 on success, -1 on error */ -int rollup_write_notice(int fd, struct rollup_bytes *bytes, uint64_t *notice_index) { - char filename[32] = {0}; - notice_index_counter = notice_index_counter + 1; - sprintf(filename, "test_notice_%d.txt", notice_index_counter); - FILE *f = fopen(filename, "w"); - if (f == NULL) { - return -1; - } - fprintf(f, "index: %d, payload_size: %d, payload: ", notice_index_counter, bytes->length); - for (int i = 0; i < bytes->length; i++) { - fputc(bytes->data[i], f); - } - fclose(f); - *notice_index = notice_index_counter; - return 0; -} - - -/* Outputs a new report to a file test_report_xx.txt - * Returns 0 on success, -1 on error */ -int rollup_write_report(int fd, struct rollup_bytes *bytes) { - char filename[32] = {0}; - report_index_counter = report_index_counter + 1; - sprintf(filename, "test_report_%d.txt", report_index_counter); - FILE *f = fopen(filename, "w"); - if (f == NULL) { - return -1; - } - fprintf(f, "index: %d, payload_size: %d, payload: ", report_index_counter, bytes->length); - for (int i = 0; i < bytes->length; i++) { - fputc(bytes->data[i], f); - } - fclose(f); - return 0; -} - -/* Outputs a dapp exception to a file test_exception_xx.txt - * Returns 0 on success, -1 on error */ -int rollup_throw_exception(int fd, struct rollup_bytes *bytes) { - char filename[32] = {0}; - exception_index_counter = exception_index_counter + 1; - sprintf(filename, "test_exception_%d.txt", exception_index_counter); - FILE *f = fopen(filename, "w"); - if (f == NULL) { - return -1; - } - fprintf(f, "index: %d, payload_size: %d, payload: ", exception_index_counter, bytes->length); - for (int i = 0; i < bytes->length; i++) { - fputc(bytes->data[i], f); - } - fclose(f); - return 0; -} - diff --git a/rollup-http/rollup-http-server/tests/rollup_test_bindings.h b/rollup-http/rollup-http-server/tests/rollup_test_bindings.h deleted file mode 100644 index 50a3e86a..00000000 --- a/rollup-http/rollup-http-server/tests/rollup_test_bindings.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright Cartesi and individual authors (see AUTHORS) - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef _UAPI_LINUX_CARTESI_ROLLUP_H -#define _UAPI_LINUX_CARTESI_ROLLUP_H - -#include -#include -#include -#include -#include -#include -#include - - -#define CARTESI_ROLLUP_ADVANCE_STATE 0 -#define CARTESI_ROLLUP_INSPECT_STATE 1 - -#define CARTESI_ROLLUP_ADDRESS_SIZE 20 - -struct rollup_bytes { - unsigned char *data; - uint64_t length; -}; - -struct rollup_input_metadata { - uint8_t msg_sender[CARTESI_ROLLUP_ADDRESS_SIZE]; - uint64_t block_number; - uint64_t timestamp; - uint64_t epoch_index; - uint64_t input_index; -}; - -struct rollup_advance_state { - struct rollup_input_metadata metadata; - struct rollup_bytes payload; -}; - -struct rollup_inspect_state { - struct rollup_bytes payload; -}; - -struct rollup_finish { - /* True if previous request should be accepted */ - /* False if previous request should be rejected */ - bool accept_previous_request; - - int next_request_type; /* either CARTESI_ROLLUP_ADVANCE or CARTESI_ROLLUP_INSPECT */ - int next_request_payload_length; -}; - -struct rollup_voucher { - uint8_t destination[CARTESI_ROLLUP_ADDRESS_SIZE]; - struct rollup_bytes payload; - uint64_t index; -}; - -struct rollup_notice { - struct rollup_bytes payload; - uint64_t index; -}; - -struct rollup_report { - struct rollup_bytes payload; -}; - -struct rollup_exception { - struct rollup_bytes payload; -}; - -/* Finishes processing of current advance or inspect. - * Returns only when next advance input or inspect query is ready. - * How: - * Yields manual with rx-accepted if accept is true and yields manual with rx-rejected if accept is false. - * Once yield returns, checks the data field in fromhost to decide if next request is advance or inspect. - * Returns type and payload length of next request in struct - * Returns 0 */ -#define IOCTL_ROLLUP_FINISH _IOWR(0xd3, 0, struct rollup_finish) - -/* Obtains arguments to advance state - * How: - * Reads from input metadat memory range and convert data. - * Reads from rx buffer and copy to payload - * Returns 0 */ -#define IOCTL_ROLLUP_READ_ADVANCE_STATE _IOWR(0xd3, 0, struct rollup_advance_state) - -/* Obtains arguments to inspect state - * How: - * Reads from rx buffer and copy to payload - * Returns 0 */ -#define IOCTL_ROLLUP_READ_INSPECT_STATE _IOWR(0xd3, 0, struct rollup_inspect_state) - -/* Outputs a new voucher. - * How: Computes the Keccak-256 hash of address+payload and then, atomically: - * - Copies the (address+be32(0x40)+be32(payload_length)+payload) to the tx buffer - * - Copies the hash to the next available slot in the voucher-hashes memory range - * - Yields automatic with tx-voucher - * - Fills in the index field with the corresponding slot from voucher-hashes - * Returns 0 */ -#define IOCTL_ROLLUP_WRITE_VOUCHER _IOWR(0xd3, 1, struct rollup_voucher) - -/* Outputs a new notice. - * How: Computes the Keccak-256 hash of payload and then, atomically: - * - Copies the (be32(0x20)+be32(payload_length)+payload) to the tx buffer - * - Copies the hash to the next available slot in the notice-hashes memory range - * - Yields automatic with tx-notice - * - Fills in the index field with the corresponding slot from notice-hashes - * Returns 0 */ -#define IOCTL_ROLLUP_WRITE_NOTICE _IOWR(0xd3, 2, struct rollup_notice) - -/* Outputs a new report. - * - Copies the (be32(0x20)+be32(payload_length)+payload) to the tx buffer - * - Yields automatic with tx-report - * Returns 0 */ -#define IOCTL_ROLLUP_WRITE_REPORT _IOWR(0xd3, 3, struct rollup_report) - -/* Throws an exeption. - * - Copies the (be32(0x20)+be32(payload_length)+payload) to the tx buffer - * - Yields manual with tx-exception - * Returns 0 */ -#define IOCTL_ROLLUP_THROW_EXCEPTION _IOWR(0xd3, 4, struct rollup_exception) -#endif - - -int rollup_finish_request(int fd, struct rollup_finish *finish, bool accept); -int rollup_read_advance_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *bytes, struct rollup_input_metadata *metadata); -int rollup_read_inspect_state_request(int fd, struct rollup_finish *finish, struct rollup_bytes *query); -int rollup_write_voucher(int fd, uint8_t address[CARTESI_ROLLUP_ADDRESS_SIZE], struct rollup_bytes *bytes, uint64_t* voucher_index); -int rollup_write_notice(int fd, struct rollup_bytes *bytes, uint64_t* notice_index); -int rollup_write_report(int fd, struct rollup_bytes *bytes); -int rollup_throw_exception(int fd, struct rollup_bytes *bytes); diff --git a/sys-utils/Makefile b/sys-utils/Makefile index 510b60c2..327a0549 100644 --- a/sys-utils/Makefile +++ b/sys-utils/Makefile @@ -23,8 +23,8 @@ all: $(UTILITIES) $(UTILITIES): @$(MAKE) -C $@ -with-toolchain: - @$(MAKE) $(UTILITIES_WITH_TOOLCHAIN) +with-toolchain: + @$(MAKE) $(UTILITIES_WITH_TOOLCHAIN) $(UTILITIES_WITH_TOOLCHAIN): @$(MAKE) -C $@ with-toolchain diff --git a/sys-utils/cartesi-init/cartesi-init b/sys-utils/cartesi-init/cartesi-init index c787e036..ac160ffd 100755 --- a/sys-utils/cartesi-init/cartesi-init +++ b/sys-utils/cartesi-init/cartesi-init @@ -36,13 +36,10 @@ if [ -n "$ENTRYPOINT" ]; then HOME=$(eval echo ~$USER) WORKDIR=${WORKDIR:-"$HOME"} - # give user group access to rollup and yield devices - [ -c /dev/rollup ] && \ - busybox chown :$(busybox id -g $USER) /dev/rollup && \ - busybox chmod g+rw /dev/rollup - [ -c /dev/yield ] && - busybox chown :$(busybox id -g $USER) /dev/yield && \ - busybox chmod g+rw /dev/yield + # give user group access to cmio device + [ -c /dev/cmio ] && \ + busybox chown :$(busybox id -g $USER) /dev/cmio && \ + busybox chmod g+rw /dev/cmio # execute entrypoint (cd $WORKDIR && diff --git a/sys-utils/ioctl-echo-loop/Makefile b/sys-utils/ioctl-echo-loop/Makefile index be73ff91..7f03a8ca 100644 --- a/sys-utils/ioctl-echo-loop/Makefile +++ b/sys-utils/ioctl-echo-loop/Makefile @@ -22,14 +22,14 @@ RISCV_ARCH ?= rv64gc RISCV_ABI ?= lp64d TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu- -TOOLCHAIN_SUFFIX ?= -RVCC = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX) -RVCXX = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX) -RVCOPY = $(TOOLCHAIN_PREFIX)objcopy$(TOOLCHAIN_SUFFIX) -RVDUMP = $(TOOLCHAIN_PREFIX)objdump$(TOOLCHAIN_SUFFIX) +RVCC = $(TOOLCHAIN_PREFIX)gcc +RVCXX = $(TOOLCHAIN_PREFIX)g++ +RVCOPY = $(TOOLCHAIN_PREFIX)objcopy +RVDUMP = $(TOOLCHAIN_PREFIX)objdump STRIP = $(TOOLCHAIN_PREFIX)strip -CFLAGS :=-Wall -pedantic -O2 -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) +CFLAGS +=-Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt` +LDLIBS += `pkg-config --libs libcmt` CONTAINER_MAKE := /usr/bin/make CONTAINER_BASE := /opt/cartesi/tools @@ -43,8 +43,9 @@ ioctl-echo-loop.with-toolchain with-toolchain: extra.ext2.with-toolchain: $(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain" +ioctl-echo-loop: export PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig ioctl-echo-loop: ioctl-echo-loop.c - $(RVCC) $(CFLAGS) -o ioctl-echo-loop ioctl-echo-loop.c + $(RVCC) $(CFLAGS) -o ioctl-echo-loop ioctl-echo-loop.c $(LDLIBS) $(STRIP) ioctl-echo-loop extra.ext2: ioctl-echo-loop diff --git a/sys-utils/ioctl-echo-loop/ioctl-echo-loop.c b/sys-utils/ioctl-echo-loop/ioctl-echo-loop.c index af3f38ce..2b3d206e 100644 --- a/sys-utils/ioctl-echo-loop/ioctl-echo-loop.c +++ b/sys-utils/ioctl-echo-loop/ioctl-echo-loop.c @@ -24,17 +24,7 @@ #include #include -#include - -#define ROLLUP_DEVICE_NAME "/dev/rollup" - -static void show_finish(struct rollup_finish *finish); -static void show_advance(struct rollup_advance_state *advance); -static void show_inspect(struct rollup_inspect_state *inspect); -static void show_voucher(struct rollup_voucher *voucher); -static void show_notice(struct rollup_notice *notice); -static void show_report(struct rollup_report *report); -static void show_exception(struct rollup_exception *exception); +#include "libcmt/rollup.h" static void help(const char *progname) { fprintf(stderr, @@ -97,160 +87,70 @@ static void parse_args(int argc, char *argv[], struct parsed_args *args) { } } -static int finish_request(int fd, struct rollup_finish *finish, bool accept) { - int res = 0; - memset(finish, 0, sizeof(*finish)); +static int finish_request(cmt_rollup_t *me, cmt_rollup_finish_t *finish, bool accept) { finish->accept_previous_request = accept; - res = ioctl(fd, IOCTL_ROLLUP_FINISH, (unsigned long) finish); - if (res != 0) { - int code = errno; - fprintf(stderr, "IOCTL_ROLLUP_FINISH returned error %s [%d]\n", strerror(code), code); - } - return res; + return cmt_rollup_finish(me, finish); } -static int resize_bytes(struct rollup_bytes *bytes, uint64_t size) { - if (bytes->length < size) { - uint8_t *new_data = (uint8_t *) realloc(bytes->data, size); - if (!new_data) { - return -1; - } - bytes->length = size; - bytes->data = new_data; - } - return 0; -} - -static int write_notices(int fd, unsigned count, struct rollup_bytes *bytes, unsigned verbose) { - struct rollup_notice n; - memset(&n, 0, sizeof(n)); - n.payload = *bytes; +static int write_notices(cmt_rollup_t *me, unsigned count, uint32_t length, const void *data) { for (unsigned i = 0; i < count; i++) { - int res = ioctl(fd, IOCTL_ROLLUP_WRITE_NOTICE, (unsigned long) &n); - if (res != 0) { - fprintf(stderr, "IOCTL_ROLLUP_WRITE_NOTICE returned error %d\n", res); - return res; - } - if (verbose) - show_notice(&n); + int rc = cmt_rollup_emit_notice(me, length, data); + if (rc) return rc; } return 0; } -static int write_vouchers(int fd, unsigned count, struct rollup_bytes *bytes, uint8_t *destination, unsigned verbose) { - struct rollup_voucher v; - memset(&v, 0, sizeof(v)); - v.payload = *bytes; - memcpy(v.destination, destination, sizeof(v.destination)); +static int write_vouchers(cmt_rollup_t *me, unsigned count, uint8_t destination[CMT_ADDRESS_LENGTH] + ,uint32_t length, const void *data) { for (unsigned i = 0; i < count; i++) { - int res = ioctl(fd, IOCTL_ROLLUP_WRITE_VOUCHER, (unsigned long) &v); - if (res != 0) { - int code = errno; - fprintf(stderr, "IOCTL_ROLLUP_WRITE_VOUCHER returned error %s [%d]\n", strerror(code), code); - return res; - } - if (verbose) - show_voucher(&v); + int rc = cmt_rollup_emit_voucher(me, CMT_ADDRESS_LENGTH, destination, 0, NULL, length, data); + if (rc) return rc; } return 0; } -static int write_reports(int fd, unsigned count, struct rollup_bytes *bytes, unsigned verbose) { - struct rollup_report r; - memset(&r, 0, sizeof(r)); - r.payload = *bytes; - if (verbose) - show_report(&r); +static int write_reports(cmt_rollup_t *me, unsigned count, uint32_t length, const void *data) { for (unsigned i = 0; i < count; i++) { - int res = ioctl(fd, IOCTL_ROLLUP_WRITE_REPORT, (unsigned long) &r); - if (res != 0) { - int code = errno; - fprintf(stderr, "IOCTL_ROLLUP_WRITE_REPORT returned error %s [%d]\n", strerror(code), code); - return res; - } + int rc = cmt_rollup_emit_report(me, length, data); + if (rc) return rc; } return 0; } -static int write_exception(int fd, struct rollup_bytes *bytes, unsigned verbose) { - struct rollup_exception e; - memset(&e, 0, sizeof(e)); - e.payload = *bytes; - if (verbose) - show_exception(&e); - int res = ioctl(fd, IOCTL_ROLLUP_THROW_EXCEPTION, (unsigned long) &e); - if (res != 0) { - int code = errno; - fprintf(stderr, "IOCTL_ROLLUP_THROW_EXCEPTION returned error %s [%d]\n", strerror(code), code); - return res; - } - return 0; -} +static int handle_advance_state_request(cmt_rollup_t *me, struct parsed_args *args) { + cmt_rollup_advance_t advance; + int rc = cmt_rollup_read_advance_state(me, &advance); + if (rc) return rc; -static int handle_advance_state_request(int fd, struct parsed_args *args, struct rollup_finish *finish, - struct rollup_bytes *bytes, struct rollup_input_metadata *metadata) { - struct rollup_advance_state req; - int res = 0; - if (resize_bytes(bytes, finish->next_request_payload_length) != 0) { - fprintf(stderr, "Failed growing payload buffer\n"); + if (write_vouchers(me, args->voucher_count, advance.sender, advance.length, advance.data) != 0) { return -1; } - memset(&req, 0, sizeof(req)); - req.payload.data = bytes->data; - req.payload.length = finish->next_request_payload_length; - res = ioctl(fd, IOCTL_ROLLUP_READ_ADVANCE_STATE, (unsigned long) &req); - if (res != 0) { - int code = errno; - fprintf(stderr, "IOCTL_ROLLUP_READ_ADVANCE_STATE returned error %s [%d]\n", strerror(code), code); - return res; - } - *metadata = req.metadata; - if (args->verbose) - show_advance(&req); - if (write_vouchers(fd, args->voucher_count, &req.payload, req.metadata.msg_sender, args->verbose) != 0) { + if (write_notices(me, args->notice_count, advance.length, advance.data) != 0) { return -1; } - if (write_notices(fd, args->notice_count, &req.payload, args->verbose) != 0) { - return -1; - } - if (write_reports(fd, args->report_count, &req.payload, args->verbose) != 0) { + if (write_reports(me, args->report_count, advance.length, advance.data) != 0) { return -1; } return 0; } -static int handle_inspect_state_request(int fd, struct parsed_args *args, struct rollup_finish *finish, - struct rollup_bytes *bytes) { - struct rollup_inspect_state req; - int res = 0; - if (resize_bytes(bytes, finish->next_request_payload_length) != 0) { - fprintf(stderr, "Failed growing payload buffer\n"); - return -1; - } - memset(&req, 0, sizeof(req)); - req.payload.data = bytes->data; - req.payload.length = finish->next_request_payload_length; - if (args->verbose) - show_inspect(&req); - res = ioctl(fd, IOCTL_ROLLUP_READ_INSPECT_STATE, (unsigned long) &req); - if (res != 0) { - int code = errno; - fprintf(stderr, "IOCTL_ROLLUP_READ_INSPECT_STATE returned error %s [%d]\n", strerror(code), code); - return res; - } - if (write_reports(fd, args->report_count, &req.payload, args->verbose) != 0) { +static int handle_inspect_state_request(cmt_rollup_t *me, struct parsed_args *args) { + cmt_rollup_inspect_t inspect; + int rc = cmt_rollup_read_inspect_state(me, &inspect); + if (rc) return rc; + + if (write_reports(me, args->report_count, inspect.length, inspect.data) != 0) { return -1; } return 0; } -static int handle_request(int fd, struct parsed_args *args, struct rollup_finish *finish, struct rollup_bytes *bytes, - struct rollup_input_metadata *metadata) { +static int handle_request(cmt_rollup_t *me, struct parsed_args *args, cmt_rollup_finish_t *finish) { switch (finish->next_request_type) { - case CARTESI_ROLLUP_ADVANCE_STATE: - return handle_advance_state_request(fd, args, finish, bytes, metadata); - case CARTESI_ROLLUP_INSPECT_STATE: - return handle_inspect_state_request(fd, args, finish, bytes); + case CMT_IO_REASON_ADVANCE: + return handle_advance_state_request(me, args); + case CMT_IO_REASON_INSPECT: + return handle_inspect_state_request(me, args); default: /* unknown request type */ fprintf(stderr, "Unknown request type %d\n", finish->next_request_type); @@ -260,129 +160,44 @@ static int handle_request(int fd, struct parsed_args *args, struct rollup_finish } int main(int argc, char *argv[]) { - struct rollup_input_metadata metadata; - struct rollup_finish finish; - struct parsed_args args; - struct rollup_bytes bytes; - int fd; + unsigned input_index = 0; + cmt_rollup_t rollup; + if (cmt_rollup_init(&rollup)) + return EXIT_FAILURE; - memset(&metadata, 0, sizeof(metadata)); + struct parsed_args args; parse_args(argc, argv, &args); - fd = open(ROLLUP_DEVICE_NAME, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Error opening device " ROLLUP_DEVICE_NAME "\n"); - return fd; - } - fprintf(stderr, "Echoing as %d voucher copies, %d notice copies, and %d report copies\n", args.voucher_count, args.notice_count, args.report_count); - memset(&bytes, 0, sizeof(bytes)); - /* Accept the initial request */ - if (finish_request(fd, &finish, true) != 0) { + cmt_rollup_finish_t finish; + if (finish_request(&rollup, &finish, true) != 0) { exit(1); - } else if (args.verbose) { - show_finish(&finish); } /* handle a request, then wait for next */ for (;;) { bool reject_advance, reject_inspect, throw_exception; - if (handle_request(fd, &args, &finish, &bytes, &metadata) != 0) { + if (handle_request(&rollup, &args, &finish) != 0) { break; } reject_advance = - (finish.next_request_type == CARTESI_ROLLUP_ADVANCE_STATE) && (args.reject == metadata.input_index); - reject_inspect = (finish.next_request_type == CARTESI_ROLLUP_INSPECT_STATE) && args.reject_inspects; + (finish.next_request_type == CMT_IO_REASON_ADVANCE) && (args.reject == input_index); + reject_inspect = (finish.next_request_type == CMT_IO_REASON_INSPECT) && args.reject_inspects; throw_exception = - (finish.next_request_type == CARTESI_ROLLUP_ADVANCE_STATE) && (args.exception == metadata.input_index); + (finish.next_request_type == CMT_IO_REASON_ADVANCE) && (args.exception == input_index); if (throw_exception) { - write_exception(fd, &bytes, args.verbose); + const char message[] = "exception"; + cmt_rollup_emit_exception(&rollup, sizeof message -1, message); } - if (finish_request(fd, &finish, !(reject_advance || reject_inspect)) != 0) { + if (finish_request(&rollup, &finish, !(reject_advance || reject_inspect)) != 0) { break; - } else if (args.verbose) { - show_finish(&finish); } } - close(fd); - + cmt_rollup_fini(&rollup); fprintf(stderr, "Exiting...\n"); - return 0; } - -static void print_address(uint8_t *address) { - for (int i = 0; i < CARTESI_ROLLUP_ADDRESS_SIZE; i += 4) { - for (int j = 0; j < 4; ++j) { - printf("%02x", address[i + j]); - } - printf("%s", i == CARTESI_ROLLUP_ADDRESS_SIZE - 4 ? "\n" : " "); - } -} - -static void show_finish(struct rollup_finish *finish) { - const char *type = "unknown"; - switch (finish->next_request_type) { - case CARTESI_ROLLUP_ADVANCE_STATE: - type = "advance"; - break; - case CARTESI_ROLLUP_INSPECT_STATE: - type = "inspect"; - break; - } - printf("finish:\n" - "\taccept: %s\n" - "\ttype: %s\n" - "\tlength: %d\n", - finish->accept_previous_request ? "yes" : "no", type, finish->next_request_payload_length); -} - -static void show_advance(struct rollup_advance_state *advance) { - printf("advance:\n" - "\tmsg_sender: "); - print_address(advance->metadata.msg_sender); - printf("\tblock_number: %llu\n" - "\ttimestamp: %llu\n" - "\tepoch_index: %llu\n" - "\tinput_index: %llu\n", - advance->metadata.block_number, advance->metadata.timestamp, advance->metadata.epoch_index, - advance->metadata.input_index); -} - -static void show_inspect(struct rollup_inspect_state *inspect) { - printf("inspect:\n" - "\tlength: %llu\n", - inspect->payload.length); -} - -static void show_voucher(struct rollup_voucher *voucher) { - printf("voucher:\n" - "\tindex: %llu\n" - "\tlength: %llu\n" - "\tdestination: ", - voucher->index, voucher->payload.length); - print_address(voucher->destination); -} - -static void show_notice(struct rollup_notice *notice) { - printf("notice:\n" - "\tindex: %llu\n" - "\tlength: %llu\n", - notice->index, notice->payload.length); -} - -static void show_report(struct rollup_report *report) { - printf("report:\n" - "\tlength: %llu\n", - report->payload.length); -} - -static void show_exception(struct rollup_exception *exception) { - printf("exception:\n" - "\tlength: %llu\n", - exception->payload.length); -} diff --git a/sys-utils/libcmt/Makefile b/sys-utils/libcmt/Makefile new file mode 100644 index 00000000..969aea88 --- /dev/null +++ b/sys-utils/libcmt/Makefile @@ -0,0 +1,197 @@ +# paths +PREFIX = /usr +TARGET_PREFIX ?= $(PREFIX) + +TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- +TARGET_CC := $(TOOLCHAIN_PREFIX)gcc +TARGET_AR := $(TOOLCHAIN_PREFIX)ar +TARGET_CFLAGS := -Wvla -O2 -g -Wall -pedantic -Wextra -Iinclude +CFLAGS := -Wvla -O2 -g -Wall -pedantic -Wextra -Iinclude + +ALL := ioctl.build mock.build tools.build doc.build test.run +all: $(ALL) + +#------------------------------------------------------------------------------- +examples_SRC := \ + doc/examples/abi_encode_000.c \ + doc/examples/abi_encode_001.c \ + doc/examples/abi_encode_002.c \ + doc/examples/abi_decode_000.c \ + doc/examples/abi_decode_001.c \ + doc/examples/abi_decode_002.c \ + doc/examples/io.c \ + doc/examples/rollup.c + +examples_OBJDIR := .build/examples/ +examples_OBJ := $(patsubst %.c,$(examples_OBJDIR)%.o,$(examples_SRC)) + +$(examples_OBJ): $(examples_OBJDIR)%.o: %.c + @mkdir -p $(@D) + $(CC) $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +# no need to link, just ensure examples build correctly +examples.build: $(examples_OBJ) + +#------------------------------------------------------------------------------- +ioctl_SRC := \ + src/buf.c \ + src/abi.c \ + src/keccak.c \ + src/merkle.c \ + src/merkle-table.c \ + src/rollup.c \ + src/ioctl/io.c + +ioctl_OBJDIR := build/ioctl/ +ioctl_OBJ := $(patsubst %.c,$(ioctl_OBJDIR)%.o,$(ioctl_SRC)) +ioctl_LIB := $(ioctl_OBJDIR)libcmt.a + +$(ioctl_OBJ): $(ioctl_OBJDIR)%.o: %.c + @mkdir -p $(@D) + $(TARGET_CC) $(TARGET_CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +$(ioctl_LIB): $(ioctl_OBJ) + $(TARGET_AR) rcs $@ $^ + +$(ioctl_OBJDIR)io_echo: src/tests/io_echo.c $(ioctl_LIB) + $(TARGET_CC) $(TARGET_CFLAGS) -o $@ $^ + +$(ioctl_OBJDIR)rollup_echo: src/tests/rollup_echo.c $(ioctl_LIB) + $(TARGET_CC) $(TARGET_CFLAGS) -o $@ $^ + +ioctl.build: $(ioctl_LIB) $(ioctl_OBJDIR)io_echo $(ioctl_OBJDIR)rollup_echo +ioctl.install: $(ioctl_LIB) + mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + cp -f $< $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ + cp -f include/libcmt/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ + mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig + sed \ + -e 's|@ARG_PREFIX@|$(TARGET_PREFIX)|g' \ + tools/templates/libcmt.pc > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc + +#------------------------------------------------------------------------------- +mock_SRC := \ + src/abi.c \ + src/buf.c \ + src/keccak.c \ + src/merkle.c \ + src/merkle-table.c \ + src/rollup.c \ + src/mock/io.c + +mock_OBJDIR := build/mock/ +mock_OBJ := $(patsubst %.c,$(mock_OBJDIR)%.o,$(mock_SRC)) +mock_LIB := $(mock_OBJDIR)libcmt.a + +$(mock_OBJ): $(mock_OBJDIR)%.o: %.c + @mkdir -p $(@D) + $(CC) $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +$(mock_LIB): $(mock_OBJ) + $(AR) rcs $@ $^ + +$(mock_OBJDIR)io_echo: src/tests/io_echo.c $(mock_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +$(mock_OBJDIR)rollup_echo: src/tests/rollup_echo.c $(mock_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +mock.build: $(mock_LIB) $(mock_OBJDIR)io_echo $(mock_OBJDIR)rollup_echo + +mock.install: $(mock_LIB) + mkdir -p $(DESTDIR)$(PREFIX)/lib + cp -f $< $(DESTDIR)$(PREFIX)/lib + mkdir -p $(DESTDIR)$(PREFIX)/include/libcmt/mock + cp -f include/libcmt/*.h $(DESTDIR)$(PREFIX)/include/libcmt/ + mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig + sed \ + -e 's|@ARG_PREFIX@|$(PREFIX)|g' \ + tools/templates/libcmt_mock.pc > $(DESTDIR)$(PREFIX)/lib/pkgconfig/libcmt.pc + +#------------------------------------------------------------------------------- +testdata: + cast calldata "EvmAdvance(address,uint256,uint256,uint256,bytes)" \ + `cast address-zero` 1 2 3 0xdeadbeef | xxd -r -p > dat/C.bin + cast calldata "Voucher(address,bytes)" \ + `cast address-zero` 0xdeadbeef | xxd -r -p > dat/C.v0.bin + cast calldata "Notice(bytes)" \ + 0xdeadbeef | xxd -r -p > dat/C.n0.bin + xxd -n advance -i dat/C.bin > dat/C.h + xxd -n voucher -i dat/C.v0.bin > dat/C.v0.h + xxd -n notice -i dat/C.n0.bin > dat/C.n0.h + +unittests_BINS := \ + $(mock_OBJDIR)abi-multi \ + $(mock_OBJDIR)abi-single \ + $(mock_OBJDIR)keccak \ + $(mock_OBJDIR)merkle \ + +$(mock_OBJDIR)abi-multi: src/tests/abi-multi.c $(mock_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +$(mock_OBJDIR)abi-single: src/tests/abi-single.c $(mock_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +$(mock_OBJDIR)keccak: src/tests/keccak.c $(mock_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +$(mock_OBJDIR)merkle: src/tests/merkle.c $(mock_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +test.build: $(unittests_BINS) $(mock_OBJDIR)io_echo +test.run: test.build + $(foreach test,$(unittests_BINS),$(test) &&) true + +#------------------------------------------------------------------------------- +tools_OBJDIR := build/tools/ + +tools_BINS := \ + $(tools_OBJDIR)funsel \ + $(tools_OBJDIR)merkle-table + +$(tools_OBJDIR)funsel: src/tools/funsel.c $(mock_LIB) + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ $^ + +$(tools_OBJDIR)merkle-table: src/tools/merkle-table.c src/keccak.c + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ $^ + +# generated source code +src/merkle.c: src/merkle-table.c +src/merkle-table.c: $(tools_OBJDIR)merkle-table + $< > $@ + +tools.build: $(tools_BINS) + +#------------------------------------------------------------------------------- + +help: + @echo "Targets: (default: '*')" + @echo "* all - $(ALL)" + @echo " mock.build - Build a mocked version of the library, tools and examples; to run on the host system." + @echo " mock.install - Install the mocked version of the library and C headers; on the host system." + @echo " Use DESTDIR and PREFIX to customize the installation." + @echo " ioctl.build - Build the library, tools and examples; to run on the cartesi-machine." + @echo " (requires the cartesi Linux headers to build)" + @echo " ioctl.install - Install the library and C headers; on the host system." + @echo " Use TARGET_DESTDIR and TARGET_PREFIX to customize the installation." + @echo " test.build - Build tests on top of the mocked library to run on the host system." + @echo " test.run - Execute the tests." + @echo " tools.build - Build tools on top of the mocked library to run on the host system." + @echo " doc.build - Build the documentation and API references as html." + @echo " clean - remove the binaries and objects." + +doc/theme: + git clone git@github.com:jothepro/doxygen-awesome-css.git $@ + git -C doc/theme checkout 8cea9a073ecd50a5b2c0958a3df100292d6c7374 + +doc.build: doc/theme examples.build + doxygen doc/Doxyfile + +OBJ := $(mock_OBJ) $(ioctl_OBJ) $(examples_OBJ) $(tools_OBJ) +clean: + rm -rf $(OBJ) $(unittests_BINS) $(tools_BINS) libcmt_mock.a libcmt.a + +-include $(OBJ:%.o=%.d) diff --git a/sys-utils/libcmt/README.md b/sys-utils/libcmt/README.md new file mode 100644 index 00000000..582db807 --- /dev/null +++ b/sys-utils/libcmt/README.md @@ -0,0 +1,247 @@ +This is a C library to facilitate the development of applications running on the cartesi-machine. +It handles the IO and communication protocol with the machine-emulator. + +The high level @ref libcmt\_rollup API provides functions for common operations, such as generating vouchers, notices, retrieving the next input, etc. +Check the [cartesi documentation](https://docs.cartesi.io/) for an explanation of the rollup interaction model. + +In addition to the above mentioned module, we provide @ref libcmt\_io\_driver, a thin abstraction of the linux kernel driver. + +And finally, a couple of utility modules used by the high level API are also exposed. +- @ref libcmt\_abi is a Ethereum Virtual Machine Application Binary Interface (EVM-ABI) encoder / decoder. +- @ref libcmt\_buf is a bounds checking buffer. +- @ref libcmt\_merkle is a sparse merkle tree implementation on top of keccak. +- @ref libcmt\_keccak is the hashing function used extensively by Ethereum. + +The header files and a compiled RISC-V version of this library can be found [here](https://github.com/cartesi/machine-emulator-tools/). +We also provide `.pc` (pkg-config) files to facilitate linking. + +# mock and testing + +This library provides a mock implementation of @ref libcmt\_io\_driver that is +able to simulate requests and replies on the host machine. + +- Build it with: `make mock.build`. +- Install it with: `make mock.install`, use `PREFIX` to specify the installation path: + (The command below will install the library and headers on `$PWD/_install` directory) +``` +make mock.install PREFIX=_install +``` + +## testing + +Use the environment variable @p CMT\_INPUTS to inject inputs into the application compiled with the mock. +Outputs will be written to files with names derived from the input name. + +example: +``` +CMT_INPUTS="0:advance.bin" ./application +``` + +The first output will generate the file: +``` +advance.output-0.bin +``` + +The first report will generate the file: +``` +advance.report-0.bin +``` + +The first exception will generate the file: +``` +advance.exception-0.bin +``` + +The (verifiable) outputs root hash: +``` +advance.outputs_root_hash.bin +``` + +inputs must follow this syntax, a comma separated list of reason number followed by a filepath: +``` +CMT_INPUTS=" ':' ( ',' ':' ) *" +``` + +In addition to @p CMT\_INPUTS, there is also the @p CMT\_DEBUG variable. Enable it +for a verbose version of the low level calls. + +``` +CMT_DEBUG=yes ./application +``` + +## generating inputs + +Inputs and Outputs are expected to be EVM-ABI encoded. Encoding and decoding +can be acheived multiple ways, including writing tools with this library. A +simple way to generate testing data is to use the @p cast tool from +[foundry](http://book.getfoundry.sh/reference/cast/cast.html) and `xxd`. + +Encoding an @p EvmAdvance: +``` +cast calldata "EvmAdvance(address,uint256,uint256,uint256,bytes)" \ + 0x0000000000000000000000000000000000000000 \ + 0x0000000000000000000000000000000000000000 \ + 0x0000000000000000000000000000000000000000 \ + 0x0000000000000000000000000000000000000000 \ + 0x`echo "advance-0" | xxd -p -c0` | xxd -r -p > 0.bin +``` + +Encoding an @p EvmInspect: +``` +cast calldata "EvmInspect(bytes)" \ + 0x`echo "inspect-0" | xxd -p -c0` | xxd -r -p > 1.bin +``` + +## parsing outputs + +Decoding a @p Voucher: +``` +cast calldata-decode "Voucher(address,uint256,bytes)" 0x`xxd -p -c0 "$1"` | ( + read address + read value + read bytes + + echo "{" + printf '\t"address" : "%s",\n' $address + printf '\t"value" : "%s",\n' $value + printf '\t"bytes" : "%s"\n' $bytes + echo "}" +) + +# sh decode-voucher.sh $1 | jq '.bytes' | xxd -r +``` + +Decoding a @p Notice: +``` +cast calldata-decode "Notice(bytes)" 0x`xxd -p -c0 "$1"` | ( + read bytes + + echo "{" + printf '\t"bytes" : "%s"\n' $bytes + echo "}" +) + +# sh decode-notice.sh $1 | jq '.bytes' | xxd -r +``` + +# binds + +This library is intented to be used with programming languages other than C. +They acheive this by different means. + +## Go + +Go is able to include C headers directly. + +The application can be compiled with: `go build main.go`. Assuming that the +mock was installed at `./libcmt-0.1.0`. +(Code below is for demonstration purposes and not intended for production) + +``` +package main + +/* +#cgo CFLAGS: -Ilibcmt-0.1.0/include/ +#cgo LDFLAGS: -Llibcmt-0.1.0/lib/ -lcmt + +#include "libcmt/rollup.h" +*/ +import "C" + +import ( + "math/big" + "fmt" + "unsafe" +) + +func main() { + var rollup C.cmt_rollup_t + err := C.cmt_rollup_init(&rollup) + if err != 0 { + fmt.Printf("initialization failed\n") + } + + bytes_s := []byte{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + } + wei := new(big.Int).SetBytes(bytes_s) + + finish := C.cmt_rollup_finish_t{ + accept_previous_request: true, + } + for { + var advance C.cmt_rollup_advance_t + err = C.cmt_rollup_finish(&rollup, &finish) + if err != 0 { return; } + + err = C.cmt_rollup_read_advance_state(&rollup, &advance); + if err != 0 { return; } + + bytes:= wei.Bytes() + size := len(bytes) + C.cmt_rollup_emit_voucher(&rollup, + C.CMT_ADDRESS_LENGTH, &advance.sender[0], + C.uint(size), unsafe.Pointer(&bytes[0]), + advance.length, advance.data) + C.cmt_rollup_emit_report(&rollup, advance.length, advance.data) + } +} +``` + +## Rust + +Rust interop with C requires bindings to be generated, we'll use bindgen to +accomplish this. + +Create the initial directory layout with `cargo`, then add the library to it: +``` +cargo init --bin cmt +# download the library and extract it into cmt/libcmt-0.1.0 +cd cmt +``` + +Generate the bindings, execute: +``` +# join all header files into one. +cat libcmt-0.1.0/include/libcmt/*.h > src/libcmt.h + +# generate the bindings +bindgen src/libcmt.h -o src/bindings.rs --allowlist-function '^cmt_.*' --allowlist-type '^cmt_.*' --no-doc-comments -- -I libcmt-0.1.0/include/libcmt +``` + +Include the bindings to the project, add the following to: `src/lib.rs` +``` +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!("bindings.rs"); +``` + +Tell cargo to link with the C library, add the following to: `build.rs` +``` +fn main() { + println!("cargo:rustc-link-search=libcmt-0.1.0/lib"); + println!("cargo:rustc-link-lib=cmt"); +} +``` + +An example of the raw calls to C, add the following to: `src/main.rs` +``` +use std::mem; + +fn main() { + let mut rollup: cmt::cmt_rollup_t = unsafe { mem::zeroed() }; + let rc = unsafe { cmt::cmt_rollup_init(&mut rollup) }; + println!("got return value: {}!", rc); +} +``` + +Messages like the one below most likely mean that cargo didn't find the library +`libcmt.a` or `build.rs` is incomplete: +``` +undefined reference to `cmt_rollup_emit_voucher' +``` diff --git a/sys-utils/libcmt/doc/Doxyfile b/sys-utils/libcmt/doc/Doxyfile new file mode 100644 index 00000000..415f3da8 --- /dev/null +++ b/sys-utils/libcmt/doc/Doxyfile @@ -0,0 +1,2777 @@ +# Doxyfile 1.9.6 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Cartesi Machine Tools Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = NO + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = YES + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:^^" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. + +CASE_SENSE_NAMES = SYSTEM + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = doc/DoxygenLayout.xml + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = README.md include + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.l \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# ANamespace::AClass, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = doc/examples + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = README.md + +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS +# tag is set to YES then doxygen will add the directory of each input to the +# include path. +# The default value is: YES. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = doc/theme/doxygen-awesome.css \ + doc/theme/doxygen-awesome-sidebar-only.css + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_DARK + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use gray-scales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /