diff --git a/lib/grpc-interfaces b/lib/grpc-interfaces index cba7c3f1c..ce2d7ba23 160000 --- a/lib/grpc-interfaces +++ b/lib/grpc-interfaces @@ -1 +1 @@ -Subproject commit cba7c3f1c53b83bee83d8a1e5a1074591279220f +Subproject commit ce2d7ba2384554137edc8a980d0878d61b8f35ff diff --git a/lib/machine-emulator-defines b/lib/machine-emulator-defines index fc2473ac7..0cfb61f96 160000 --- a/lib/machine-emulator-defines +++ b/lib/machine-emulator-defines @@ -1 +1 @@ -Subproject commit fc2473ac74d485b40f53f45f874b67abcb6843af +Subproject commit 0cfb61f96fa4bf7505516963b4312199f165fef9 diff --git a/src/cartesi-machine.lua b/src/cartesi-machine.lua index 7fdb94153..382e17259 100755 --- a/src/cartesi-machine.lua +++ b/src/cartesi-machine.lua @@ -139,9 +139,6 @@ where options are: --rollup-rx-buffer=:[,:[,...]...] --rollup-tx-buffer=:[,:[,...]...] - --rollup-input-metadata=:[,:[,...]...] - --rollup-voucher-hashes=:[,:[,...]...] - --rollup-notice-hashes=:[,:[,...]...] defines the individual the memory ranges used by rollups. : is one of @@ -161,9 +158,6 @@ where options are: --rollup-rx-buffer=start:0x60000000,length:2<<20 --rollup-tx-buffer=start:0x60200000,length:2<<20 - --rollup-input-metadata=start:0x60400000,length:4096 - --rollup-voucher-hashes=start:0x60600000,length:2<<20 - --rollup-notice-hashes=start:0x60800000,length:2<<20 --htif-yield-manual --htif-yield-automatic @@ -171,24 +165,15 @@ where options are: advances the state of the machine through a number of inputs in an epoch : is one of - epoch_index: input: input_metadata: input_index_begin: input_index_end: - voucher: - voucher_hashes: - notice: - notice_hashes: - report: + output: hashes - epoch_index - the index of the epoch (the value of %%e). - - input (default: "epoch-%%e-input-%%i.bin") - the pattern that derives the name of the file read for input %%i - of epoch index %%e. + input (default: "input-%%i.bin") + the pattern that derives the name of the file read for input %%i. input_index_begin (default: 0) index of first input to advance (the first value of %%i). @@ -196,36 +181,15 @@ where options are: input_index_end (default: 0) one past index of last input to advance (one past last value of %%i). - input_metadata (default: "epoch-%%e-input-metadata-%%i.bin") - the pattern that derives the name of the file read for - input metadata %%i of epoch index %%e. - - voucher (default: "epoch-%%e-input-%%i-voucher-%%o.bin") - the pattern that derives the name of the file written for voucher %%o - of input %%i of epoch %%e. - - voucher_hashes (default: "epoch-%%e-input-%%i-voucher-hashes.bin") - the pattern that derives the name of the file written for the voucher - hashes of input %%i of epoch %%e. - - notice (default: "epoch-%%e-input-%%i-notice-%%o.bin") - the pattern that derives the name of the file written for notice %%o - of input %%i of epoch %%e. - - notice_hashes (default: "epoch-%%e-input-%%i-notice-hashes.bin") - the pattern that derives the name of the file written for the notice - hashes of input %%i of epoch %%e. - - report (default: "epoch-%%e-input-%%i-report-%%o.bin") - the pattern that derives the name of the file written for report %%o - of input %%i of epoch %%e. + output (default: "input-%%i-output-%%o.bin") + the pattern that derives the name of the file written for output %%o + of input %%i. hashes print out hashes before every input. - the input index ranges in {input_index_begin, ..., input_index_end-1}. - for each input, "%%e" is replaced by the epoch index, "%%i" by the - input index, and "%%o" by the voucher, notice, or report index. + the input index ranges in {input_index_begin, ..., input_index_end-1}. for + each input, "%%i" by the input index, and "%%o" by the output index. --rollup-inspect-state=:[,:[,...]...] inspect the state of the machine with a query. @@ -238,11 +202,11 @@ where options are: query (default: "query.bin") the name of the file from which to read the query. - report (default: "query-report-%%o.bin") + report (default: "query-%%o.bin") the pattern that derives the name of the file written for report %%o of the query. - while the query is processed, "%%o" is replaced by the current report index. + while the query is processed, "%%o" is replaced by the current output index. --concurrency=:[,:[,...]...] configures the number of threads used in some implementation parts. @@ -632,9 +596,6 @@ local options = { rollup = rollup or {} rollup.rx_buffer = { start = 0x60000000, length = 2 << 20 } rollup.tx_buffer = { start = 0x60200000, length = 2 << 20 } - rollup.input_metadata = { start = 0x60400000, length = 4096 } - rollup.voucher_hashes = { start = 0x60600000, length = 2 << 20 } - rollup.notice_hashes = { start = 0x60800000, length = 2 << 20 } htif_yield_automatic = true htif_yield_manual = true return true @@ -691,32 +652,21 @@ local options = { function(all, opts) if not opts then return false end local r = util.parse_options(opts, { - epoch_index = true, input = true, - input_metadata = true, input_index_begin = true, input_index_end = true, - voucher = true, - voucher_hashes = true, - notice = true, - notice_hashes = true, - report = true, + output = true, hashes = true, }) assert(not r.hashes or r.hashes == true, "invalid hashes value in " .. all) - r.epoch_index = assert(util.parse_number(r.epoch_index), "invalid epoch index in " .. all) - r.input = r.input or "epoch-%e-input-%i.bin" - r.input_metadata = r.input_metadata or "epoch-%e-input-metadata-%i.bin" + r.input = r.input or "input-%i.bin" r.input_index_begin = r.input_index_begin or 0 r.input_index_begin = assert(util.parse_number(r.input_index_begin), "invalid input index begin in " .. all) r.input_index_end = r.input_index_end or 0 r.input_index_end = assert(util.parse_number(r.input_index_end), "invalid input index end in " .. all) - r.voucher = r.voucher or "epoch-%e-input-%i-voucher-%o.bin" - r.voucher_hashes = r.voucher_hashes or "epoch-%e-input-%i-voucher-hashes.bin" - r.notice = r.notice or "epoch-%e-input-%i-notice-%o.bin" - r.notice_hashes = r.notice_hashes or "epoch-%e-input-%i-notice-hashes.bin" - r.report = r.report or "epoch-%e-input-%i-report-%o.bin" + r.output = r.output or "input-%i-output-%o.bin" r.next_input_index = r.input_index_begin + r.output_index = 0 rollup_advance = r return true end, @@ -730,7 +680,7 @@ local options = { report = true, }) r.query = r.query or "query.bin" - r.report = r.report or "query-report-%o.bin" + r.report = r.report or "query-output-%o.bin" rollup_inspect = r return true end, @@ -1032,33 +982,6 @@ local options = { return true end, }, - { - "^(%-%-rollup%-input%-metadata%=(.+))$", - function(all, opts) - if not opts then return false end - rollup = rollup or {} - rollup.input_metadata = parse_memory_range(opts, "rollup input metadata", all) - return true - end, - }, - { - "^(%-%-rollup%-voucher%-hashes%=(.+))$", - function(all, opts) - if not opts then return false end - rollup = rollup or {} - rollup.voucher_hashes = parse_memory_range(opts, "rollup voucher hashes", all) - return true - end, - }, - { - "^(%-%-rollup%-notice%-hashes%=(.+))$", - function(all, opts) - if not opts then return false end - rollup = rollup or {} - rollup.notice_hashes = parse_memory_range(opts, "rollup notice hashes", all) - return true - end, - }, { "^%-%-gdb(%=?)(.*)$", function(o, address) @@ -1207,12 +1130,6 @@ local function store_machine_config(config, output) store_memory_range(config.rollup.rx_buffer, " ", output) output(" tx_buffer = ") store_memory_range(config.rollup.tx_buffer, " ", output) - output(" input_metadata = ") - store_memory_range(config.rollup.input_metadata, " ", output) - output(" voucher_hashes = ") - store_memory_range(config.rollup.voucher_hashes, " ", output) - output(" notice_hashes = ") - store_memory_range(config.rollup.notice_hashes, " ", output) output(" },\n") end output(" uarch = {\n") @@ -1415,10 +1332,7 @@ local htif_yield_reason = { [cartesi.machine.HTIF_YIELD_REASON_PROGRESS] = "progress", [cartesi.machine.HTIF_YIELD_REASON_RX_ACCEPTED] = "rx-accepted", [cartesi.machine.HTIF_YIELD_REASON_RX_REJECTED] = "rx-rejected", - [cartesi.machine.HTIF_YIELD_REASON_TX_VOUCHER] = "tx-voucher", - [cartesi.machine.HTIF_YIELD_REASON_TX_NOTICE] = "tx-notice", - [cartesi.machine.HTIF_YIELD_REASON_TX_REPORT] = "tx-report", - [cartesi.machine.HTIF_YIELD_REASON_TX_EXCEPTION] = "tx-exception", + [cartesi.machine.HTIF_YIELD_REASON_TX_OUTPUT] = "tx-output", } local htif_yield_mode = { @@ -1465,7 +1379,7 @@ local function get_yield(machine) local cmd = machine:read_htif_tohost_cmd() local data = machine:read_htif_tohost_data() local reason = data >> 32 - return cmd, reason, data + return cmd, (reason & 0xffff), (data & 0xffffffff) end local function get_and_print_yield(machine, htif) @@ -1504,28 +1418,19 @@ local function instantiate_filename(pattern, values) return (string.gsub(pattern, "\0", "%")) end -local function save_rollup_voucher_and_notice_hashes(machine, config, advance) - local values = { e = advance.epoch_index, i = advance.next_input_index - 1 } - save_rollup_hashes(machine, config.voucher_hashes, instantiate_filename(advance.voucher_hashes, values)) - save_rollup_hashes(machine, config.notice_hashes, instantiate_filename(advance.notice_hashes, values)) -end - local function load_memory_range(machine, config, filename) stderr("Loading %s\n", filename) local f = assert(io.open(filename, "rb")) local s = assert(f:read("*a")) f:close() machine:write_memory(config.start, s) + return #s end -local function load_rollup_input_and_metadata(machine, config, advance) +local function load_rollup_input(machine, config, advance) local values = { e = advance.epoch_index, i = advance.next_input_index } - machine:replace_memory_range(config.input_metadata) -- clear - load_memory_range(machine, config.input_metadata, instantiate_filename(advance.input_metadata, values)) machine:replace_memory_range(config.rx_buffer) -- clear - load_memory_range(machine, config.rx_buffer, instantiate_filename(advance.input, values)) - machine:replace_memory_range(config.voucher_hashes) -- clear - machine:replace_memory_range(config.notice_hashes) -- clear + return load_memory_range(machine, config.rx_buffer, instantiate_filename(advance.input, values)) end local function load_rollup_query(machine, config, inspect) @@ -1533,28 +1438,11 @@ local function load_rollup_query(machine, config, inspect) load_memory_range(machine, config.rx_buffer, inspect.query) -- load query payload end -local function save_rollup_advance_state_voucher(machine, config, advance) - local values = { e = advance.epoch_index, i = advance.next_input_index - 1, o = advance.voucher_index } - local name = instantiate_filename(advance.voucher, values) +local function save_rollup_state_output(machine, config, advance, length) + local values = { e = advance.epoch_index, i = advance.next_input_index - 1, o = advance.output_index } + local name = instantiate_filename(advance.output, values) stderr("Storing %s\n", name) local f = assert(io.open(name, "wb")) - -- skip address and offset to reach payload length - local length = string.unpack(">I8", machine:read_memory(config.start + 3 * 32 - 8, 8)) - -- add address, offset, and payload length to amount to be read - length = length + 3 * 32 - assert(f:write(machine:read_memory(config.start, length))) - f:close() -end - -local function save_rollup_advance_state_notice(machine, config, advance) - local values = { e = advance.epoch_index, i = advance.next_input_index - 1, o = advance.notice_index } - local name = instantiate_filename(advance.notice, values) - stderr("Storing %s\n", name) - local f = assert(io.open(name, "wb")) - -- skip offset to reach payload length - local length = string.unpack(">I8", machine:read_memory(config.start + 2 * 32 - 8, 8)) - -- add offset and payload length to amount to be read - length = length + 2 * 32 assert(f:write(machine:read_memory(config.start, length))) f:close() end @@ -1567,21 +1455,8 @@ local function dump_exception(machine, config) stderr("Rollup exception with payload: %q\n", payload) end -local function save_rollup_advance_state_report(machine, config, advance) - local values = { e = advance.epoch_index, i = advance.next_input_index - 1, o = advance.report_index } - local name = instantiate_filename(advance.report, values) - stderr("Storing %s\n", name) - local f = assert(io.open(name, "wb")) - -- skip offset to reach payload length - local length = string.unpack(">I8", machine:read_memory(config.start + 2 * 32 - 8, 8)) - -- add offset and payload length to amount to be read - length = length + 2 * 32 - assert(f:write(machine:read_memory(config.start, length))) - f:close() -end - local function save_rollup_inspect_state_report(machine, config, inspect) - local values = { o = inspect.report_index } + local values = { o = inspect.output_index } local name = instantiate_filename(inspect.report, values) stderr("Storing %s\n", name) local f = assert(io.open(name, "wb")) @@ -1659,9 +1534,6 @@ else assert(remote_address, "rollup requires --remote-address for snapshot/rollback") check_rollup_memory_range_config(config.rollup.tx_buffer, "tx-buffer") check_rollup_memory_range_config(config.rollup.rx_buffer, "rx-buffer") - check_rollup_memory_range_config(config.rollup.input_metadata, "input-metadata") - check_rollup_memory_range_config(config.rollup.voucher_hashes, "voucher-hashes") - check_rollup_memory_range_config(config.rollup.notice_hashes, "notice-hashes") end local cycles = machine:read_mcycle() if initial_hash then @@ -1708,70 +1580,49 @@ else break -- deal with yield manual elseif machine:read_iflags_Y() then - local _, reason = get_and_print_yield(machine, config.htif) + local _, reason, output_length = get_and_print_yield(machine, config.htif) -- there are advance state inputs to feed - if reason == cartesi.machine.HTIF_YIELD_REASON_TX_EXCEPTION then - dump_exception(machine, config.rollup.tx_buffer) - exit_code = 1 - elseif rollup_advance and rollup_advance.next_input_index < rollup_advance.input_index_end then - -- save only if we have already run an input - if rollup_advance.next_input_index > rollup_advance.input_index_begin then - save_rollup_voucher_and_notice_hashes(machine, config.rollup, rollup_advance) - end + if rollup_advance and rollup_advance.next_input_index < rollup_advance.input_index_end then if reason == cartesi.machine.HTIF_YIELD_REASON_RX_REJECTED then machine:rollback() cycles = machine:read_mcycle() else assert(reason == cartesi.machine.HTIF_YIELD_REASON_RX_ACCEPTED, "invalid manual yield reason") end - stderr("\nEpoch %d before input %d\n", rollup_advance.epoch_index, rollup_advance.next_input_index) if rollup_advance.hashes then print_root_hash(machine) end machine:snapshot() - load_rollup_input_and_metadata(machine, config.rollup, rollup_advance) + local input_length = load_rollup_input(machine, config.rollup, rollup_advance) if rollup_advance.hashes then print_root_hash(machine) end machine:reset_iflags_Y() - machine:write_htif_fromhost_data(0) -- tell machine it is an rollup_advance state, but this is default - rollup_advance.voucher_index = 0 - rollup_advance.notice_index = 0 - rollup_advance.report_index = 0 + machine:write_htif_fromhost_data((0 << 32) | input_length) -- tell machine it is an rollup_advance state, but this is default + rollup_advance.output_index = 0 rollup_advance.next_input_index = rollup_advance.next_input_index + 1 else - -- there are outputs of a prevous advance state to save - if rollup_advance and rollup_advance.next_input_index > rollup_advance.input_index_begin then - save_rollup_voucher_and_notice_hashes(machine, config.rollup, rollup_advance) - end -- there is an inspect state query to feed if rollup_inspect and rollup_inspect.query then stderr("\nBefore query\n") - load_rollup_query(machine, config.rollup, rollup_inspect) + local input_length = load_rollup_query(machine, config.rollup, rollup_inspect) machine:reset_iflags_Y() - machine:write_htif_fromhost_data(1) -- tell machine it is an inspect state - rollup_inspect.report_index = 0 + machine:write_htif_fromhost_data((1 << 32) | input_length) -- tell machine it is an inspect state rollup_inspect.query = nil rollup_advance = nil end end -- deal with yield automatic elseif machine:read_iflags_X() then - local _, reason = get_and_print_yield(machine, config.htif) + local _, reason, length = get_and_print_yield(machine, config.htif) -- we have fed an advance state input if rollup_advance and rollup_advance.next_input_index > rollup_advance.input_index_begin then - if reason == cartesi.machine.HTIF_YIELD_REASON_TX_VOUCHER then - save_rollup_advance_state_voucher(machine, config.rollup.tx_buffer, rollup_advance) - rollup_advance.voucher_index = rollup_advance.voucher_index + 1 - elseif reason == cartesi.machine.HTIF_YIELD_REASON_TX_NOTICE then - save_rollup_advance_state_notice(machine, config.rollup.tx_buffer, rollup_advance) - rollup_advance.notice_index = rollup_advance.notice_index + 1 - elseif reason == cartesi.machine.HTIF_YIELD_REASON_TX_REPORT then - save_rollup_advance_state_report(machine, config.rollup.tx_buffer, rollup_advance) - rollup_advance.report_index = rollup_advance.report_index + 1 + if reason == cartesi.machine.HTIF_YIELD_REASON_TX_OUTPUT then + save_rollup_state_output(machine, config.rollup.tx_buffer, rollup_advance, length) + rollup_advance.output_index = rollup_advance.output_index + 1 end -- ignore other reasons -- we have feed the inspect state query elseif rollup_inspect and not rollup_inspect.query then if reason == cartesi.machine.HTIF_YIELD_REASON_TX_REPORT then - save_rollup_inspect_state_report(machine, config.rollup.tx_buffer, rollup_inspect) - rollup_inspect.report_index = rollup_inspect.report_index + 1 + save_rollup_state_output(machine, config.rollup.tx_buffer, rollup_inspect, length) + rollup_inspect.output_index = rollup_inspect.output_index + 1 end -- ignore other reasons end diff --git a/src/clua-htif.cpp b/src/clua-htif.cpp index 18f4b3b56..b474ad3fb 100644 --- a/src/clua-htif.cpp +++ b/src/clua-htif.cpp @@ -34,12 +34,9 @@ int clua_htif_export(lua_State *L, int ctxidx) { named_constant{HTIF_YIELD_AUTOMATIC, "HTIF_YIELD_AUTOMATIC"}, named_constant{HTIF_YIELD_MANUAL, "HTIF_YIELD_MANUAL"}, named_constant{HTIF_YIELD_REASON_PROGRESS, "HTIF_YIELD_REASON_PROGRESS"}, - named_constant{HTIF_YIELD_REASON_RX_ACCEPTED, "HTIF_YIELD_REASON_RX_ACCEPTED"}, - named_constant{HTIF_YIELD_REASON_RX_REJECTED, "HTIF_YIELD_REASON_RX_REJECTED"}, - named_constant{HTIF_YIELD_REASON_TX_VOUCHER, "HTIF_YIELD_REASON_TX_VOUCHER"}, - named_constant{HTIF_YIELD_REASON_TX_NOTICE, "HTIF_YIELD_REASON_TX_NOTICE"}, - named_constant{HTIF_YIELD_REASON_TX_REPORT, "HTIF_YIELD_REASON_TX_REPORT"}, - named_constant{HTIF_YIELD_REASON_TX_EXCEPTION, "HTIF_YIELD_REASON_TX_EXCEPTION"}, + named_constant{HTIF_YIELD_REASON_RX_ACCEPTED_DEF, "HTIF_YIELD_REASON_RX_ACCEPTED"}, + named_constant{HTIF_YIELD_REASON_RX_REJECTED_DEF, "HTIF_YIELD_REASON_RX_REJECTED"}, + named_constant{HTIF_YIELD_REASON_TX_OUTPUT_DEF, "HTIF_YIELD_REASON_TX_OUTPUT"}, named_constant{HTIF_CONSOLE_GETCHAR, "HTIF_CONSOLE_GETCHAR"}, named_constant{HTIF_CONSOLE_PUTCHAR, "HTIF_CONSOLE_PUTCHAR"}, }; diff --git a/src/clua-machine-util.cpp b/src/clua-machine-util.cpp index a49272e5f..1f5fbe8f5 100644 --- a/src/clua-machine-util.cpp +++ b/src/clua-machine-util.cpp @@ -835,12 +835,6 @@ static void push_cm_rollup_config(lua_State *L, const cm_rollup_config *r) { lua_setfield(L, -2, "rx_buffer"); // rollup push_cm_memory_range_config(L, &r->tx_buffer); // rollup tx_buffer lua_setfield(L, -2, "tx_buffer"); // rollup - push_cm_memory_range_config(L, &r->input_metadata); // rollup input_metadata - lua_setfield(L, -2, "input_metadata"); // rollup - push_cm_memory_range_config(L, &r->voucher_hashes); // rollup voucher_hashes - lua_setfield(L, -2, "voucher_hashes"); // rollup - push_cm_memory_range_config(L, &r->notice_hashes); // rollup notice_hashes - lua_setfield(L, -2, "notice_hashes"); // rollup } /// \brief Pushes cm_flash_drive_configs to the Lua stack @@ -982,15 +976,6 @@ static void check_cm_rollup_config(lua_State *L, int tabidx, cm_rollup_config *r lua_pop(L, 1); lua_getfield(L, -1, "tx_buffer"); clua_check_cm_memory_range_config(L, -1, "rollup rx buffer", &r->tx_buffer); - lua_pop(L, 1); - lua_getfield(L, -1, "input_metadata"); - clua_check_cm_memory_range_config(L, -1, "rollup input metadata", &r->input_metadata); - lua_pop(L, 1); - lua_getfield(L, -1, "voucher_hashes"); - clua_check_cm_memory_range_config(L, -1, "rollup voucher hashes", &r->voucher_hashes); - lua_pop(L, 1); - lua_getfield(L, -1, "notice_hashes"); - clua_check_cm_memory_range_config(L, -1, "rollup notice hashes", &r->notice_hashes); lua_pop(L, 2); } diff --git a/src/htif.h b/src/htif.h index bcc4eec8b..1f7accbf3 100644 --- a/src/htif.h +++ b/src/htif.h @@ -85,13 +85,10 @@ enum HTIF_commands : uint64_t { /// \brief HTIF yield reasons enum HTIF_yield_reason : uint64_t { - HTIF_YIELD_REASON_PROGRESS = HTIF_YIELD_REASON_PROGRESS_DEF, - HTIF_YIELD_REASON_RX_ACCEPTED = HTIF_YIELD_REASON_RX_ACCEPTED_DEF, - HTIF_YIELD_REASON_RX_REJECTED = HTIF_YIELD_REASON_RX_REJECTED_DEF, - HTIF_YIELD_REASON_TX_VOUCHER = HTIF_YIELD_REASON_TX_VOUCHER_DEF, - HTIF_YIELD_REASON_TX_NOTICE = HTIF_YIELD_REASON_TX_NOTICE_DEF, - HTIF_YIELD_REASON_TX_REPORT = HTIF_YIELD_REASON_TX_REPORT_DEF, - HTIF_YIELD_REASON_TX_EXCEPTION = HTIF_YIELD_REASON_TX_EXCEPTION_DEF, + HTIF_YIELD_REASON_PROGRESS = HTIF_YIELD_REASON_PROGRESS_DEF, + HTIF_YIELD_REASON_RX_ACCEPTED = HTIF_YIELD_REASON_RX_ACCEPTED_DEF, + HTIF_YIELD_REASON_RX_REJECTED = HTIF_YIELD_REASON_RX_REJECTED_DEF, + HTIF_YIELD_REASON_TX_OUTPUT = HTIF_YIELD_REASON_TX_OUTPUT_DEF, }; /// \brief Mapping between CSRs and their relative addresses in HTIF memory enum class htif_csr { diff --git a/src/json-util.cpp b/src/json-util.cpp index 5ef64354e..f278ff963 100644 --- a/src/json-util.cpp +++ b/src/json-util.cpp @@ -916,9 +916,6 @@ void ju_get_opt_field(const nlohmann::json &j, const K &key, rollup_config &valu const auto new_path = path + to_string(key) + "/"; ju_get_field(jconfig, "rx_buffer"s, value.rx_buffer, new_path); ju_get_field(jconfig, "tx_buffer"s, value.tx_buffer, new_path); - ju_get_field(jconfig, "input_metadata"s, value.input_metadata, new_path); - ju_get_field(jconfig, "voucher_hashes"s, value.voucher_hashes, new_path); - ju_get_field(jconfig, "notice_hashes"s, value.notice_hashes, new_path); } template void ju_get_opt_field(const nlohmann::json &j, const uint64_t &key, rollup_config &value, @@ -940,9 +937,6 @@ void ju_get_opt_field(const nlohmann::json &j, const K &key, std::optional(const nlohmann::json &j, const uint64_t &key, @@ -1159,9 +1153,6 @@ void to_json(nlohmann::json &j, const rollup_config &config) { j = nlohmann::json{ {"rx_buffer", config.rx_buffer}, {"tx_buffer", config.tx_buffer}, - {"input_metadata", config.input_metadata}, - {"voucher_hashes", config.voucher_hashes}, - {"notice_hashes", config.notice_hashes}, }; } diff --git a/src/machine-c-api.cpp b/src/machine-c-api.cpp index cc70975aa..7dc8167db 100644 --- a/src/machine-c-api.cpp +++ b/src/machine-c-api.cpp @@ -286,8 +286,7 @@ static std::optional convert_from_c(const cm_rollup_conf return {}; } cartesi::rollup_config new_cpp_rollup_config{convert_from_c(&c_config->rx_buffer), - convert_from_c(&c_config->tx_buffer), convert_from_c(&c_config->input_metadata), - convert_from_c(&c_config->voucher_hashes), convert_from_c(&c_config->notice_hashes)}; + convert_from_c(&c_config->tx_buffer)}; return new_cpp_rollup_config; } @@ -299,9 +298,6 @@ static cm_rollup_config convert_to_c(const std::optional } new_c_rollup_config.rx_buffer = convert_to_c(cpp_config->rx_buffer); new_c_rollup_config.tx_buffer = convert_to_c(cpp_config->tx_buffer); - new_c_rollup_config.input_metadata = convert_to_c(cpp_config->input_metadata); - new_c_rollup_config.voucher_hashes = convert_to_c(cpp_config->voucher_hashes); - new_c_rollup_config.notice_hashes = convert_to_c(cpp_config->notice_hashes); return new_c_rollup_config; } @@ -708,9 +704,6 @@ void cm_delete_machine_config(const cm_machine_config *config) { delete[] config->tlb.image_filename; delete[] config->rollup.rx_buffer.image_filename; delete[] config->rollup.tx_buffer.image_filename; - delete[] config->rollup.input_metadata.image_filename; - delete[] config->rollup.voucher_hashes.image_filename; - delete[] config->rollup.notice_hashes.image_filename; delete[] config->uarch.ram.image_filename; delete config; diff --git a/src/machine-c-api.h b/src/machine-c-api.h index 88e9c3682..4d67895b2 100644 --- a/src/machine-c-api.h +++ b/src/machine-c-api.h @@ -235,9 +235,6 @@ typedef struct { // NOLINT(modernize-use-using) bool has_value; ///< Represents whether the rest of the struct have been filled cm_memory_range_config rx_buffer; ///< RX buffer memory range cm_memory_range_config tx_buffer; ///< TX buffer memory range - cm_memory_range_config input_metadata; ///< Input metadata memory range - cm_memory_range_config voucher_hashes; ///< Voucher hashes memory range - cm_memory_range_config notice_hashes; ///< Notice hashes memory range } cm_rollup_config; /// \brief microarchitecture RAM configuration diff --git a/src/machine-config.cpp b/src/machine-config.cpp index b75f26448..c27b2dc66 100644 --- a/src/machine-config.cpp +++ b/src/machine-config.cpp @@ -53,9 +53,6 @@ static void adjust_image_filenames(machine_config &c, const std::string &dir) { auto &r = c.rollup.value(); r.rx_buffer.image_filename = c.get_image_filename(dir, r.rx_buffer); r.tx_buffer.image_filename = c.get_image_filename(dir, r.tx_buffer); - r.input_metadata.image_filename = c.get_image_filename(dir, r.input_metadata); - r.voucher_hashes.image_filename = c.get_image_filename(dir, r.voucher_hashes); - r.notice_hashes.image_filename = c.get_image_filename(dir, r.notice_hashes); } if (c.uarch.ram.length > 0) { diff --git a/src/machine-config.h b/src/machine-config.h index 372886a9c..502981fdc 100644 --- a/src/machine-config.h +++ b/src/machine-config.h @@ -115,9 +115,6 @@ struct htif_config final { struct rollup_config { // NOLINT(bugprone-exception-escape) memory_range_config rx_buffer{}; ///< RX buffer memory_range_config tx_buffer{}; ///< TX buffer - memory_range_config input_metadata{}; ///< Buffer for input metadata - memory_range_config voucher_hashes{}; ///< Buffer for the voucher hash array - memory_range_config notice_hashes{}; ///< Buffer for the notice hash array }; /// \brief Machine state configuration diff --git a/src/machine.cpp b/src/machine.cpp index 11354de32..28a713c63 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -100,33 +100,6 @@ const pma_entry::flags machine::m_rollup_tx_buffer_flags{ PMA_ISTART_DID::rollup_tx_buffer // DID }; -const pma_entry::flags machine::m_rollup_input_metadata_flags{ - true, // R - false, // W - false, // X - true, // IR - true, // IW - PMA_ISTART_DID::rollup_input_metadata // DID -}; - -const pma_entry::flags machine::m_rollup_voucher_hashes_flags{ - true, // R - true, // W - false, // X - true, // IR - true, // IW - PMA_ISTART_DID::rollup_voucher_hashes // DID -}; - -const pma_entry::flags machine::m_rollup_notice_hashes_flags{ - true, // R - true, // W - false, // X - true, // IR - true, // IW - PMA_ISTART_DID::rollup_notice_hashes // DID -}; - pma_entry machine::make_memory_range_pma_entry(const std::string &description, const memory_range_config &c) { if (c.image_filename.empty()) { return make_callocd_memory_pma_entry(description, c.start, c.length); @@ -146,20 +119,6 @@ pma_entry machine::make_rollup_tx_buffer_pma_entry(const memory_range_config &c) return make_memory_range_pma_entry("rollup tx buffer memory range"s, c).set_flags(m_rollup_tx_buffer_flags); } -pma_entry machine::make_rollup_input_metadata_pma_entry(const memory_range_config &c) { - return make_memory_range_pma_entry("rollup input metadata memory range"s, c) - .set_flags(m_rollup_input_metadata_flags); -} - -pma_entry machine::make_rollup_voucher_hashes_pma_entry(const memory_range_config &c) { - return make_memory_range_pma_entry("rollup voucher hashes memory range"s, c) - .set_flags(m_rollup_voucher_hashes_flags); -} - -pma_entry machine::make_rollup_notice_hashes_pma_entry(const memory_range_config &c) { - return make_memory_range_pma_entry("rollup notice hashes memory range"s, c).set_flags(m_rollup_notice_hashes_flags); -} - pma_entry &machine::register_pma_entry(pma_entry &&pma) { if (m_s.pmas.capacity() <= m_s.pmas.size()) { // NOLINT(readability-static-accessed-through-instance) throw std::runtime_error{"too many PMAs when adding "s + pma.get_description()}; @@ -205,12 +164,6 @@ static bool DID_is_protected(PMA_ISTART_DID DID) { return false; case PMA_ISTART_DID::rollup_tx_buffer: return false; - case PMA_ISTART_DID::rollup_input_metadata: - return false; - case PMA_ISTART_DID::rollup_voucher_hashes: - return false; - case PMA_ISTART_DID::rollup_notice_hashes: - return false; default: return true; } @@ -378,17 +331,11 @@ machine::machine(const machine_config &c, const machine_runtime_config &r) : // Register rollup memory ranges if (m_c.rollup.has_value()) { if (m_c.rollup->rx_buffer.length == 0 || m_c.rollup->rx_buffer.start == 0 || - m_c.rollup->tx_buffer.length == 0 || m_c.rollup->tx_buffer.start == 0 || - m_c.rollup->input_metadata.length == 0 || m_c.rollup->input_metadata.start == 0 || - m_c.rollup->voucher_hashes.length == 0 || m_c.rollup->voucher_hashes.start == 0 || - m_c.rollup->notice_hashes.length == 0 || m_c.rollup->notice_hashes.start == 0) { + m_c.rollup->tx_buffer.length == 0 || m_c.rollup->tx_buffer.start == 0) { throw std::invalid_argument{"incomplete rollup configuration"}; } register_pma_entry(make_rollup_tx_buffer_pma_entry(m_c.rollup->tx_buffer)); register_pma_entry(make_rollup_rx_buffer_pma_entry(m_c.rollup->rx_buffer)); - register_pma_entry(make_rollup_input_metadata_pma_entry(m_c.rollup->input_metadata)); - register_pma_entry(make_rollup_voucher_hashes_pma_entry(m_c.rollup->voucher_hashes)); - register_pma_entry(make_rollup_notice_hashes_pma_entry(m_c.rollup->notice_hashes)); } // Register HTIF device @@ -553,9 +500,6 @@ machine_config machine::get_serialization_config(void) const { auto &r = c.rollup.value(); r.rx_buffer.image_filename.clear(); r.tx_buffer.image_filename.clear(); - r.input_metadata.image_filename.clear(); - r.voucher_hashes.image_filename.clear(); - r.notice_hashes.image_filename.clear(); } c.uarch.processor.cycle = read_uarch_cycle(); c.uarch.processor.halt_flag = read_uarch_halt_flag(); @@ -660,9 +604,6 @@ void machine::store_pmas(const machine_config &c, const std::string &dir) const const auto &r = c.rollup.value(); store_memory_pma(find_pma_entry(r.rx_buffer.start), dir); store_memory_pma(find_pma_entry(r.tx_buffer.start), dir); - store_memory_pma(find_pma_entry(r.input_metadata.start), dir); - store_memory_pma(find_pma_entry(r.voucher_hashes.start), dir); - store_memory_pma(find_pma_entry(r.notice_hashes.start), dir); } if (!m_uarch.get_state().ram.get_istart_E()) { store_memory_pma(m_uarch.get_state().ram, dir); diff --git a/src/machine.h b/src/machine.h index 2b913da3c..118ad9829 100644 --- a/src/machine.h +++ b/src/machine.h @@ -64,9 +64,6 @@ class machine final { static const pma_entry::flags m_flash_drive_flags; ///< PMA flags used for flash drives static const pma_entry::flags m_rollup_rx_buffer_flags; ///< PMA flags used for rollup rx buffer static const pma_entry::flags m_rollup_tx_buffer_flags; ///< PMA flags used for rollup tx buffer - static const pma_entry::flags m_rollup_input_metadata_flags; ///< PMA flags used for rollup input metadata - static const pma_entry::flags m_rollup_voucher_hashes_flags; ///< PMA flags used for rollup voucher hashes - static const pma_entry::flags m_rollup_notice_hashes_flags; ///< PMA flags used for rollup notice hashes /// \brief Allocates a new PMA entry. /// \param pma PMA entry to add to machine. @@ -95,21 +92,6 @@ class machine final { /// \returns New PMA entry with tx buffer flags already set. static pma_entry make_rollup_tx_buffer_pma_entry(const memory_range_config &c); - /// \brief Creates a new rollup input metadata PMA entry. - /// \param c Memory range configuration. - /// \returns New PMA entry with rollup input metadata flags already set. - static pma_entry make_rollup_input_metadata_pma_entry(const memory_range_config &c); - - /// \brief Creates a new rollup voucher hashes PMA entry. - /// \param c Memory range configuration. - /// \returns New PMA entry with rollup voucher hashes flags already set. - static pma_entry make_rollup_voucher_hashes_pma_entry(const memory_range_config &c); - - /// \brief Creates a new rollup notice hahes PMA entry. - /// \param c Memory range configuration. - /// \returns New PMA entry with rollup notice hashes flags already set. - static pma_entry make_rollup_notice_hashes_pma_entry(const memory_range_config &c); - /// \brief Saves PMAs into files for serialization /// \param config Machine config to be stored /// \param directory Directory where PMAs will be stored diff --git a/src/pma-constants.h b/src/pma-constants.h index 70091a660..66edf2122 100644 --- a/src/pma-constants.h +++ b/src/pma-constants.h @@ -106,9 +106,6 @@ enum class PMA_ISTART_DID { HTIF = PMA_HTIF_DID_DEF, ///< DID for HTIF device rollup_rx_buffer = PMA_ROLLUP_RX_BUFFER_DID_DEF, ///< DID for rollup receive buffer rollup_tx_buffer = PMA_ROLLUP_TX_BUFFER_DID_DEF, ///< DID for rollup transmit buffer - rollup_input_metadata = PMA_ROLLUP_INPUT_METADATA_DID_DEF, ///< DID for rollup input metadata memory range - rollup_voucher_hashes = PMA_ROLLUP_VOUCHER_HASHES_DID_DEF, ///< DID for rollup voucher hashes memory range - rollup_notice_hashes = PMA_ROLLUP_NOTICE_HASHES_DID_DEF, ///< DID for rollup notice hashes memory range }; } // namespace cartesi diff --git a/src/protobuf-util.cpp b/src/protobuf-util.cpp index 65c37fc39..7372da372 100644 --- a/src/protobuf-util.cpp +++ b/src/protobuf-util.cpp @@ -38,9 +38,6 @@ void set_proto_memory_range(const memory_range_config &m, CartesiMachine::Memory void set_proto_rollup(const rollup_config &r, CartesiMachine::RollupConfig *proto_r) { set_proto_memory_range(r.rx_buffer, proto_r->mutable_rx_buffer()); set_proto_memory_range(r.tx_buffer, proto_r->mutable_tx_buffer()); - set_proto_memory_range(r.input_metadata, proto_r->mutable_input_metadata()); - set_proto_memory_range(r.voucher_hashes, proto_r->mutable_voucher_hashes()); - set_proto_memory_range(r.notice_hashes, proto_r->mutable_notice_hashes()); } void set_proto_machine_config(const machine_config &c, CartesiMachine::MachineConfig *proto_c) { @@ -793,15 +790,6 @@ rollup_config get_proto_rollup_config(const CartesiMachine::RollupConfig &proto_ if (proto_r.has_tx_buffer()) { r.tx_buffer = get_proto_memory_range_config(proto_r.tx_buffer()); } - if (proto_r.has_input_metadata()) { - r.input_metadata = get_proto_memory_range_config(proto_r.input_metadata()); - } - if (proto_r.has_voucher_hashes()) { - r.voucher_hashes = get_proto_memory_range_config(proto_r.voucher_hashes()); - } - if (proto_r.has_input_metadata()) { - r.notice_hashes = get_proto_memory_range_config(proto_r.notice_hashes()); - } return r; }