├── cmake ├── dummy │ ├── intxConfig.cmake │ ├── ethashConfig.cmake │ └── nlohmann_jsonConfig.cmake ├── LinkLLVM.cmake ├── blst.cmake └── test.cmake ├── test ├── vm │ ├── data │ │ ├── compile_benchmarks │ │ │ └── stop │ │ ├── regression_tests │ │ │ ├── push_several.evm │ │ │ ├── cold_warm │ │ │ ├── bad_gas.evm │ │ │ ├── bad_result.evm │ │ │ ├── balance_check │ │ │ └── fuzzer_01.evm │ │ ├── execution_benchmarks │ │ │ └── basic │ │ │ │ ├── empty │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_0 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_1 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_10 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_11 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_12 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_13 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_14 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_15 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_16 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_17 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_18 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_19 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_2 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_20 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_21 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_22 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_23 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_24 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_25 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_26 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_27 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_28 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_29 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_3 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_30 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_31 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_32 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_4 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_5 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_6 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_7 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_8 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ ├── push_9 │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ │ │ └── counting_loop │ │ │ │ ├── calldata │ │ │ │ └── contract │ │ └── cachegrind │ │ │ └── haswell.json │ ├── unit │ │ ├── runtime │ │ │ └── fixture.S │ │ ├── test_params.cpp │ │ └── test_params.hpp │ ├── compile_benchmarks │ │ └── CMakeLists.txt │ ├── fuzzer │ │ └── assertions.hpp │ ├── CMakeLists.txt │ ├── utils │ │ └── CMakeLists.txt │ └── micro_benchmarks │ │ └── CMakeLists.txt ├── data │ ├── checkpoint │ │ ├── code │ │ └── accounts │ └── blocks │ │ ├── compressed_blocks │ │ ├── 0 │ │ ├── 1 │ │ ├── 2 │ │ ├── 256 │ │ ├── 257 │ │ ├── 46402 │ │ ├── 2397315 │ │ ├── 2730000 │ │ ├── 2730001 │ │ ├── 2730002 │ │ ├── 2730009 │ │ └── 14000000 │ │ ├── bad_decode_blocks │ │ └── 46402 │ │ └── bad_decompress_blocks │ │ └── 46402 ├── ethereum_test │ └── exclude │ │ ├── eip150.cmake │ │ ├── eip158.cmake │ │ ├── byzantium.cmake │ │ ├── frontier.cmake │ │ ├── homestead.cmake │ │ ├── constantinoplefix.cmake │ │ ├── osaka.cmake │ │ └── prague.cmake └── unit │ └── common │ ├── src │ └── test │ │ └── main.cpp │ ├── include │ └── monad │ │ └── test │ │ └── config.hpp │ └── CMakeLists.txt ├── .dockerignore ├── scripts ├── vm │ ├── benchmark-analysis │ │ ├── .python-version │ │ ├── .flake8 │ │ ├── Makefile │ │ ├── src │ │ │ ├── compare_benchmarks │ │ │ │ └── __init__.py │ │ │ └── compare_implementations │ │ │ │ └── __init__.py │ │ └── pyproject.toml │ ├── fuzzer.sh │ ├── typechecker-fuzzer.sh │ ├── build-tests.sh │ ├── ci-fuzzer.sh │ ├── test.sh │ └── copy-s-files.sh ├── root │ ├── sudoers.d │ │ └── drop_caches │ ├── bin │ │ ├── drop_caches │ │ └── reserve_hugepages.sh │ └── etc │ │ ├── security │ │ └── limits.d │ │ │ └── memlock.conf │ │ └── sysctl.d │ │ └── monad-perf.conf ├── dev │ └── blktrace │ │ ├── dump.sh │ │ └── capture.sh ├── build.sh ├── configure.sh ├── ubuntu-build │ ├── install-boost.sh │ ├── install-deps.sh │ └── install-tools.sh ├── apply-clang-format.sh ├── test.sh ├── genpoststate │ └── Dockerfile ├── apply-clang-tidy-fixes.sh └── ubuntu-host │ └── setup.sh ├── category ├── core │ ├── toolchains │ │ ├── blacklist.tsan │ │ ├── gcc-avx512.cmake │ │ ├── gcc-avx2.cmake │ │ ├── gcc-tsan.cmake │ │ ├── gcc-asan.cmake │ │ ├── clang-tsan.cmake │ │ └── clang-fuzz.cmake │ ├── monad │ │ ├── tests │ │ │ ├── callgrind │ │ │ │ ├── _keccak_0.callgrind.json │ │ │ │ ├── _keccak_20.callgrind.json │ │ │ │ ├── _keccak_32.callgrind.json │ │ │ │ ├── keccak_0.json │ │ │ │ ├── keccak_20.json │ │ │ │ └── keccak_32.json │ │ │ ├── disas │ │ │ │ ├── core-tl_tid.dis │ │ │ │ ├── __init__.py │ │ │ │ ├── core-tl_tid.py │ │ │ │ ├── fiber │ │ │ │ │ └── priority_queue.py │ │ │ │ └── core-spinlock.py │ │ │ └── __init__.py │ │ └── __init__.py │ ├── keccak_impl.S │ ├── endian.hpp │ ├── concat.h │ ├── likely.h │ ├── cpu_relax.h │ ├── size_of.hpp │ ├── cpuset.h │ ├── tl_tid.c │ ├── cleanup.h │ ├── keccak.h │ ├── math_disas.cpp │ ├── procfs │ │ └── statm.h │ ├── result.hpp │ ├── tl_tid.h │ ├── basic_formatter.hpp │ ├── fiber │ │ ├── priority_task.hpp │ │ ├── config.hpp │ │ ├── priority_queue.cpp │ │ └── priority_pool.cpp │ ├── io │ │ └── config.hpp │ ├── spinlock_disas.c │ ├── event │ │ └── event_metadata.h │ ├── test │ │ └── huge_mem.cpp │ ├── math.hpp │ ├── cleanup.c │ ├── keccak.hpp │ ├── bytes_hash_compare.hpp │ ├── srcloc.h │ ├── nibble.h │ ├── util │ │ └── stopwatch.hpp │ ├── blake3.hpp │ ├── unaligned.hpp │ └── is_specialization_of.hpp ├── mpt │ ├── test │ │ └── many_nested_updates_simple_flat.json │ ├── cli_tool_impl.hpp │ ├── bench │ │ └── CMakeLists.txt │ ├── cli_tool_main.cpp │ ├── config.hpp │ ├── state_machine.hpp │ └── merkle │ │ └── node_reference.hpp ├── vm │ ├── runtime │ │ ├── exit.S │ │ ├── allocator.cpp │ │ └── runtime.hpp │ ├── core │ │ ├── cases.hpp │ │ ├── CMakeLists.txt │ │ └── assert.cpp │ ├── llvm │ │ └── entry.S │ ├── compiler │ │ ├── ir │ │ │ └── poly_typed │ │ │ │ ├── infer.hpp │ │ │ │ └── unify.hpp │ │ └── types.hpp │ ├── utils │ │ ├── traits.hpp │ │ ├── debug.cpp │ │ ├── evm-as │ │ │ └── utils.hpp │ │ ├── evmc_utils.cpp │ │ └── debug.hpp │ ├── interpreter │ │ ├── entry.S │ │ ├── instruction_stats.hpp │ │ └── execute.hpp │ ├── evm │ │ ├── delegation.hpp │ │ └── CMakeLists.txt │ └── fuzzing │ │ └── CMakeLists.txt ├── execution │ ├── monad │ │ ├── min_base_fee.cpp │ │ ├── min_base_fee.h │ │ ├── reserve_balance.h │ │ ├── chain │ │ │ ├── monad_mainnet_alloc.hpp │ │ │ ├── monad_devnet.hpp │ │ │ ├── monad_mainnet.hpp │ │ │ └── monad_testnet.hpp │ │ ├── monad_transaction_gas.hpp │ │ ├── staking │ │ │ ├── execute_block_prelude.hpp │ │ │ ├── util │ │ │ │ ├── consensus_view.cpp │ │ │ │ ├── delegator.cpp │ │ │ │ └── val_execution.cpp │ │ │ └── read_valset.hpp │ │ ├── system_sender.hpp │ │ ├── core │ │ │ └── rlp │ │ │ │ └── monad_block_rlp.hpp │ │ ├── monad_transaction_gas.cpp │ │ └── monad_precompiles.hpp │ └── ethereum │ │ ├── trace │ │ ├── tracer_config.h │ │ └── rlp │ │ │ └── call_frame_rlp.hpp │ │ ├── block_reward.hpp │ │ ├── chain │ │ ├── chain_config.h │ │ ├── genesis_state.hpp │ │ └── chain.cpp │ │ ├── core │ │ ├── rlp │ │ │ ├── signature_rlp.hpp │ │ │ ├── account_rlp.hpp │ │ │ ├── withdrawal_rlp.hpp │ │ │ ├── block_rlp.hpp │ │ │ └── signature_rlp.cpp │ │ ├── variant.hpp │ │ ├── withdrawal.hpp │ │ ├── signature.hpp │ │ ├── fmt │ │ │ ├── int_fmt.hpp │ │ │ └── bytes_fmt.hpp │ │ └── contract │ │ │ └── abi_decode_error.cpp │ │ ├── fmt │ │ └── event_trace_fmt.hpp │ │ ├── rlp │ │ └── config.hpp │ │ ├── create_contract_address.hpp │ │ ├── db │ │ ├── file_db.hpp │ │ └── block_db.hpp │ │ └── metrics │ │ └── block_metrics.hpp ├── statesync │ ├── statesync_version.h │ └── statesync_version.cpp └── rpc │ └── CMakeLists.txt ├── CODEOWNERS ├── utils ├── clang-tidy-auto-const │ ├── NOTICE │ └── CMakeLists.txt └── CMakeLists.txt ├── .github └── workflows │ └── license.yml ├── monad └── __init__.py ├── cmd ├── vm │ ├── type-check │ │ └── CMakeLists.txt │ ├── mce │ │ └── src │ │ │ └── instrumentation_device.hpp │ └── parser │ │ └── CMakeLists.txt └── monad │ ├── file_io.hpp │ └── runloop_ethereum.hpp ├── third_party ├── c-kzg-4844-builder │ ├── src │ │ └── c-kzg-4844 │ │ │ └── trusted_setup.hpp │ └── cmake │ │ └── trusted_setup.cpp.in └── go-ethereum │ └── core │ └── vm │ └── testdata │ └── precompiles │ └── fail-blsMapG1.json └── .vscode └── settings.json /cmake/dummy/intxConfig.cmake: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cmake/dummy/ethashConfig.cmake: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cmake/dummy/nlohmann_jsonConfig.cmake: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/compile_benchmarks/stop: -------------------------------------------------------------------------------- 1 | 00 -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | build 3 | docker 4 | -------------------------------------------------------------------------------- /test/vm/data/regression_tests/push_several.evm: -------------------------------------------------------------------------------- 1 | `a _ -------------------------------------------------------------------------------- /scripts/vm/benchmark-analysis/.python-version: -------------------------------------------------------------------------------- 1 | 3.12 2 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/empty/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/empty/contract: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_0/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_1/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_10/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_11/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_12/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_13/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_14/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_15/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_16/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_17/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_18/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_19/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_2/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_20/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_21/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_22/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_23/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_24/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_25/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_26/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_27/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_28/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_29/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_3/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_30/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_31/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_32/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_4/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_5/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_6/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_7/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_8/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_9/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/counting_loop/calldata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /category/core/toolchains/blacklist.tsan: -------------------------------------------------------------------------------- 1 | src:*/boost/lockfree/* 2 | 3 | -------------------------------------------------------------------------------- /scripts/root/sudoers.d/drop_caches: -------------------------------------------------------------------------------- 1 | ALL ALL=(root) NOPASSWD: /usr/local/bin/drop_caches 2 | -------------------------------------------------------------------------------- /scripts/root/bin/drop_caches: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sync 4 | echo 3 > /proc/sys/vm/drop_caches 5 | 6 | -------------------------------------------------------------------------------- /scripts/root/etc/security/limits.d/memlock.conf: -------------------------------------------------------------------------------- 1 | * soft memlock 8388608 2 | * hard memlock 8388608 3 | -------------------------------------------------------------------------------- /scripts/root/etc/sysctl.d/monad-perf.conf: -------------------------------------------------------------------------------- 1 | kernel.kptr_restrict = 0 2 | kernel.perf_event_paranoid = 0 3 | -------------------------------------------------------------------------------- /test/data/checkpoint/code: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/checkpoint/code -------------------------------------------------------------------------------- /test/data/checkpoint/accounts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/checkpoint/accounts -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | /category/vm @baltoli @andreaslyn 2 | /test/vm @baltoli @andreaslyn 3 | /cmd/vm @baltoli @andreaslyn -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/0 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/1 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/2 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/256: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/256 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/257: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/257 -------------------------------------------------------------------------------- /test/vm/data/regression_tests/cold_warm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/regression_tests/cold_warm -------------------------------------------------------------------------------- /test/data/blocks/bad_decode_blocks/46402: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/bad_decode_blocks/46402 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/46402: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/46402 -------------------------------------------------------------------------------- /test/vm/data/regression_tests/bad_gas.evm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/regression_tests/bad_gas.evm -------------------------------------------------------------------------------- /scripts/dev/blktrace/dump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Rendering binary log $1 into text ..." 3 | blkparse -i $1 -t | grep " C R " > out.txt 4 | -------------------------------------------------------------------------------- /test/data/blocks/bad_decompress_blocks/46402: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/bad_decompress_blocks/46402 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/14000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/14000000 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/2397315: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/2397315 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/2730000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/2730000 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/2730001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/2730001 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/2730002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/2730002 -------------------------------------------------------------------------------- /test/data/blocks/compressed_blocks/2730009: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/data/blocks/compressed_blocks/2730009 -------------------------------------------------------------------------------- /test/vm/data/regression_tests/bad_result.evm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/regression_tests/bad_result.evm -------------------------------------------------------------------------------- /test/vm/data/regression_tests/balance_check: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/regression_tests/balance_check -------------------------------------------------------------------------------- /test/vm/data/regression_tests/fuzzer_01.evm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/regression_tests/fuzzer_01.evm -------------------------------------------------------------------------------- /category/core/monad/tests/callgrind/_keccak_0.callgrind.json: -------------------------------------------------------------------------------- 1 | { 2 | " total": 4417, 3 | "ethash_keccak256": 44, 4 | "keccakf1600_bmi": 4373 5 | } -------------------------------------------------------------------------------- /category/core/monad/tests/callgrind/_keccak_20.callgrind.json: -------------------------------------------------------------------------------- 1 | { 2 | " total": 4469, 3 | "ethash_keccak256": 96, 4 | "keccakf1600_bmi": 4373 5 | } -------------------------------------------------------------------------------- /category/core/monad/tests/callgrind/_keccak_32.callgrind.json: -------------------------------------------------------------------------------- 1 | { 2 | " total": 4449, 3 | "ethash_keccak256": 76, 4 | "keccakf1600_bmi": 4373 5 | } -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERBOSE=1 \ 4 | cmake \ 5 | --build build \ 6 | --config ${CMAKE_BUILD_TYPE:-RelWithDebInfo} \ 7 | --target all 8 | -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_0/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_0/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_1/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_1/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_10/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_10/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_11/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_11/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_12/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_12/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_13/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_13/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_14/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_14/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_15/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_15/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_16/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_16/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_17/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_17/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_18/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_18/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_19/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_19/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_2/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_2/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_20/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_20/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_21/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_21/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_22/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_22/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_23/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_23/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_24/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_24/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_25/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_25/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_26/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_26/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_27/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_27/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_28/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_28/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_29/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_29/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_3/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_3/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_30/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_30/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_31/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_31/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_32/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_32/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_4/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_4/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_5/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_5/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_6/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_6/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_7/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_7/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_8/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_8/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/push_9/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/push_9/contract -------------------------------------------------------------------------------- /test/vm/data/execution_benchmarks/basic/counting_loop/contract: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/category-labs/monad/HEAD/test/vm/data/execution_benchmarks/basic/counting_loop/contract -------------------------------------------------------------------------------- /category/core/monad/tests/callgrind/keccak_0.json: -------------------------------------------------------------------------------- 1 | { 2 | "binary_name": "ethash-test", 3 | "function_name": "ethash_keccak256", 4 | "args": ["--gtest_filter=keccak/bytes.256/0"] 5 | } -------------------------------------------------------------------------------- /category/core/monad/tests/callgrind/keccak_20.json: -------------------------------------------------------------------------------- 1 | { 2 | "binary_name": "ethash-test", 3 | "function_name": "ethash_keccak256", 4 | "args": ["--gtest_filter=keccak/bytes.256/20"] 5 | } -------------------------------------------------------------------------------- /category/core/monad/tests/callgrind/keccak_32.json: -------------------------------------------------------------------------------- 1 | { 2 | "binary_name": "ethash-test", 3 | "function_name": "ethash_keccak256", 4 | "args": ["--gtest_filter=keccak/bytes.256/32"] 5 | } -------------------------------------------------------------------------------- /scripts/configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cmake \ 4 | -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \ 5 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE:-RelWithDebInfo} \ 6 | -B build \ 7 | -G Ninja 8 | -------------------------------------------------------------------------------- /scripts/vm/fuzzer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | root_dir=`dirname "$0"`/../.. 4 | fuzzer="$root_dir"/build/test/vm/fuzzer/monad-compiler-fuzzer 5 | 6 | MONAD_COMPILER_FUZZING=1 exec -a "$0" "$fuzzer" $@ 7 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/eip150.cmake: -------------------------------------------------------------------------------- 1 | set(eip150_excluded_tests 2 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding01.json" 3 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding127.json" 4 | ) 5 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/eip158.cmake: -------------------------------------------------------------------------------- 1 | set(eip158_excluded_tests 2 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding01.json" 3 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding127.json" 4 | ) 5 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/byzantium.cmake: -------------------------------------------------------------------------------- 1 | set(byzantium_excluded_tests 2 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding01.json" 3 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding127.json" 4 | ) 5 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/frontier.cmake: -------------------------------------------------------------------------------- 1 | set(frontier_excluded_tests 2 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding01.json" 3 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding127.json" 4 | ) 5 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/homestead.cmake: -------------------------------------------------------------------------------- 1 | set(homestead_excluded_tests 2 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding01.json" 3 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding127.json" 4 | ) 5 | -------------------------------------------------------------------------------- /scripts/dev/blktrace/capture.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$EUID" -ne 0 ]; then 3 | echo "Please run me as root" 4 | exit 1 5 | fi 6 | echo "Capturing five minutes of i/o latencies from $1 ..." 7 | blktrace -d $1 -w 300 8 | 9 | -------------------------------------------------------------------------------- /scripts/vm/typechecker-fuzzer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | root_dir=`dirname "$0"`/../.. 4 | fuzzer="$root_dir"/build/test/vm/fuzzer/monad-typechecker-fuzzer 5 | 6 | MONAD_COMPILER_FUZZING=1 exec -a "$0" "$fuzzer" $@ 7 | -------------------------------------------------------------------------------- /scripts/vm/benchmark-analysis/.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 120 3 | extend-select = B9, TC1 4 | extend-ignore = B907,B950,E,W1,W2,W3,W4,W5 5 | per-file-ignores = 6 | */__init__.py: F401 7 | type-checking-strict = true -------------------------------------------------------------------------------- /scripts/root/bin/reserve_hugepages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo 4 > /sys/devices/system/node/node${1}/hugepages/hugepages-1048576kB/nr_hugepages 4 | echo 2000 > /sys/devices/system/node/node${1}/hugepages/hugepages-2048kB/nr_hugepages 5 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/constantinoplefix.cmake: -------------------------------------------------------------------------------- 1 | set(constantinoplefix_excluded_tests 2 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding01.json" 3 | "TransactionTests.ttWrongRLP/RLPIncorrectByteEncoding127.json" 4 | ) 5 | -------------------------------------------------------------------------------- /category/core/toolchains/gcc-avx512.cmake: -------------------------------------------------------------------------------- 1 | # This toolchain is good for a basic AVX512 CPU 2 | set(CMAKE_ASM_FLAGS_INIT "-march=skylake-avx512") 3 | set(CMAKE_C_FLAGS_INIT "-march=skylake-avx512") 4 | set(CMAKE_CXX_FLAGS_INIT "-march=skylake-avx512") 5 | -------------------------------------------------------------------------------- /scripts/vm/build-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERBOSE=1 \ 4 | cmake \ 5 | --build build \ 6 | --config RelWithDebInfo \ 7 | --target vm-unit-tests \ 8 | --target compiler-blockchain-tests \ 9 | --target interpreter-blockchain-tests 10 | -------------------------------------------------------------------------------- /category/core/toolchains/gcc-avx2.cmake: -------------------------------------------------------------------------------- 1 | # This toolchain is good for an AVX2 CPU with arbitrary precision arithmetic extensions 2 | set(CMAKE_ASM_FLAGS_INIT "-march=haswell") 3 | set(CMAKE_C_FLAGS_INIT "-march=haswell") 4 | set(CMAKE_CXX_FLAGS_INIT "-march=haswell") 5 | -------------------------------------------------------------------------------- /category/core/toolchains/gcc-tsan.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_ASM_FLAGS_INIT "-march=haswell") 2 | set(CMAKE_C_FLAGS_INIT "-march=haswell -fsanitize=thread -fno-omit-frame-pointer -Wno-error=tsan -g") 3 | set(CMAKE_CXX_FLAGS_INIT "-march=haswell -fsanitize=thread -fno-omit-frame-pointer -Wno-error=tsan -g") 4 | -------------------------------------------------------------------------------- /scripts/vm/ci-fuzzer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -uxo pipefail 3 | 4 | script_dir=$(dirname "$0") 5 | 6 | "$script_dir/tmux-fuzzer.sh" start --base-seed=143 7 | sleep 300 8 | 9 | "$script_dir/tmux-fuzzer.sh" status | grep "TERMINATED" 10 | if [ $? -eq 0 ]; then 11 | exit 1 12 | fi -------------------------------------------------------------------------------- /scripts/vm/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euxo pipefail 4 | 5 | export UBSAN_OPTIONS="halt_on_error=1" 6 | ulimit -s 131072 7 | 8 | ./build/test/vm/unit/vm-unit-tests 9 | ./build/test/vm/blockchain/compiler-blockchain-tests 10 | ./build/test/vm/blockchain/interpreter-blockchain-tests 11 | 12 | 13 | -------------------------------------------------------------------------------- /scripts/ubuntu-build/install-boost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | apt-get update 4 | 5 | apt-get install -y \ 6 | libboost-fiber1.83.0 \ 7 | libboost-json1.83.0 \ 8 | libboost-stacktrace1.83.0 9 | 10 | apt-get install -y \ 11 | libboost-fiber1.83-dev \ 12 | libboost-json1.83-dev \ 13 | libboost-stacktrace1.83-dev \ 14 | libboost1.83-dev 15 | -------------------------------------------------------------------------------- /scripts/vm/benchmark-analysis/Makefile: -------------------------------------------------------------------------------- 1 | RUN := uv run 2 | 3 | .PHONY: check 4 | check: 5 | $(RUN) mypy src 6 | $(RUN) black --check src 7 | $(RUN) isort --check src 8 | $(RUN) autoflake --quiet --check src 9 | $(RUN) flake8 src 10 | 11 | .PHONY: format 12 | format: 13 | $(RUN) autoflake --quiet --in-place src 14 | $(RUN) isort src 15 | $(RUN) black src -------------------------------------------------------------------------------- /category/core/toolchains/gcc-asan.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_ASM_FLAGS_INIT "-march=haswell") 2 | set(CMAKE_C_FLAGS_INIT "-march=haswell -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -g") 3 | set(CMAKE_CXX_FLAGS_INIT "-march=haswell -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -g") 4 | set(CMAKE_EXE_LINKER_FLAGS_INIT "-fsanitize=address -fsanitize=undefined") 5 | -------------------------------------------------------------------------------- /category/core/monad/tests/disas/core-tl_tid.dis: -------------------------------------------------------------------------------- 1 | 0000000000000000 : 2 | 0: 50 push %rax 3 | 1: e8 00 00 00 00 call 6 4 | 2: R_X86_64_PLT32 gettid-0x4 5 | 6: 64 89 04 25 00 00 00 00 mov %eax,%fs:0x0 6 | a: R_X86_64_TPOFF32 tl_tid 7 | e: 58 pop %rax 8 | f: c3 ret 9 | -------------------------------------------------------------------------------- /category/mpt/test/many_nested_updates_simple_flat.json: -------------------------------------------------------------------------------- 1 | { 2 | "updates": { 3 | "ac4c09c28206e7e35594aa6b342f5d0a3a5e4842fab428f762e6e282e5c1657c": "b36711eb3906a7c8603d71d409e7a54d87bdc1f70442027a5b", 4 | "212b86b49e656acf0641169a0b59f4e629439f25d9d4654fec8d4819fb40d6ba": "1c441ae6" 5 | }, 6 | "root_hash": "0d203b1bed203d355d6201a703774018a182975fc4fcae0dae19825cd40ccd17" 7 | } -------------------------------------------------------------------------------- /category/vm/runtime/exit.S: -------------------------------------------------------------------------------- 1 | .text 2 | .globl monad_vm_runtime_exit 3 | .type monad_vm_runtime_exit, @function 4 | .align 16 5 | monad_vm_runtime_exit: 6 | movq %rdi, %rsp 7 | popq %r15 8 | popq %r14 9 | popq %r13 10 | popq %r12 11 | popq %rbx 12 | popq %rbp 13 | retq 14 | .size monad_vm_runtime_exit, .-monad_vm_runtime_exit 15 | .section .note.GNU-stack,"",@progbits 16 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/osaka.cmake: -------------------------------------------------------------------------------- 1 | set(osaka_excluded_tests 2 | # Features modified by Osaka EIPs that we haven't yet implemented support for 3 | "BlockchainTests.cancun/eip4844_blobs/*" 4 | 5 | # New features in Osaka 6 | "BlockchainTests.osaka/eip7594_peerdas/*" 7 | "BlockchainTests.osaka/eip7934_block_rlp_limit/*" 8 | "BlockchainTests.osaka/eip7825_transaction_gas_limit_cap/*" 9 | ) -------------------------------------------------------------------------------- /scripts/apply-clang-format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | script_dir="$(dirname "$0")" 4 | root_dir="$(realpath "$script_dir/..")" 5 | 6 | clang-format-19 \ 7 | -i $(\ 8 | find \ 9 | "${root_dir}"/category \ 10 | "${root_dir}"/cmd \ 11 | "${root_dir}"/test \ 12 | -name '*.hpp' -or \ 13 | -name '*.cpp' -or \ 14 | -name '*.c' -or \ 15 | -name '*.h') -------------------------------------------------------------------------------- /category/core/toolchains/clang-tsan.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_ASM_FLAGS_INIT "-march=haswell") 2 | set(CMAKE_C_FLAGS_INIT "-march=haswell -fsanitize=thread -fno-omit-frame-pointer -g -fsanitize-blacklist=/mnt/raid0/monad/monad-trie/monad-core/toolchains/blacklist.tsan") 3 | set(CMAKE_CXX_FLAGS_INIT "-march=haswell -fsanitize=thread -fno-omit-frame-pointer -g -fsanitize-blacklist=/mnt/raid0/monad/monad-trie/monad-core/toolchains/blacklist.tsan") 4 | -------------------------------------------------------------------------------- /category/core/keccak_impl.S: -------------------------------------------------------------------------------- 1 | #if defined(__linux__) && defined(__ELF__) 2 | .section .note.GNU-stack,"",%progbits 3 | #endif 4 | 5 | #if defined(__x86_64__) 6 | #if defined(__AVX512F__) 7 | #include 8 | #elif defined(__AVX2__) 9 | #include 10 | #else 11 | #error avx2 or avx512 required 12 | #endif 13 | #else 14 | #error unsupported arch 15 | #endif 16 | -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -Eeuo pipefail 4 | 5 | CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:-$(nproc)} \ 6 | ctest --output-on-failure --timeout 500 --test-dir build 7 | 8 | PYTEST_MATCH_ARGS="" 9 | if [ "${CC}" != "clang" ] || [ "${CMAKE_BUILD_TYPE}" != "RelWithDebInfo" ]; then 10 | PYTEST_MATCH_ARGS="-k not test_callgrind and not test_disas" 11 | fi 12 | 13 | pytest-3 --pyargs monad ${PYTEST_MATCH_ARGS:+"${PYTEST_MATCH_ARGS}"} || [ $? -eq 5 ] 14 | -------------------------------------------------------------------------------- /scripts/ubuntu-build/install-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | packages=( 4 | libarchive-dev 5 | libbenchmark-dev 6 | libbrotli-dev 7 | libcap-dev 8 | libcgroup-dev 9 | libclang-19-dev 10 | libcli11-dev 11 | libcrypto++-dev 12 | libgmock-dev 13 | libgmp-dev 14 | libgtest-dev 15 | libhugetlbfs-dev 16 | libmagicenum-dev 17 | libtbb-dev 18 | liburing-dev 19 | libzstd-dev 20 | ) 21 | 22 | apt-get update 23 | apt-get install -y "${packages[@]}" 24 | -------------------------------------------------------------------------------- /cmake/LinkLLVM.cmake: -------------------------------------------------------------------------------- 1 | function(monad_link_llvm target) 2 | llvm_config(${target} 3 | USE_SHARED true) 4 | 5 | # these options are needed to ignore the spurious ciso646 warning 6 | target_compile_options(${target} PRIVATE $<$:-Wno-cpp>) 7 | target_compile_options(${target} PRIVATE $<$:-Wno-\#warnings>) 8 | 9 | 10 | target_include_directories(${target} 11 | SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS}) 12 | endfunction() 13 | -------------------------------------------------------------------------------- /scripts/ubuntu-build/install-tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | packages=( 4 | apt-utils 5 | ca-certificates 6 | clang-19 7 | clang-tools-19 8 | clang-tidy-19 9 | cmake 10 | curl 11 | dialog 12 | g++-15 13 | gcc-15 14 | gdb 15 | git 16 | gnupg 17 | libhugetlbfs-bin 18 | ninja-build 19 | pkg-config 20 | python-is-python3 21 | python3-pytest 22 | software-properties-common 23 | valgrind 24 | wget 25 | ) 26 | 27 | apt-get update 28 | apt-get install -y "${packages[@]}" 29 | -------------------------------------------------------------------------------- /test/ethereum_test/exclude/prague.cmake: -------------------------------------------------------------------------------- 1 | set(prague_excluded_tests 2 | # Blobs (EIP-4844) 3 | "BlockchainTests.cancun/eip4844_blobs/*" 4 | # Unimplemented Prague EIPs 5 | "BlockchainTests.prague/eip6110_deposits/*" 6 | "BlockchainTests.prague/eip7002_el_triggerable_withdrawals/*" 7 | "BlockchainTests.prague/eip7251_consolidations/*" 8 | "BlockchainTests.prague/eip7685_general_purpose_el_requests/*" 9 | # Long-running tests 10 | "BlockchainTests.prague/eip2935_historical_block_hashes_from_state/block_hashes/block_hashes_history.json" 11 | ) 12 | -------------------------------------------------------------------------------- /utils/clang-tidy-auto-const/NOTICE: -------------------------------------------------------------------------------- 1 | This project includes code from the LLVM Project, which is licensed under the Apache License v2.0 with LLVM Exceptions. 2 | Copyright (c) 2003–2025, LLVM Project. 3 | All rights reserved. 4 | You may obtain a copy of the license at: 5 | https://llvm.org/LICENSE.txt 6 | 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. 7 | LLVM Exceptions apply. See the LICENSE.txt file in the LLVM distribution for details. 8 | -------------------------------------------------------------------------------- /test/vm/data/cachegrind/haswell.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Haswell cache architecture details", 3 | "I1": { 4 | "description": "Level 1 instruction cache details", 5 | "size": 32768, 6 | "assoc": 8, 7 | "line_size": 64 8 | }, 9 | "D1": { 10 | "description": "Level 1 data cache details", 11 | "size": 32768, 12 | "assoc": 8, 13 | "line_size": 64 14 | }, 15 | "LL": { 16 | "description": "Last level instruction cache details", 17 | "size": 8388608, 18 | "assoc": 16, 19 | "line_size": 64 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/license.yml: -------------------------------------------------------------------------------- 1 | name: License 2 | 3 | on: 4 | merge_group: 5 | branches: ["main"] 6 | paths-ignore: 7 | - 'third_party/**' 8 | push: 9 | branches: ["main"] 10 | paths-ignore: 11 | - 'third_party/**' 12 | pull_request: 13 | branches: ["main"] 14 | types: [ opened, synchronize, reopened, edited ] 15 | paths-ignore: 16 | - 'third_party/**' 17 | 18 | jobs: 19 | check-license: 20 | runs-on: ubuntu-24.04-32 21 | 22 | steps: 23 | - name: Checkout repository 24 | uses: actions/checkout@v4 25 | - name: Check licenses 26 | run: .github/workflows/license.sh 27 | -------------------------------------------------------------------------------- /test/vm/unit/runtime/fixture.S: -------------------------------------------------------------------------------- 1 | // fixture.S 2 | .text 3 | .globl tests_trampoline 4 | .type tests_trampoline, @function 5 | .align 16 6 | tests_trampoline: 7 | pushq %rbp 8 | pushq %rbx 9 | pushq %r12 10 | pushq %r13 11 | pushq %r14 12 | pushq %r15 13 | movq %rsp, (%rdi) # save host stack pointer 14 | pushq %rbp # 16-byte align the stack 15 | movq %rdx, %rdi # move lambda ptr into rdi (first arg for call_closure) 16 | call *%rsi # call call_closure (second arg) 17 | int3 # This instruction should never be reached: call_closure is expected to exit via ctx->exit() -------------------------------------------------------------------------------- /cmake/blst.cmake: -------------------------------------------------------------------------------- 1 | set(BLST_SOURCE_DIR "${PROJECT_SOURCE_DIR}/third_party/blst") 2 | 3 | enable_language(ASM) 4 | 5 | add_library(blst STATIC 6 | "${BLST_SOURCE_DIR}/build/assembly.S" 7 | "${BLST_SOURCE_DIR}/src/server.c") 8 | 9 | target_include_directories(blst PUBLIC ${BLST_SOURCE_DIR}/bindings) 10 | 11 | # The compilation options and defintions match what build.sh would do; if you 12 | # upgrade libblst, ensure this is still the case 13 | target_compile_options(blst PRIVATE -Wall -Wextra -Werror) 14 | target_compile_definitions(blst PRIVATE __ADX__) 15 | set_target_properties(blst PROPERTIES POSITION_INDEPENDENT_CODE ON) 16 | 17 | add_library(blst::blst ALIAS blst) 18 | -------------------------------------------------------------------------------- /scripts/vm/copy-s-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SOURCE_DIR=$(realpath "$1") 6 | TARGET_DIR=$(realpath "$2") 7 | 8 | mkdir -p "$TARGET_DIR" 9 | 10 | find "$SOURCE_DIR" -type f -name '*.s' -print0 | while IFS= read -r -d '' src_file; do 11 | # Skip files already in the target directory 12 | if [[ "$src_file" == "$TARGET_DIR"* ]]; then 13 | continue 14 | fi 15 | 16 | filename=$(basename "$src_file") 17 | dest_file="$TARGET_DIR/$filename" 18 | 19 | # Copy only if destination doesn't exist or files differ 20 | if [[ ! -e "$dest_file" ]] || ! cmp -s "$src_file" "$dest_file"; then 21 | cp "$src_file" "$dest_file" 22 | fi 23 | done -------------------------------------------------------------------------------- /category/core/toolchains/clang-fuzz.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_ASM_FLAGS_INIT "-march=haswell") 2 | set(CMAKE_C_FLAGS_INIT "-march=haswell -fsanitize=address -fsanitize=undefined -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -UNDEBUG -fsanitize-coverage=inline-8bit-counters -fsanitize-coverage=trace-cmp -fsanitize-coverage=pc-table") 3 | set(CMAKE_CXX_FLAGS_INIT "-march=haswell -fsanitize=address -fsanitize=undefined -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -UNDEBUG -fsanitize-coverage=inline-8bit-counters -fsanitize-coverage=trace-cmp -fsanitize-coverage=pc-table") 4 | #set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld") 5 | -------------------------------------------------------------------------------- /category/core/monad/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | -------------------------------------------------------------------------------- /category/core/monad/tests/disas/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | -------------------------------------------------------------------------------- /scripts/vm/benchmark-analysis/src/compare_benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | -------------------------------------------------------------------------------- /scripts/vm/benchmark-analysis/src/compare_implementations/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | -------------------------------------------------------------------------------- /utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_subdirectory(clang-tidy-auto-const) 17 | -------------------------------------------------------------------------------- /monad/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | import sys 17 | 18 | assert sys.version_info >= (3,) 19 | -------------------------------------------------------------------------------- /category/core/monad/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | import sys 17 | 18 | assert sys.version_info >= (3,) 19 | -------------------------------------------------------------------------------- /category/core/monad/tests/disas/core-tl_tid.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | obj = "libmonad_core.a" 17 | syms = [ 18 | "init_tl_tid", 19 | ] 20 | -------------------------------------------------------------------------------- /category/core/endian.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | static_assert(std::endian::native == std::endian::little); 21 | -------------------------------------------------------------------------------- /category/core/concat.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #define MONAD_CORE_CONCAT2(a, b) a##b 19 | #define MONAD_CORE_CONCAT(a, b) MONAD_CORE_CONCAT2(a, b) 20 | -------------------------------------------------------------------------------- /category/core/likely.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #define MONAD_LIKELY(x) __builtin_expect(!!(x), 1) 19 | #define MONAD_UNLIKELY(x) __builtin_expect(!!(x), 0) 20 | -------------------------------------------------------------------------------- /test/vm/unit/test_params.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include "test_params.hpp" 17 | 18 | namespace monad::vm::compiler::test 19 | { 20 | struct TestParams params = TestParams(false); 21 | } 22 | -------------------------------------------------------------------------------- /category/core/cpu_relax.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #ifdef __x86_64__ 19 | #define cpu_relax() __builtin_ia32_pause(); 20 | #else 21 | #error unsupported arch 22 | #endif 23 | -------------------------------------------------------------------------------- /category/core/monad/tests/disas/fiber/priority_queue.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | obj = "libmonad_core.a" 17 | syms = [ 18 | "monad::fiber::PriorityQueue::pop()", 19 | "monad::fiber::PriorityQueue::push(boost::fibers::context*)", 20 | ] 21 | -------------------------------------------------------------------------------- /category/core/size_of.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | MONAD_NAMESPACE_BEGIN 21 | 22 | template 23 | struct SizeOf; 24 | 25 | MONAD_NAMESPACE_END 26 | -------------------------------------------------------------------------------- /cmd/vm/type-check/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_executable(directory-type-check directory_type_check.cpp) 17 | monad_compile_options(directory-type-check) 18 | target_link_libraries(directory-type-check PRIVATE monad_execution) 19 | -------------------------------------------------------------------------------- /category/vm/core/cases.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | namespace monad::vm 19 | { 20 | template 21 | struct Cases : Ts... 22 | { 23 | using Ts::operator()...; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /category/execution/monad/min_base_fee.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | extern "C" uint64_t monad_min_base_fee_wei(monad_revision) 19 | { 20 | return 100'000'000'000; 21 | } 22 | -------------------------------------------------------------------------------- /third_party/c-kzg-4844-builder/src/c-kzg-4844/trusted_setup.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | namespace c_kzg_4844 20 | { 21 | std::span trusted_setup_data() noexcept; 22 | } 23 | -------------------------------------------------------------------------------- /category/core/monad/tests/disas/core-spinlock.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | obj = "libmonad_core_disas.a" 17 | syms = [ 18 | "spinlock_init_disas", 19 | "spinlock_try_lock_disas", 20 | "spinlock_lock_disas", 21 | "spinlock_unlock_disas", 22 | ] 23 | -------------------------------------------------------------------------------- /category/vm/llvm/entry.S: -------------------------------------------------------------------------------- 1 | // This function acts as a trampoline to make the llvm backend's exit 2 | // compatible with the existing runtime exit mechanism. It sets up the stack and 3 | // preserved registers so that `monad_runtime_exit` can clean them up in the 4 | // same way as it does for compiled code. 5 | .text 6 | .globl llvm_runtime_trampoline 7 | .type llvm_runtime_trampoline, @function 8 | .align 16 9 | llvm_runtime_trampoline: 10 | pushq %rbp 11 | pushq %rbx 12 | pushq %r12 13 | pushq %r13 14 | pushq %r14 15 | pushq %r15 16 | // rdi contains first argument to contract function 17 | // rsi contains second argument to contract function 18 | movq %rsp, (%rcx) // save stack ptr (adjust rdx if args added to contract function) 19 | jmp *%rdx // jump to contract function (adjust rsi if args added to contract function) 20 | .size llvm_runtime_trampoline, .-llvm_runtime_trampoline 21 | .section .note.GNU-stack,"",@progbits 22 | -------------------------------------------------------------------------------- /category/core/cpuset.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | cpu_set_t monad_parse_cpuset(char *); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /category/mpt/cli_tool_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | extern int main_impl( 23 | std::ostream &cout, std::ostream &cerr, std::span args); 24 | -------------------------------------------------------------------------------- /category/core/tl_tid.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | 20 | static_assert(__builtin_types_compatible_p(pid_t, int)); 21 | 22 | __thread int tl_tid = 0; 23 | 24 | void init_tl_tid() 25 | { 26 | tl_tid = gettid(); 27 | } 28 | -------------------------------------------------------------------------------- /cmd/vm/mce/src/instrumentation_device.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | enum class InstrumentationDevice 19 | { 20 | // Use cachegrind to collect measurements. 21 | Cachegrind, 22 | // Use a simple wall clock timer to collect measurements. 23 | WallClock 24 | }; 25 | -------------------------------------------------------------------------------- /scripts/genpoststate/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=linux/amd64 fedora:38 2 | 3 | ENV TESTDIR=ethtest 4 | ARG GAT_VERSION="1.12.0-e501b3b0" 5 | 6 | RUN mkdir $TESTDIR 7 | WORKDIR $TESTDIR 8 | 9 | RUN dnf -y install jq \ 10 | && dnf -y clean all \ 11 | && rm -rf /var/cache/yum 12 | 13 | RUN curl -O https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-${GAT_VERSION}.tar.gz 14 | RUN curl -O https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-${GAT_VERSION}.tar.gz.asc 15 | 16 | RUN gpg --recv-keys F9585DE6 C2FF8BBF 9BA28146 7B9E2481 D2A67EAC && gpg --verify geth-alltools-linux-amd64-${GAT_VERSION}.tar.gz.asc 17 | 18 | RUN tar -xvf geth-alltools-linux-amd64-${GAT_VERSION}.tar.gz \ 19 | && mv geth-alltools-linux-amd64-${GAT_VERSION}/evm evm \ 20 | && rm -rf geth-alltools-linux-amd64-${GAT_VERSION}.tar.gz geth-alltools-linux-amd64-${GAT_VERSION}.tar.gz.asc geth-alltools-linux-amd64-${GAT_VERSION} 21 | 22 | COPY gps.sh /ethtest/gps.sh 23 | 24 | ENTRYPOINT ["/ethtest/gps.sh"] 25 | -------------------------------------------------------------------------------- /category/core/cleanup.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | void cleanup_free(char *const *); 26 | 27 | void cleanup_close(int *); 28 | 29 | void cleanup_fclose(FILE *const *); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /category/mpt/bench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | # benchmark async reads 17 | add_executable(async_read_bench "async_read_bench.cpp") 18 | monad_compile_options(async_read_bench) 19 | target_link_libraries( 20 | async_read_bench PUBLIC monad_trie monad_async monad_core 21 | CLI11::CLI11 quill::quill) 22 | -------------------------------------------------------------------------------- /category/core/keccak.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | #define KECCAK256_SIZE 32 24 | 25 | void keccak256( 26 | unsigned char const *in, unsigned long len, 27 | unsigned char out[KECCAK256_SIZE]); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /category/core/math_disas.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | size_t round_up_disas(size_t const x, size_t const y) 25 | { 26 | return round_up(x, y); 27 | } 28 | 29 | MONAD_NAMESPACE_END 30 | -------------------------------------------------------------------------------- /category/statesync/statesync_version.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | uint32_t monad_statesync_version(); 26 | 27 | bool monad_statesync_client_compatible(uint32_t version); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /test/unit/common/src/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | int main(int argc, char **argv) 20 | { 21 | ::testing::InitGoogleTest(&argc, argv); 22 | testing::AddGlobalTestEnvironment(new monad::test::Environment); 23 | return RUN_ALL_TESTS(); 24 | } 25 | -------------------------------------------------------------------------------- /category/core/procfs/statm.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | bool monad_procfs_self_statm(long *size, long *resident, long *shared); 26 | 27 | long monad_procfs_self_resident(); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /category/execution/monad/min_base_fee.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" 24 | { 25 | #endif 26 | 27 | uint64_t monad_min_base_fee_wei(enum monad_revision); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /category/execution/monad/reserve_balance.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" 24 | { 25 | #endif 26 | 27 | unsigned monad_default_max_reserve_balance_mon(enum monad_revision); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /category/vm/runtime/allocator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | namespace monad::vm::runtime 20 | { 21 | thread_local CachedAllocatorList EvmStackAllocatorMeta::cache_list; 22 | thread_local CachedAllocatorList EvmMemoryAllocatorMeta::cache_list; 23 | } 24 | -------------------------------------------------------------------------------- /category/vm/compiler/ir/poly_typed/infer.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace monad::vm::compiler::poly_typed 21 | { 22 | std::vector infer_types( 23 | std::unordered_map const &jumpdests, 24 | std::vector &&pre_blocks); 25 | } 26 | -------------------------------------------------------------------------------- /category/execution/ethereum/trace/tracer_config.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | enum monad_tracer_config 24 | { 25 | NOOP_TRACER = 0, 26 | CALL_TRACER = 1, 27 | PRESTATE_TRACER = 2, 28 | STATEDIFF_TRACER = 3, 29 | ACCESS_LIST_TRACER = 4, 30 | }; 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /cmd/vm/parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_executable(parser-tool) 17 | 18 | target_sources(parser-tool PRIVATE 19 | parser_tool.cpp) 20 | 21 | target_include_directories(parser-tool 22 | PUBLIC src/ 23 | ) 24 | 25 | target_link_libraries(parser-tool 26 | PRIVATE monad_execution 27 | PRIVATE evmc::evmc 28 | PRIVATE CLI11::CLI11 29 | ) 30 | 31 | monad_compile_options(parser-tool) 32 | -------------------------------------------------------------------------------- /category/execution/ethereum/block_reward.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | MONAD_NAMESPACE_BEGIN 24 | 25 | struct Block; 26 | class State; 27 | 28 | template 29 | void apply_block_reward(State &, Block const &); 30 | 31 | MONAD_NAMESPACE_END 32 | -------------------------------------------------------------------------------- /category/vm/utils/traits.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace monad::vm::utils 21 | { 22 | template 23 | consteval bool same_signature(X (*)(Xs...), Y (*)(Ys...)) noexcept 24 | { 25 | return std::is_same_v && (std::is_same_v && ...); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.formatting.provider": "black", 3 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 4 | "files.exclude": { 5 | "**/__pycache__": true 6 | }, 7 | "files.associations": { 8 | "*.ipp": "cpp", 9 | "*.tcc": "cpp", 10 | "__hash_table": "cpp", 11 | "__locale": "cpp", 12 | "__node_handle": "cpp", 13 | "__split_buffer": "cpp", 14 | "__tree": "cpp", 15 | "array": "cpp", 16 | "bitset": "cpp", 17 | "chrono": "cpp", 18 | "deque": "cpp", 19 | "filesystem": "cpp", 20 | "format": "cpp", 21 | "forward_list": "cpp", 22 | "functional": "cpp", 23 | "initializer_list": "cpp", 24 | "list": "cpp", 25 | "locale": "cpp", 26 | "map": "cpp", 27 | "set": "cpp", 28 | "span": "cpp", 29 | "stacktrace": "cpp", 30 | "string": "cpp", 31 | "string_view": "cpp", 32 | "unordered_map": "cpp", 33 | "unordered_set": "cpp", 34 | "vector": "cpp", 35 | "optional": "cpp" 36 | } 37 | } -------------------------------------------------------------------------------- /category/execution/ethereum/chain/chain_config.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | enum monad_chain_config 24 | { 25 | CHAIN_CONFIG_ETHEREUM_MAINNET = 0, 26 | CHAIN_CONFIG_MONAD_DEVNET = 1, 27 | CHAIN_CONFIG_MONAD_TESTNET = 2, 28 | CHAIN_CONFIG_MONAD_MAINNET = 3, 29 | }; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /category/execution/monad/chain/monad_mainnet_alloc.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | MONAD_NAMESPACE_BEGIN 21 | 22 | inline constexpr char const *MONAD_MAINNET_ALLOC = R"( 23 | { 24 | "f12cEa359512B8CcD5E7b33B3d308A174837250C": { 25 | "wei_balance": "100000000000000000000000000000" 26 | } 27 | } 28 | )"; 29 | 30 | MONAD_NAMESPACE_END 31 | -------------------------------------------------------------------------------- /category/vm/interpreter/entry.S: -------------------------------------------------------------------------------- 1 | // This function acts as a trampoline to make the interpreter's core loop 2 | // compatible with the existing runtime exit mechanism. It sets up the stack and 3 | // preserved registers so that `monad_vm_runtime_exit` can clean them up in the 4 | // same way as it does for compiled code. 5 | .text 6 | .globl monad_vm_interpreter_trampoline 7 | .type monad_vm_interpreter_trampoline, @function 8 | .align 16 9 | monad_vm_interpreter_trampoline: 10 | pushq %rbp 11 | pushq %rbx 12 | pushq %r12 13 | pushq %r13 14 | pushq %r14 15 | pushq %r15 16 | movq %rsp, (%rdi) 17 | pushq %rbp // for stack alignment 18 | // Use the call instruction to enter the interpreter loop, so that the 19 | // trampoline is the return address of the interpreter loop. Stack 20 | // backtraces will deterministically end at the trampoline like this, 21 | // because the trampoline is not in the `.eh_frame` unwind table. 22 | call *%r8 23 | int3 // unreachable 24 | .size monad_vm_interpreter_trampoline, .-monad_vm_interpreter_trampoline 25 | .section .note.GNU-stack,"",@progbits 26 | -------------------------------------------------------------------------------- /category/core/result.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | namespace outcome = BOOST_OUTCOME_V2_NAMESPACE; 25 | namespace outcome_e = outcome::experimental; 26 | 27 | template 28 | using Result = outcome_e::status_result; 29 | 30 | MONAD_NAMESPACE_END 31 | -------------------------------------------------------------------------------- /category/execution/ethereum/core/rlp/signature_rlp.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | MONAD_RLP_NAMESPACE_BEGIN 24 | 25 | Result decode_sc(byte_string_view &); 26 | 27 | MONAD_RLP_NAMESPACE_END 28 | -------------------------------------------------------------------------------- /category/vm/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | enable_language(C) 17 | 18 | add_library(monad-vm-core OBJECT) 19 | 20 | target_sources(monad-vm-core PRIVATE 21 | "assert.cpp" 22 | "assert.h" 23 | "cases.hpp" 24 | ) 25 | 26 | monad_compile_options(monad-vm-core) 27 | 28 | target_include_directories(monad-vm-core 29 | PUBLIC ${CATEGORY_MAIN_DIR} 30 | ) 31 | 32 | add_library(monad-vm::monad-vm-core ALIAS monad-vm-core) 33 | -------------------------------------------------------------------------------- /category/vm/interpreter/instruction_stats.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace monad::vm::interpreter::stats 21 | { 22 | #ifdef MONAD_VM_INTERPRETER_STATS 23 | void begin(std::uint8_t const opcode); 24 | void end(); 25 | #else 26 | [[gnu::always_inline]] inline void begin(std::uint8_t const) {} 27 | 28 | [[gnu::always_inline]] inline void end() {} 29 | #endif 30 | } 31 | -------------------------------------------------------------------------------- /scripts/vm/benchmark-analysis/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "benchmark-analysis" 3 | version = "0.1.0" 4 | description = "Add your description here" 5 | readme = "README.md" 6 | requires-python = ">=3.12" 7 | dependencies = [ 8 | "pandas>=2.2.3", 9 | "pandas-stubs>=2.2.3.241126", 10 | "scipy>=1.15.0", 11 | "tabulate>=0.9.0", 12 | ] 13 | 14 | [project.scripts] 15 | compare-benchmarks = "compare_benchmarks.main:main" 16 | compare-implementations = "compare_implementations.main:main" 17 | 18 | [tool.uv] 19 | package = true 20 | 21 | [tool.autoflake] 22 | recursive = true 23 | expand-star-imports = true 24 | remove-all-unused-imports = true 25 | ignore-init-module-imports = true 26 | remove-duplicate-keys = true 27 | remove-unused-variables = true 28 | 29 | [tool.black] 30 | line-length = 120 31 | skip-string-normalization = true 32 | 33 | [tool.mypy] 34 | disallow_untyped_defs = true 35 | 36 | [dependency-groups] 37 | dev = [ 38 | "autoflake>=2.3.1", 39 | "black>=24.10.0", 40 | "flake8>=7.1.1", 41 | "isort>=5.13.2", 42 | "mypy>=1.14.1", 43 | "pandas-stubs>=2.2.3.241126", 44 | "scipy-stubs>=1.15.0.0", 45 | ] 46 | -------------------------------------------------------------------------------- /category/core/tl_tid.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | #include 24 | 25 | extern __thread int tl_tid; 26 | 27 | void init_tl_tid(); 28 | 29 | static inline int get_tl_tid() 30 | { 31 | if (MONAD_UNLIKELY(!tl_tid)) { 32 | init_tl_tid(); 33 | } 34 | return tl_tid; 35 | } 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /category/execution/monad/monad_transaction_gas.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | template 25 | uint64_t compute_gas_refund( 26 | Transaction const &, uint64_t gas_remaining, uint64_t refund); 27 | 28 | MONAD_NAMESPACE_END 29 | -------------------------------------------------------------------------------- /category/core/basic_formatter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | namespace fmt = fmtquill::v10; 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | struct BasicFormatter 27 | { 28 | template 29 | constexpr auto parse(ParseContext &ctx) 30 | { 31 | return ctx.begin(); 32 | } 33 | }; 34 | 35 | MONAD_NAMESPACE_END 36 | -------------------------------------------------------------------------------- /category/execution/monad/staking/execute_block_prelude.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | MONAD_NAMESPACE_BEGIN 22 | 23 | class State; 24 | 25 | MONAD_NAMESPACE_END 26 | 27 | MONAD_STAKING_NAMESPACE_BEGIN 28 | 29 | template 30 | void execute_block_prelude(State &); 31 | 32 | MONAD_STAKING_NAMESPACE_END 33 | -------------------------------------------------------------------------------- /category/vm/utils/debug.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #ifdef MONAD_COMPILER_TESTING 17 | #include 18 | #include 19 | 20 | namespace monad::vm::utils 21 | { 22 | static auto const is_fuzzing_monad_vm_env = 23 | std::getenv("MONAD_COMPILER_FUZZING"); 24 | bool is_fuzzing_monad_vm = is_fuzzing_monad_vm_env && 25 | std::strcmp(is_fuzzing_monad_vm_env, "1") == 0; 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /category/vm/compiler/types.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | namespace monad::vm::compiler 23 | { 24 | using byte_offset = std::size_t; 25 | 26 | using block_id = std::size_t; 27 | 28 | using uint256_t = runtime::uint256_t; 29 | 30 | inline constexpr block_id INVALID_BLOCK_ID = 31 | std::numeric_limits::max(); 32 | } 33 | -------------------------------------------------------------------------------- /category/execution/ethereum/chain/genesis_state.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | MONAD_NAMESPACE_BEGIN 22 | 23 | class TrieDb; 24 | 25 | struct GenesisState 26 | { 27 | BlockHeader header{}; 28 | char const *const alloc{nullptr}; 29 | }; 30 | 31 | void load_genesis_state(GenesisState const &, TrieDb &); 32 | 33 | MONAD_NAMESPACE_END 34 | -------------------------------------------------------------------------------- /category/vm/evm/delegation.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | namespace monad::vm::evm 23 | { 24 | evmc::bytes_view delegation_indicator_prefix(); 25 | 26 | bool is_delegated(std::span code); 27 | 28 | std::optional resolve_delegation( 29 | evmc_host_interface const *, evmc_host_context *, 30 | evmc::address const &); 31 | } 32 | -------------------------------------------------------------------------------- /category/core/fiber/priority_task.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | MONAD_FIBER_NAMESPACE_BEGIN 24 | 25 | struct PriorityTask 26 | { 27 | uint64_t priority{0}; 28 | std::move_only_function task{}; 29 | }; 30 | 31 | static_assert(sizeof(PriorityTask) == 48); 32 | static_assert(alignof(PriorityTask) == 8); 33 | 34 | MONAD_FIBER_NAMESPACE_END 35 | -------------------------------------------------------------------------------- /category/mpt/cli_tool_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include "cli_tool_impl.hpp" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | int main(int argc_, char const *argv[]) 24 | { 25 | size_t const argc = size_t(argc_); 26 | std::vector args(argc); 27 | for (size_t n = 0; n < argc; n++) { 28 | args[n] = argv[n]; 29 | } 30 | return main_impl(std::cout, std::cerr, args); 31 | } 32 | -------------------------------------------------------------------------------- /category/statesync/statesync_version.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | // Modify when there are changes to the protocol 19 | 20 | constexpr uint32_t MONAD_STATESYNC_VERSION = 1; 21 | 22 | uint32_t monad_statesync_version() 23 | { 24 | return MONAD_STATESYNC_VERSION; 25 | } 26 | 27 | bool monad_statesync_client_compatible(uint32_t const version) 28 | { 29 | return version <= MONAD_STATESYNC_VERSION && version >= 1; 30 | } 31 | -------------------------------------------------------------------------------- /scripts/apply-clang-tidy-fixes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ! -z "$(git status --untracked-files=no --porcelain)" ]]; then 4 | printf "FATAL: Do not run this on a git repo with uncommitted changes\n\n\n" >&2 5 | git status --untracked-files=no 6 | exit 1 7 | fi 8 | BUILDDIR=$1/ 9 | if [[ -z "$1" && -f "build/compile_commands.json" ]]; then 10 | BUILDDIR=build/ 11 | fi 12 | if [[ -z "$1" && -f "compile_commands.json" ]]; then 13 | BUILDDIR= 14 | fi 15 | if [[ ! -f "${BUILDDIR}compile_commands.json" ]]; then 16 | echo "FATAL:Pass the path to the cmake build directory containing 'compile_commands.json' as the first argument" >&2 17 | exit 1 18 | fi 19 | pushd "$BUILDDIR" 20 | run-clang-tidy -fix -format "^((?!/third_party/).)+\.(c|cpp|cxx)$" | tee apply-clang-tidy-fixes.log 21 | popd 22 | if [[ ! -z "$(git status --untracked-files=no --porcelain)" ]]; then 23 | git status --untracked-files=no 24 | printf "\nFixes were applied, make sure everything compiles and works then do 'git commit --amend'\n" 25 | else 26 | printf "\nNo fixes applied, you don't need to run 'git commit --amend'\n" 27 | fi 28 | printf "\nA copy of the output above has been placed into '${BUILDDIR}apply-clang-tidy-fixes.log'\n" 29 | -------------------------------------------------------------------------------- /category/execution/ethereum/fmt/event_trace_fmt.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | namespace fmt = fmtquill::v10; 24 | 25 | template <> 26 | struct quill::copy_loggable : std::true_type 27 | { 28 | }; 29 | 30 | template <> 31 | struct fmt::formatter : public fmt::ostream_formatter 32 | { 33 | }; 34 | -------------------------------------------------------------------------------- /category/core/io/config.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #define MONAD_IO_NAMESPACE_BEGIN \ 21 | MONAD_NAMESPACE_BEGIN namespace io \ 22 | { 23 | 24 | #define MONAD_IO_NAMESPACE_END \ 25 | } \ 26 | MONAD_NAMESPACE_END 27 | -------------------------------------------------------------------------------- /category/core/fiber/config.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #define MONAD_FIBER_NAMESPACE_BEGIN \ 21 | MONAD_NAMESPACE_BEGIN namespace fiber \ 22 | { 23 | 24 | #define MONAD_FIBER_NAMESPACE_END \ 25 | } \ 26 | MONAD_NAMESPACE_END 27 | -------------------------------------------------------------------------------- /category/vm/utils/evm-as/utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | namespace monad::vm::utils::evm_as 23 | { 24 | template 25 | requires requires(T const &x) { 26 | static_cast(runtime::bit_width(x)); 27 | } 28 | 29 | inline size_t byte_width(T imm) 30 | { 31 | return (static_cast(runtime::bit_width(imm)) + 7) / 8; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /category/execution/monad/staking/util/consensus_view.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | MONAD_STAKING_NAMESPACE_BEGIN 20 | 21 | ConsensusView::ConsensusView( 22 | State &state, Address const &address, bytes32_t const &key) 23 | : state_{state} 24 | , address_{address} 25 | , key_{intx::be::load(key)} 26 | { 27 | } 28 | 29 | MONAD_STAKING_NAMESPACE_END 30 | -------------------------------------------------------------------------------- /category/execution/ethereum/rlp/config.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #define MONAD_RLP_NAMESPACE_BEGIN \ 21 | MONAD_NAMESPACE_BEGIN namespace rlp \ 22 | { 23 | 24 | #define MONAD_RLP_NAMESPACE_END \ 25 | } \ 26 | MONAD_NAMESPACE_END 27 | -------------------------------------------------------------------------------- /category/execution/monad/staking/util/delegator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | MONAD_STAKING_NAMESPACE_BEGIN 22 | 23 | Delegator::Delegator(State &state, Address const &address, bytes32_t const key) 24 | : state_{state} 25 | , address_{address} 26 | , key_{intx::be::load(key)} 27 | { 28 | } 29 | 30 | MONAD_STAKING_NAMESPACE_END 31 | -------------------------------------------------------------------------------- /category/vm/interpreter/execute.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace monad::vm::interpreter 27 | { 28 | template 29 | void 30 | execute(runtime::Context &, Intercode const &, std::uint8_t *stack_ptr); 31 | } 32 | -------------------------------------------------------------------------------- /test/unit/common/include/monad/test/config.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #define MONAD_TEST_NAMESPACE_BEGIN \ 21 | MONAD_NAMESPACE_BEGIN namespace test \ 22 | { 23 | #define MONAD_TEST_NAMESPACE_END \ 24 | } \ 25 | MONAD_NAMESPACE_END 26 | -------------------------------------------------------------------------------- /category/core/spinlock_disas.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | void spinlock_init_disas(spinlock_t *const lock) 19 | { 20 | spinlock_init(lock); 21 | } 22 | 23 | bool spinlock_try_lock_disas(spinlock_t *const lock) 24 | { 25 | return spinlock_try_lock(lock); 26 | } 27 | 28 | void spinlock_lock_disas(spinlock_t *const lock) 29 | { 30 | spinlock_lock(lock); 31 | } 32 | 33 | void spinlock_unlock_disas(spinlock_t *const lock) 34 | { 35 | spinlock_unlock(lock); 36 | } 37 | -------------------------------------------------------------------------------- /category/execution/ethereum/core/variant.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | MONAD_NAMESPACE_BEGIN 21 | 22 | // shamelessly stolen from cppreference 23 | 24 | // helper type for the visitor #4 25 | template 26 | struct overloaded : Ts... 27 | { 28 | using Ts::operator()...; 29 | }; 30 | // explicit deduction guide (not needed as of C++20) 31 | template 32 | overloaded(Ts...) -> overloaded; 33 | 34 | MONAD_NAMESPACE_END 35 | -------------------------------------------------------------------------------- /category/vm/utils/evmc_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | namespace monad::vm::utils 24 | { 25 | std::string hex_string(evmc::bytes32 const &x) 26 | { 27 | return evmc::hex({x.bytes, sizeof(x.bytes)}); 28 | } 29 | 30 | std::string hex_string(evmc::address const &x) 31 | { 32 | return evmc::hex({x.bytes, sizeof(x.bytes)}); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /third_party/go-ethereum/core/vm/testdata/precompiles/fail-blsMapG1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Input": "", 4 | "ExpectedError": "invalid input length", 5 | "Name": "bls_mapg1_empty_input" 6 | }, 7 | { 8 | "Input": "00000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f", 9 | "ExpectedError": "invalid input length", 10 | "Name": "bls_mapg1_short_input" 11 | }, 12 | { 13 | "Input": "0000000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f03", 14 | "ExpectedError": "invalid input length", 15 | "Name": "bls_mapg1_large_input" 16 | }, 17 | { 18 | "Input": "1000000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f", 19 | "ExpectedError": "invalid field element top bytes", 20 | "Name": "bls_mapg1_top_bytes" 21 | }, 22 | { 23 | "Input": "000000000000000000000000000000002f6d9c5465982c0421b61e74579709b3b5b91e57bdd4f6015742b4ff301abb7ef895b9cce00c33c7d48f8e5fa4ac09ae", 24 | "ExpectedError": "invalid fp.Element encoding", 25 | "Name": "bls_invalid_fq_element" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /test/vm/compile_benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_executable(compile-benchmarks) 17 | target_sources(compile-benchmarks 18 | PRIVATE 19 | compile_benchmarks.cpp 20 | ) 21 | monad_compile_options(compile-benchmarks) 22 | 23 | target_link_libraries(compile-benchmarks 24 | PRIVATE benchmark::benchmark 25 | PRIVATE monad_execution 26 | ) 27 | 28 | target_include_directories(compile-benchmarks 29 | PRIVATE "${TOP_CURRENT_BINARY_DIR}/test" 30 | PRIVATE "${TEST_DATA_DIR}/unit/common/include" 31 | ) 32 | -------------------------------------------------------------------------------- /category/rpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | cmake_minimum_required(VERSION 3.27) 17 | 18 | cmake_policy(SET CMP0144 NEW) # find_package uses upper-case _ROOT variables 19 | 20 | project(monad_rpc) 21 | 22 | add_library( 23 | monad_rpc 24 | OBJECT 25 | # rpc 26 | "monad_executor.cpp" "monad_executor.h") 27 | 28 | target_include_directories(monad_rpc PUBLIC ${CATEGORY_MAIN_DIR}) 29 | 30 | monad_compile_options(monad_rpc) 31 | target_link_libraries(monad_rpc PRIVATE monad_execution_native) 32 | 33 | monad_add_test_folder(".") 34 | -------------------------------------------------------------------------------- /category/execution/ethereum/chain/chain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | using BOOST_OUTCOME_V2_NAMESPACE::success; 27 | 28 | Result Chain::static_validate_header(BlockHeader const &) const 29 | { 30 | return success(); 31 | } 32 | 33 | MONAD_NAMESPACE_END 34 | -------------------------------------------------------------------------------- /category/execution/monad/staking/util/val_execution.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | MONAD_STAKING_NAMESPACE_BEGIN 22 | 23 | ValExecution::ValExecution( 24 | State &state, Address const &address, bytes32_t const key) 25 | : state_{state} 26 | , address_{address} 27 | , key_{intx::be::load(key)} 28 | { 29 | } 30 | 31 | MONAD_STAKING_NAMESPACE_END 32 | -------------------------------------------------------------------------------- /category/execution/monad/system_sender.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | MONAD_NAMESPACE_BEGIN 24 | 25 | // This address is derived from a known key. Consensus will sign all system 26 | // transactions with this key. 27 | inline constexpr Address SYSTEM_SENDER = evmc::literals::parse( 28 | "0x6f49a8F621353f12378d0046E7d7e4b9B249DC9e"); 29 | 30 | MONAD_NAMESPACE_END 31 | -------------------------------------------------------------------------------- /category/core/fiber/priority_queue.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | 20 | MONAD_FIBER_NAMESPACE_BEGIN 21 | 22 | bool PriorityQueue::empty() const 23 | { 24 | return queue_.empty(); 25 | } 26 | 27 | context *PriorityQueue::pop() 28 | { 29 | context *ctx = nullptr; 30 | queue_.try_pop(ctx); 31 | return ctx; 32 | } 33 | 34 | void PriorityQueue::push(context *const ctx) 35 | { 36 | queue_.push(ctx); 37 | } 38 | 39 | MONAD_FIBER_NAMESPACE_END 40 | -------------------------------------------------------------------------------- /category/execution/ethereum/core/rlp/account_rlp.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | MONAD_RLP_NAMESPACE_BEGIN 25 | 26 | byte_string encode_account(Account const &, bytes32_t const &storage_root); 27 | 28 | Result decode_account(bytes32_t &storage_root, byte_string_view &); 29 | 30 | MONAD_RLP_NAMESPACE_END 31 | -------------------------------------------------------------------------------- /category/execution/ethereum/create_contract_address.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | MONAD_NAMESPACE_BEGIN 26 | 27 | Address create_contract_address(Address const &from, uint64_t const nonce); 28 | Address create2_contract_address( 29 | Address const &from, bytes32_t const &zeta, 30 | ethash::hash256 const &code_hash); 31 | 32 | MONAD_NAMESPACE_END 33 | -------------------------------------------------------------------------------- /category/vm/core/assert.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | extern char const *__progname; // NOLINT(bugprone-reserved-identifier) 20 | 21 | extern "C" void __attribute__((noreturn)) monad_vm_assertion_failed( 22 | char const *expr, char const *function, char const *file, long line) 23 | { 24 | std::print( 25 | stderr, 26 | "{}: {}:{}: {}: Assertion '{}' failed.\n", 27 | __progname, 28 | file, 29 | line, 30 | function, 31 | expr); 32 | 33 | std::abort(); 34 | } 35 | -------------------------------------------------------------------------------- /category/core/event/event_metadata.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | // clang-format off 26 | 27 | /// Metadata describing each event in an event domain 28 | struct monad_event_metadata 29 | { 30 | uint16_t event_type; ///< Enumeration constant 31 | char const *c_name; ///< Short form C style name 32 | char const *description; ///< Text description for UI commands 33 | }; 34 | 35 | // clang-format on 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif 40 | -------------------------------------------------------------------------------- /category/execution/ethereum/core/rlp/withdrawal_rlp.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | MONAD_RLP_NAMESPACE_BEGIN 26 | 27 | byte_string encode_withdrawal(Withdrawal const &); 28 | 29 | Result decode_withdrawal(byte_string_view &); 30 | Result> decode_withdrawal_list(byte_string_view &); 31 | 32 | MONAD_RLP_NAMESPACE_END 33 | -------------------------------------------------------------------------------- /cmd/monad/file_io.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | MONAD_NAMESPACE_BEGIN 26 | 27 | byte_string read_file(bytes32_t const &, std::filesystem::path const &); 28 | 29 | MonadConsensusBlockBody 30 | read_body(bytes32_t const &, std::filesystem::path const &); 31 | 32 | bytes32_t head_pointer_to_id(std::filesystem::path const &); 33 | 34 | MONAD_NAMESPACE_END 35 | -------------------------------------------------------------------------------- /scripts/ubuntu-host/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### general 4 | 5 | apt-get update 6 | 7 | apt-get install -y apt-utils 8 | 9 | apt-get install -y dialog 10 | 11 | apt-get install -y \ 12 | ca-certificates \ 13 | curl \ 14 | gnupg \ 15 | software-properties-common 16 | 17 | ### docker 18 | 19 | # https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository 20 | 21 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ 22 | | gpg --dearmor -o /etc/apt/keyrings/docker.gpg 23 | 24 | chmod a+r /etc/apt/keyrings/docker.gpg 25 | 26 | echo \ 27 | "deb [arch="$(dpkg --print-architecture)" \ 28 | signed-by=/etc/apt/keyrings/docker.gpg] \ 29 | https://download.docker.com/linux/ubuntu \ 30 | "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" \ 31 | | tee /etc/apt/sources.list.d/docker.list > /dev/null 32 | 33 | apt-get update 34 | 35 | apt-get install -y \ 36 | docker-ce \ 37 | docker-ce-cli \ 38 | docker-ce-rootless-extras \ 39 | containerd.io \ 40 | docker-buildx-plugin \ 41 | docker-compose-plugin 42 | 43 | ### docker rootless 44 | 45 | # https://docs.docker.com/engine/security/rootless/ 46 | 47 | apt-get install -y \ 48 | uidmap \ 49 | dbus-user-session 50 | 51 | systemctl disable --now docker.service docker.socket 52 | 53 | ### general 54 | 55 | apt-get upgrade -y 56 | -------------------------------------------------------------------------------- /category/core/test/huge_mem.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | #include // NOLINT 20 | 21 | #include 22 | 23 | #include 24 | 25 | TEST(HugeMem, works) 26 | { 27 | using namespace MONAD_NAMESPACE; 28 | HugeMem const mem(5); 29 | std::cerr << "HugeMem construction was successful" << std::endl; 30 | unsigned char volatile *p = mem.get_data(); 31 | p[0] = 5; 32 | std::cerr << "HugeMem write was successful" << std::endl; 33 | } 34 | -------------------------------------------------------------------------------- /category/execution/ethereum/core/withdrawal.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | MONAD_NAMESPACE_BEGIN 22 | 23 | // EIP-4895 24 | struct Withdrawal 25 | { 26 | uint64_t index{0}; 27 | uint64_t validator_index{}; 28 | uint64_t amount{}; 29 | Address recipient{}; 30 | 31 | friend bool operator==(Withdrawal const &, Withdrawal const &) = default; 32 | }; 33 | 34 | static_assert(sizeof(Withdrawal) == 48); 35 | static_assert(alignof(Withdrawal) == 8); 36 | 37 | MONAD_NAMESPACE_END 38 | -------------------------------------------------------------------------------- /category/execution/ethereum/db/file_db.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | class FileDb final 27 | { 28 | class Impl; 29 | 30 | std::unique_ptr impl_; 31 | 32 | public: 33 | FileDb() = delete; 34 | FileDb(FileDb const &) = delete; 35 | FileDb(FileDb &&); 36 | explicit FileDb(char const *dir); 37 | ~FileDb(); 38 | 39 | std::optional get(char const *key) const; 40 | }; 41 | 42 | MONAD_NAMESPACE_END 43 | -------------------------------------------------------------------------------- /category/vm/compiler/ir/poly_typed/unify.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | namespace monad::vm::compiler::poly_typed 22 | { 23 | void unify(SubstMap &, Kind, Kind); 24 | 25 | void unify(SubstMap &, ContKind, ContKind); 26 | 27 | using ParamVarNameMap = std::unordered_map>; 28 | 29 | void unify_param_var_name_map( 30 | SubstMap &, std::vector const &, ParamVarNameMap const &); 31 | } 32 | -------------------------------------------------------------------------------- /category/core/math.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | /** 25 | * returns smallest z such that z % y == 0 and z >= x 26 | */ 27 | template 28 | constexpr T round_up(T const x, T const y) 29 | { 30 | T z = x + (y - 1); 31 | z /= y; 32 | z *= y; 33 | return z; 34 | /* 35 | TODO alt impl 36 | T z = x; 37 | T const r = x % y; 38 | if (r) { 39 | z += y - r; 40 | } 41 | */ 42 | return z; 43 | } 44 | 45 | MONAD_NAMESPACE_END 46 | -------------------------------------------------------------------------------- /category/execution/ethereum/db/block_db.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | struct Block; 27 | 28 | class BlockDb 29 | { 30 | FileDb db_; 31 | 32 | public: 33 | BlockDb() = delete; 34 | BlockDb(Block const &) = delete; 35 | BlockDb(BlockDb &&) = default; 36 | explicit BlockDb(std::filesystem::path const &); 37 | ~BlockDb() = default; 38 | 39 | bool get(uint64_t, Block &) const; 40 | }; 41 | 42 | MONAD_NAMESPACE_END 43 | -------------------------------------------------------------------------------- /category/vm/fuzzing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_library(monad-vm-fuzzing OBJECT) 17 | 18 | target_sources(monad-vm-fuzzing PRIVATE 19 | "generator/choice.hpp" 20 | "generator/generator.hpp" 21 | "generator/instruction_data.cpp" 22 | "generator/instruction_data.hpp" 23 | ) 24 | 25 | monad_compile_options(monad-vm-fuzzing) 26 | 27 | target_include_directories(monad-vm-fuzzing 28 | PUBLIC src/ 29 | ) 30 | 31 | target_link_libraries(monad-vm-fuzzing 32 | PUBLIC monad-vm::monad-vm-compiler 33 | PUBLIC monad-vm::monad-vm-core 34 | PUBLIC monad-vm::monad-vm-utils 35 | ) 36 | 37 | add_library(monad-vm::monad-vm-fuzzing ALIAS monad-vm-fuzzing) 38 | -------------------------------------------------------------------------------- /third_party/c-kzg-4844-builder/cmake/trusted_setup.cpp.in: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | #ifndef __has_embed 22 | #error "No #embed support" 23 | #endif 24 | 25 | namespace c_kzg_4844 26 | { 27 | namespace 28 | { 29 | inline constexpr uint8_t embedded_data[] = { 30 | #embed "@TRUSTED_SETUP_PATH@" 31 | }; 32 | } 33 | 34 | std::span trusted_setup_data() noexcept 35 | { 36 | static_assert(sizeof(embedded_data) == 807177); 37 | return {&embedded_data[0], sizeof(embedded_data)}; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /category/core/cleanup.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | void cleanup_free(char *const *const ptr) 25 | { 26 | assert(ptr); 27 | if (*ptr) { 28 | free(*ptr); 29 | } 30 | } 31 | 32 | void cleanup_close(int *const fd) 33 | { 34 | assert(fd); 35 | if (*fd != -1) { 36 | close(*fd); 37 | *fd = -1; 38 | } 39 | } 40 | 41 | void cleanup_fclose(FILE *const *const stream) 42 | { 43 | assert(stream); 44 | if (*stream) { 45 | fclose(*stream); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /category/core/fiber/priority_pool.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | MONAD_FIBER_NAMESPACE_BEGIN 25 | 26 | PriorityPool::PriorityPool( 27 | unsigned const n_threads, unsigned const n_fibers, bool const prevent_spin) 28 | : thread_pool_{std::make_unique(n_threads, prevent_spin)} 29 | , fiber_group_{thread_pool_->create_fiber_group(n_fibers)} 30 | { 31 | } 32 | 33 | MONAD_FIBER_NAMESPACE_END 34 | -------------------------------------------------------------------------------- /cmake/test.cmake: -------------------------------------------------------------------------------- 1 | enable_testing() 2 | 3 | find_package(GTest REQUIRED) 4 | find_package(PkgConfig REQUIRED) 5 | pkg_check_modules(gmock REQUIRED IMPORTED_TARGET gmock) 6 | 7 | include(GoogleTest) 8 | 9 | function(add_unit_test) 10 | set(ONE_VALUE_ARGS TARGET) 11 | set(MULTI_VALUE_ARGS SOURCES LIBRARIES) 12 | cmake_parse_arguments(ADD_UNIT_TEST "" "${ONE_VALUE_ARGS}" 13 | "${MULTI_VALUE_ARGS}" ${ARGN}) 14 | 15 | add_executable( 16 | ${ADD_UNIT_TEST_TARGET} 17 | ${ADD_UNIT_TEST_SOURCES} 18 | ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../test/unit/common/src/test/main.cpp) 19 | monad_compile_options(${ADD_UNIT_TEST_TARGET}) 20 | 21 | target_link_libraries( 22 | ${ADD_UNIT_TEST_TARGET} 23 | PUBLIC GTest::gtest GTest::gmock monad_unit_test_common 24 | ${ADD_UNIT_TEST_LIBRARIES}) 25 | gtest_discover_tests(${ADD_UNIT_TEST_TARGET}) 26 | endfunction() 27 | 28 | function(add_integration_test) 29 | set(ONE_VALUE_ARGS TARGET) 30 | cmake_parse_arguments(ADD_INT_TEST "" "${ONE_VALUE_ARGS}" "" ${ARGN}) 31 | 32 | add_unit_test(${ADD_INT_TEST_TARGET} ${ARGN}) 33 | target_link_libraries(${ADD_INT_TEST_TARGET} PUBLIC monad_execution) 34 | 35 | if(NOT TARGET integration_tests) 36 | add_custom_target(integration_tests) 37 | endif() 38 | add_dependencies(integration_tests ${ADD_INT_TEST_TARGET}) 39 | endfunction() 40 | -------------------------------------------------------------------------------- /category/core/keccak.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | MONAD_NAMESPACE_BEGIN 24 | 25 | using ::keccak256; 26 | 27 | using hash256 = ethash::hash256; 28 | 29 | inline hash256 keccak256(byte_string_view const bytes) 30 | { 31 | hash256 hash; 32 | keccak256(bytes.data(), bytes.size(), hash.bytes); 33 | return hash; 34 | } 35 | 36 | template 37 | inline hash256 keccak256(unsigned char const (&a)[N]) 38 | { 39 | return keccak256(to_byte_string_view(a)); 40 | } 41 | 42 | MONAD_NAMESPACE_END 43 | -------------------------------------------------------------------------------- /test/unit/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_library( 17 | monad_unit_test_common STATIC 18 | ${PROJECT_SOURCE_DIR}/test/unit/common/include/monad/test/config.hpp 19 | ${PROJECT_SOURCE_DIR}/test/unit/common/include/monad/test/environment.hpp 20 | ${PROJECT_SOURCE_DIR}/test/unit/common/include/monad/test/traits_test.hpp 21 | ) 22 | 23 | target_include_directories( 24 | monad_unit_test_common PUBLIC ${PROJECT_SOURCE_DIR}/test/unit/common/include) 25 | set_target_properties(monad_unit_test_common PROPERTIES LINKER_LANGUAGE CXX) 26 | target_link_libraries(monad_unit_test_common PUBLIC monad_execution_native) 27 | monad_compile_options(monad_unit_test_common) 28 | -------------------------------------------------------------------------------- /category/core/bytes_hash_compare.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #pragma GCC diagnostic push 21 | #pragma GCC diagnostic ignored "-Wpedantic" 22 | #include 23 | #pragma GCC diagnostic pop 24 | 25 | MONAD_NAMESPACE_BEGIN 26 | 27 | template 28 | struct BytesHashCompare 29 | { 30 | size_t hash(Bytes const &a) const 31 | { 32 | return komihash(a.bytes, sizeof(Bytes), 0); 33 | } 34 | 35 | bool equal(Bytes const &a, Bytes const &b) const 36 | { 37 | return memcmp(a.bytes, b.bytes, sizeof(Bytes)) == 0; 38 | } 39 | }; 40 | 41 | MONAD_NAMESPACE_END 42 | -------------------------------------------------------------------------------- /category/execution/monad/core/rlp/monad_block_rlp.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | MONAD_RLP_NAMESPACE_BEGIN 24 | 25 | Result decode_consensus_block_header_timestamp_s(byte_string_view &); 26 | Result decode_consensus_block_body(byte_string_view &); 27 | template 28 | Result 29 | decode_consensus_block_header(byte_string_view &); 30 | 31 | MONAD_RLP_NAMESPACE_END 32 | -------------------------------------------------------------------------------- /category/execution/monad/monad_transaction_gas.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | MONAD_NAMESPACE_BEGIN 21 | 22 | template 23 | uint64_t compute_gas_refund( 24 | Transaction const &tx, uint64_t const gas_remaining, uint64_t const refund) 25 | { 26 | if constexpr (traits::monad_rev() >= MONAD_ONE) { 27 | return 0; 28 | } 29 | 30 | return g_star(tx, gas_remaining, refund); 31 | } 32 | 33 | EXPLICIT_MONAD_TRAITS(compute_gas_refund); 34 | 35 | MONAD_NAMESPACE_END 36 | -------------------------------------------------------------------------------- /test/vm/unit/test_params.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | namespace monad::vm::compiler::test 19 | { 20 | struct TestParams 21 | { 22 | public: 23 | bool dump_asm_on_failure = false; 24 | 25 | TestParams(bool dump_asm_on_failure = false) 26 | : dump_asm_on_failure(dump_asm_on_failure) 27 | { 28 | } 29 | }; 30 | 31 | // We could use testing::AddGlobalTestEnvironment(new TestParams(...)) 32 | // instead of using a global variable like google suggests, but that's 33 | // overkill for our usage, where we simply want to pass a flag to the tests. 34 | extern struct TestParams params; 35 | } 36 | -------------------------------------------------------------------------------- /utils/clang-tidy-auto-const/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | find_package(LLVM 19.1.7 REQUIRED CONFIG) 17 | find_package(Clang REQUIRED CONFIG) 18 | 19 | add_library(ConstCorrectnessChecks SHARED "") 20 | target_compile_options(ConstCorrectnessChecks PRIVATE -fno-rtti) 21 | target_include_directories( 22 | ConstCorrectnessChecks 23 | PRIVATE ${CLANG_INCLUDE_DIRS} 24 | ${LLVM_INCLUDE_DIRS} 25 | ) 26 | target_sources( 27 | ConstCorrectnessChecks 28 | PRIVATE "ExprAutoMutationAnalyzer.hpp" 29 | "ExprAutoMutationAnalyzer.cpp" 30 | "AutoConstCorrectnessCheck.hpp" 31 | "AutoConstCorrectnessCheck.cpp" 32 | "MiscUpdateModule.cpp" 33 | ) 34 | -------------------------------------------------------------------------------- /category/core/srcloc.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | typedef struct monad_source_location monad_source_location_t; 19 | 20 | /// A C structure similar to C++20's std::source_location 21 | struct monad_source_location 22 | { 23 | char const *function_name; 24 | char const *file_name; 25 | unsigned line; 26 | unsigned column; 27 | }; 28 | 29 | /// Creates a compound literal of the current source location for use in a 30 | /// macro, similar to the C++20 consteval std::source_location::current() 31 | #define MONAD_SOURCE_LOCATION_CURRENT() \ 32 | ((monad_source_location_t){__FUNCTION__, __FILE__, __LINE__, 0}) 33 | -------------------------------------------------------------------------------- /category/vm/runtime/runtime.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | -------------------------------------------------------------------------------- /category/core/nibble.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | static inline unsigned char 19 | get_nibble(unsigned char const *const d, unsigned const n) 20 | { 21 | unsigned char r = d[n / 2]; 22 | if (n % 2 == 0) { 23 | r >>= 4; 24 | } 25 | else { 26 | r &= 0xF; 27 | } 28 | return r; 29 | } 30 | 31 | static inline void 32 | set_nibble(unsigned char *const d, unsigned const n, unsigned char const v) 33 | { 34 | unsigned char r = d[n / 2]; 35 | if (n % 2 == 0) { 36 | r &= 0xF; 37 | r |= (v << 4); 38 | } 39 | else { 40 | r &= 0xF0; 41 | r |= (v & 0xF); 42 | } 43 | d[n / 2] = r; 44 | } 45 | -------------------------------------------------------------------------------- /test/vm/fuzzer/assertions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #include "account.hpp" 17 | #include "state.hpp" 18 | 19 | #include 20 | 21 | namespace monad::vm::fuzzing 22 | { 23 | void assert_equal( 24 | evmone::state::StorageValue const &a, 25 | evmone::state::StorageValue const &b); 26 | 27 | void assert_equal( 28 | evmone::state::Account const &a, evmone::state::Account const &b); 29 | 30 | void 31 | assert_equal(evmone::state::State const &a, evmone::state::State const &b); 32 | 33 | void assert_equal( 34 | evmc::Result const &evmone_result, evmc::Result const &compiler_result, 35 | bool strict_out_of_gas); 36 | } 37 | -------------------------------------------------------------------------------- /category/execution/ethereum/trace/rlp/call_frame_rlp.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | MONAD_RLP_NAMESPACE_BEGIN 27 | 28 | byte_string encode_call_frame(CallFrame const &); 29 | 30 | byte_string encode_call_frames(std::span); 31 | 32 | Result decode_call_frame(byte_string_view &); 33 | 34 | Result> decode_call_frames(byte_string_view &); 35 | 36 | MONAD_RLP_NAMESPACE_END 37 | -------------------------------------------------------------------------------- /category/execution/monad/chain/monad_devnet.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | struct MonadDevnet : MonadChain 27 | { 28 | virtual monad_revision 29 | get_monad_revision(uint64_t timestamp) const override; 30 | 31 | virtual uint256_t get_chain_id() const override; 32 | 33 | virtual GenesisState get_genesis_state() const override; 34 | }; 35 | 36 | MONAD_NAMESPACE_END 37 | -------------------------------------------------------------------------------- /category/vm/utils/debug.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | namespace monad::vm::utils 19 | { 20 | #ifdef MONAD_COMPILER_TESTING 21 | extern bool is_fuzzing_monad_vm; 22 | #else 23 | static constexpr bool is_fuzzing_monad_vm = false; 24 | #endif 25 | 26 | #ifdef MONAD_COMPILER_STATS 27 | static constexpr bool collect_monad_compiler_stats = true; 28 | #else 29 | static constexpr bool collect_monad_compiler_stats = false; 30 | #endif 31 | 32 | #ifdef MONAD_COMPILER_HOT_PATH_STATS 33 | static constexpr bool collect_monad_compiler_hot_path_stats = true; 34 | #else 35 | static constexpr bool collect_monad_compiler_hot_path_stats = false; 36 | #endif 37 | } 38 | -------------------------------------------------------------------------------- /category/execution/monad/chain/monad_mainnet.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | struct MonadMainnet : MonadChain 27 | { 28 | virtual monad_revision 29 | get_monad_revision(uint64_t timestamp) const override; 30 | 31 | virtual uint256_t get_chain_id() const override; 32 | 33 | virtual GenesisState get_genesis_state() const override; 34 | }; 35 | 36 | MONAD_NAMESPACE_END 37 | -------------------------------------------------------------------------------- /category/execution/monad/chain/monad_testnet.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | struct MonadTestnet : MonadChain 27 | { 28 | virtual monad_revision 29 | get_monad_revision(uint64_t timestamp) const override; 30 | 31 | virtual uint256_t get_chain_id() const override; 32 | 33 | virtual GenesisState get_genesis_state() const override; 34 | }; 35 | 36 | MONAD_NAMESPACE_END 37 | -------------------------------------------------------------------------------- /test/vm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | include(GoogleTest) 17 | 18 | if(MONAD_COMPILER_TESTING) 19 | find_package(GTest REQUIRED) 20 | endif() 21 | 22 | if(MONAD_COMPILER_BENCHMARKS) 23 | find_package(benchmark REQUIRED) 24 | endif() 25 | 26 | if(MONAD_COMPILER_BENCHMARKS) 27 | add_subdirectory(compile_benchmarks) 28 | add_subdirectory(execution_benchmarks) 29 | add_subdirectory(micro_benchmarks) 30 | endif() 31 | 32 | if(MONAD_COMPILER_TESTING) 33 | add_subdirectory(blockchain) 34 | add_subdirectory(fuzzer) 35 | endif() 36 | 37 | if(MONAD_COMPILER_BENCHMARKS OR MONAD_COMPILER_TESTING) 38 | add_subdirectory(vm) 39 | endif() 40 | 41 | add_subdirectory(utils) 42 | add_subdirectory(unit) 43 | -------------------------------------------------------------------------------- /category/core/util/stopwatch.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | MONAD_NAMESPACE_BEGIN 24 | 25 | template 26 | class Stopwatch final 27 | { 28 | std::chrono::time_point const begin_; 29 | 30 | public: 31 | Stopwatch() 32 | : begin_{std::chrono::steady_clock::now()} 33 | { 34 | } 35 | 36 | Duration elapsed() const 37 | { 38 | return std::chrono::duration_cast( 39 | std::chrono::steady_clock::now() - begin_); 40 | } 41 | }; 42 | 43 | MONAD_NAMESPACE_END 44 | -------------------------------------------------------------------------------- /test/vm/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_library(monad-vm-test-utils OBJECT) 17 | 18 | target_sources(monad-vm-test-utils PRIVATE 19 | "evm-as_utils.hpp" 20 | ) 21 | 22 | monad_compile_options(monad-vm-test-utils) 23 | 24 | target_link_libraries(monad-vm-test-utils 25 | PUBLIC TBB::tbb 26 | PUBLIC intx::intx 27 | PUBLIC evmc::evmc 28 | PUBLIC asmjit::asmjit 29 | PUBLIC quill::quill 30 | PUBLIC monad-vm::monad-vm-compiler 31 | PUBLIC monad-vm::monad-vm-interpreter 32 | PUBLIC monad-vm::monad-vm-core 33 | PUBLIC monad-vm::monad-vm-runtime 34 | PUBLIC monad-vm::monad-vm-utils 35 | ) 36 | 37 | add_library(monad-vm::monad-vm-test-utils ALIAS monad-vm-test-utils) 38 | -------------------------------------------------------------------------------- /test/vm/micro_benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Category Labs, Inc. 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | add_executable(vm-micro-benchmarks) 17 | target_sources(vm-micro-benchmarks 18 | PRIVATE main.cpp 19 | ) 20 | target_include_directories(vm-micro-benchmarks 21 | PRIVATE "${TOP_CURRENT_BINARY_DIR}/test" 22 | ) 23 | monad_compile_options(vm-micro-benchmarks) 24 | 25 | target_link_libraries(vm-micro-benchmarks 26 | PRIVATE blockchain-test-vm 27 | PRIVATE monad-vm::monad-vm-test-utils 28 | PRIVATE evmone::state 29 | PRIVATE evmone::statetestutils 30 | PRIVATE evmone-blockchaintest-lib 31 | PRIVATE monad_execution 32 | ) 33 | 34 | target_include_directories(vm-micro-benchmarks 35 | PRIVATE "${CATEGORY_MAIN_DIR}/third_party" 36 | ) 37 | -------------------------------------------------------------------------------- /category/core/blake3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | MONAD_NAMESPACE_BEGIN 25 | 26 | using hash256 = ethash::hash256; 27 | 28 | inline hash256 blake3(byte_string_view const bytes) 29 | { 30 | hash256 hash; 31 | static_assert(sizeof(hash256) == BLAKE3_OUT_LEN); 32 | 33 | blake3_hasher hasher; 34 | blake3_hasher_init(&hasher); 35 | blake3_hasher_update(&hasher, bytes.data(), bytes.size()); 36 | blake3_hasher_finalize(&hasher, hash.bytes, BLAKE3_OUT_LEN); 37 | return hash; 38 | } 39 | 40 | MONAD_NAMESPACE_END 41 | -------------------------------------------------------------------------------- /category/core/unaligned.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | template 25 | [[nodiscard]] constexpr T unaligned_load(unsigned char const *const buf) 26 | { 27 | std::array data; 28 | std::copy_n(buf, sizeof(T), data.data()); 29 | return std::bit_cast(data); 30 | } 31 | 32 | template 33 | constexpr void unaligned_store(unsigned char *const buf, T const &value) 34 | { 35 | auto data = std::bit_cast>(value); 36 | std::copy_n(data.data(), sizeof(T), buf); 37 | } 38 | 39 | MONAD_NAMESPACE_END 40 | -------------------------------------------------------------------------------- /category/execution/ethereum/core/signature.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | struct SignatureAndChain 25 | { 26 | uint256_t r{}; 27 | uint256_t s{}; 28 | std::optional chain_id{}; 29 | uint8_t y_parity{}; 30 | 31 | void from_v(uint256_t const &); 32 | 33 | friend bool 34 | operator==(SignatureAndChain const &, SignatureAndChain const &) = default; 35 | }; 36 | 37 | static_assert(sizeof(SignatureAndChain) == 112); 38 | static_assert(alignof(SignatureAndChain) == 8); 39 | 40 | uint256_t get_v(SignatureAndChain const &) noexcept; 41 | 42 | MONAD_NAMESPACE_END 43 | -------------------------------------------------------------------------------- /category/execution/monad/staking/read_valset.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | MONAD_NAMESPACE_BEGIN 27 | 28 | namespace mpt 29 | { 30 | class Db; 31 | } 32 | 33 | MONAD_NAMESPACE_END 34 | 35 | MONAD_STAKING_NAMESPACE_BEGIN 36 | 37 | struct Validator 38 | { 39 | uint8_t secp_pubkey[33]; 40 | uint8_t bls_pubkey[48]; 41 | evmc_uint256be stake; 42 | }; 43 | 44 | std::optional> 45 | read_valset(mpt::Db &db, size_t block_num, uint64_t requested_epoch); 46 | 47 | MONAD_STAKING_NAMESPACE_END 48 | -------------------------------------------------------------------------------- /category/core/is_specialization_of.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 Category Labs, Inc. 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2098r0.pdf 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | MONAD_NAMESPACE_BEGIN 23 | 24 | template