diff --git a/helper_scripts/generate_EmulatorConstants.lua b/helper_scripts/generate_EmulatorConstants.lua index 7049659..6fcb369 100755 --- a/helper_scripts/generate_EmulatorConstants.lua +++ b/helper_scripts/generate_EmulatorConstants.lua @@ -15,6 +15,7 @@ end local out = io.stdout +out:write(' uint64 constant CM_MARCHID = ' .. cartesi.MARCHID .. ';\n') out:write(' bytes32 constant UARCH_PRISTINE_STATE_HASH = 0x' .. hexstring(cartesi.UARCH_PRISTINE_STATE_HASH) .. ';\n') out:write(' uint64 constant UARCH_CYCLE_ADDRESS = 0x' .. hex(cartesi.machine:get_reg_address("uarch_cycle")) .. ';\n') out:write(' uint64 constant UARCH_CYCLE_MAX = 0x' .. hex(cartesi.UARCH_CYCLE_MAX) .. ';\n') diff --git a/src/EmulatorConstants.sol b/src/EmulatorConstants.sol index 74f4725..1d98c82 100644 --- a/src/EmulatorConstants.sol +++ b/src/EmulatorConstants.sol @@ -24,6 +24,7 @@ pragma solidity ^0.8.30; library EmulatorConstants { // START OF AUTO-GENERATED CODE + uint64 constant CM_MARCHID = 21; bytes32 constant UARCH_PRISTINE_STATE_HASH = 0x1187b59e3fe94897c23582998adb33d3df9e8c962f6d1696dfd91adcfabb3a23; uint64 constant UARCH_CYCLE_ADDRESS = 0x400008; diff --git a/test/EmulatorConstants.t.sol b/test/EmulatorConstants.t.sol new file mode 100644 index 0000000..371d050 --- /dev/null +++ b/test/EmulatorConstants.t.sol @@ -0,0 +1,26 @@ +// 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. + +import {Test} from "forge-std/Test.sol"; + +import {EmulatorConstants} from "src/EmulatorConstants.sol"; + +pragma solidity ^0.8.30; + +contract EmulatorConstantsTest is Test { + function testCmMarchId() public pure { + assertEq(EmulatorConstants.CM_MARCHID, 21); + } +}