aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeel Chauhan <nc@FreeBSD.org>2022-01-18 19:17:49 +0000
committerNeel Chauhan <nc@FreeBSD.org>2022-01-18 19:17:49 +0000
commit498a2a832d53da61e10368e33e6b62fca7aafb0a (patch)
tree6a7101c4d539eceac9a2601412b71a1eeced17b8
parentcee87a1eefc85598a47f07fed7052b118e2992b1 (diff)
downloadports-498a2a832d53da61e10368e33e6b62fca7aafb0a.tar.gz
ports-498a2a832d53da61e10368e33e6b62fca7aafb0a.zip
net-p2p/arbitrum-avm: New port: Arbitrum Virtual Machine
-rw-r--r--net-p2p/Makefile1
-rw-r--r--net-p2p/arbitrum-avm/Makefile44
-rw-r--r--net-p2p/arbitrum-avm/distinfo3
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_CMakeLists.txt12
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_include_avm__values_bigint.hpp17
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_src_bigint.cpp10
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_inboxmessage.cpp19
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machine.cpp17
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machinestate_machineoperation.cpp254
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_carbcore.cpp56
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_cmachine.cpp20
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_include_data__storage_value_valuecache.hpp11
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_src_arbcore.cpp11
-rw-r--r--net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_external_CMakeLists.txt29
-rw-r--r--net-p2p/arbitrum-avm/pkg-descr7
15 files changed, 511 insertions, 0 deletions
diff --git a/net-p2p/Makefile b/net-p2p/Makefile
index 4eb6b19463b1..7f90af63a582 100644
--- a/net-p2p/Makefile
+++ b/net-p2p/Makefile
@@ -2,6 +2,7 @@
SUBDIR += amule
SUBDIR += amule-devel
+ SUBDIR += arbitrum-avm
SUBDIR += autoscan
SUBDIR += awgg
SUBDIR += bazarr
diff --git a/net-p2p/arbitrum-avm/Makefile b/net-p2p/arbitrum-avm/Makefile
new file mode 100644
index 000000000000..c530605cfea0
--- /dev/null
+++ b/net-p2p/arbitrum-avm/Makefile
@@ -0,0 +1,44 @@
+PORTNAME= arbitrum-avm
+PORTVERSION= 1.2.0
+DISTVERSIONPREFIX= v
+CATEGORIES= net-p2p
+MASTER_SITES= https://neel.my.to/mirror/arbitrum/
+DISTNAME= arbitrum-${PORTVERSION}
+
+MAINTAINER= nc@FreeBSD.org
+COMMENT= Arbitrum Virtual Machine
+
+LICENSE= APACHE20
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+BUILD_DEPENDS= ethash>0:net-p2p/ethash \
+ git:devel/git \
+ intx>0:math/intx \
+ microsoft-gsl>0:devel/microsoft-gsl
+LIB_DEPENDS= libbenchmark.so:devel/benchmark \
+ libboost_system.so:devel/boost-libs \
+ libgtest.so:devel/googletest \
+ librocksdb.so:databases/rocksdb \
+ libsecp256k1.so:math/secp256k1
+RUN_DEPENDS= ethash>0:net-p2p/ethash \
+ intx>0:math/intx
+
+USES= cmake
+
+CMAKE_OFF= HUNTER_ENABLED
+CMAKE_SOURCE_PATH= ${WRKSRC}/packages/arb-avm-cpp
+
+PLIST_FILES= bin/arbcore_runner \
+ bin/avm_runner \
+ bin/avm_tests
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKDIR}/.build/bin/arbcore_runner \
+ ${STAGEDIR}${PREFIX}/bin/arbcore_runner
+ ${INSTALL_PROGRAM} ${WRKDIR}/.build/bin/avm_runner \
+ ${STAGEDIR}${PREFIX}/bin/avm_runner
+ ${INSTALL_PROGRAM} ${WRKDIR}/.build/bin/avm_tests \
+ ${STAGEDIR}${PREFIX}/bin/avm_tests
+
+.include <bsd.port.mk>
+
diff --git a/net-p2p/arbitrum-avm/distinfo b/net-p2p/arbitrum-avm/distinfo
new file mode 100644
index 000000000000..8f71fad15956
--- /dev/null
+++ b/net-p2p/arbitrum-avm/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1642530329
+SHA256 (arbitrum-1.2.0.tar.gz) = 7572b3ebf2239a4998cef47ced4389be4b3254dbbc7ff234aed3bdc70bc77363
+SIZE (arbitrum-1.2.0.tar.gz) = 78457864
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_CMakeLists.txt b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_CMakeLists.txt
new file mode 100644
index 000000000000..bee7f7b43ad4
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_CMakeLists.txt
@@ -0,0 +1,12 @@
+--- packages/arb-avm-cpp/CMakeLists.txt.orig 2022-01-14 20:16:55 UTC
++++ packages/arb-avm-cpp/CMakeLists.txt
+@@ -204,6 +204,9 @@ find_package(ethash CONFIG REQUIRED)
+ hunter_add_package(intx)
+ find_package(intx CONFIG REQUIRED)
+
++find_package(Microsoft.GSL CONFIG REQUIRED)
++pkg_search_module(ZSTD QUIET libzstd)
++
+ get_target_property(ETHASH_LIB ethash::keccak "LOCATION_Release")
+ get_filename_component(ETHASH_LIB_FOLDER "${ETHASH_LIB}" DIRECTORY)
+
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_include_avm__values_bigint.hpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_include_avm__values_bigint.hpp
new file mode 100644
index 000000000000..65b9f5655b0c
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_include_avm__values_bigint.hpp
@@ -0,0 +1,17 @@
+--- packages/arb-avm-cpp/avm_values/include/avm_values/bigint.hpp.orig 2022-01-14 20:18:32 UTC
++++ packages/arb-avm-cpp/avm_values/include/avm_values/bigint.hpp
+@@ -17,9 +17,14 @@
+ #ifndef bigint_hpp
+ #define bigint_hpp
+
++#include <gsl/gsl>
++
+ #include <intx/intx.hpp>
+
++#include <array>
+ #include <vector>
++
++using namespace gsl;
+
+ using uint256_t = intx::uint256;
+ using uint512_t = intx::uint512;
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_src_bigint.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_src_bigint.cpp
new file mode 100644
index 000000000000..4b3abcc5a39c
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm__values_src_bigint.cpp
@@ -0,0 +1,10 @@
+--- packages/arb-avm-cpp/avm_values/src/bigint.cpp.orig 2022-01-14 20:19:00 UTC
++++ packages/arb-avm-cpp/avm_values/src/bigint.cpp
+@@ -18,6 +18,7 @@
+
+ #include <ethash/keccak.hpp>
+
++#include <array>
+ #include <sstream>
+ #include <vector>
+
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_inboxmessage.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_inboxmessage.cpp
new file mode 100644
index 000000000000..4cf290b73e32
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_inboxmessage.cpp
@@ -0,0 +1,19 @@
+--- packages/arb-avm-cpp/avm/src/inboxmessage.cpp.orig 2022-01-14 20:17:14 UTC
++++ packages/arb-avm-cpp/avm/src/inboxmessage.cpp
+@@ -154,14 +154,14 @@ InboxMessage InboxMessage::fromTuple(const Tuple& tup)
+ throw std::runtime_error("wrong tup size");
+ }
+ auto kind =
+- intx::narrow_cast<uint8_t>(get<uint256_t>(tup.get_element_unsafe(0)));
++ narrow_cast<uint8_t>(get<uint256_t>(tup.get_element_unsafe(0)));
+ auto block_number = get<uint256_t>(tup.get_element_unsafe(1));
+ auto timestamp = get<uint256_t>(tup.get_element_unsafe(2));
+ auto sender_int = get<uint256_t>(tup.get_element_unsafe(3));
+ auto inbox_sequence_number = get<uint256_t>(tup.get_element_unsafe(4));
+ auto gas_price_l1 = get<uint256_t>(tup.get_element_unsafe(5));
+ auto data_size =
+- intx::narrow_cast<uint64_t>(get<uint256_t>(tup.get_element_unsafe(6)));
++ narrow_cast<uint64_t>(get<uint256_t>(tup.get_element_unsafe(6)));
+ auto data_buf = get<Buffer>(tup.get_element_unsafe(7));
+
+ uint8_t raw_sender[32];
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machine.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machine.cpp
new file mode 100644
index 000000000000..16e34a85962d
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machine.cpp
@@ -0,0 +1,17 @@
+--- packages/arb-avm-cpp/avm/src/machine.cpp.orig 2022-01-18 18:44:56 UTC
++++ packages/arb-avm-cpp/avm/src/machine.cpp
+@@ -95,11 +95,11 @@ Assertion Machine::run() {
+ if (auto sideload_blocked = std::get_if<SideloadBlocked>(&block_reason)) {
+ sideload_block_number = sideload_blocked->block_number;
+ }
+- return {intx::narrow_cast<uint64_t>(machine_state.output.total_steps -
++ return {narrow_cast<uint64_t>(machine_state.output.total_steps -
+ start_steps),
+- intx::narrow_cast<uint64_t>(machine_state.output.arb_gas_used -
++ narrow_cast<uint64_t>(machine_state.output.arb_gas_used -
+ start_gas),
+- intx::narrow_cast<uint64_t>(machine_state.getTotalMessagesRead() -
++ narrow_cast<uint64_t>(machine_state.getTotalMessagesRead() -
+ initialConsumed),
+ std::move(machine_state.context.sends),
+ std::move(machine_state.context.logs),
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machinestate_machineoperation.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machinestate_machineoperation.cpp
new file mode 100644
index 000000000000..25a842a23333
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_avm_src_machinestate_machineoperation.cpp
@@ -0,0 +1,254 @@
+--- packages/arb-avm-cpp/avm/src/machinestate/machineoperation.cpp.orig 2021-12-14 20:02:23 UTC
++++ packages/arb-avm-cpp/avm/src/machinestate/machineoperation.cpp
+@@ -465,6 +465,251 @@ Tuple decodeKeccakState(const uint64_t* state) {
+ }
+ } // namespace internal
+
++static inline uint64_t rol(uint64_t x, unsigned s)
++{
++ return (x << s) | (x >> (64 - s));
++}
++
++static const uint64_t round_constants[24] = {
++ 0x0000000000000001,
++ 0x0000000000008082,
++ 0x800000000000808a,
++ 0x8000000080008000,
++ 0x000000000000808b,
++ 0x0000000080000001,
++ 0x8000000080008081,
++ 0x8000000000008009,
++ 0x000000000000008a,
++ 0x0000000000000088,
++ 0x0000000080008009,
++ 0x000000008000000a,
++ 0x000000008000808b,
++ 0x800000000000008b,
++ 0x8000000000008089,
++ 0x8000000000008003,
++ 0x8000000000008002,
++ 0x8000000000000080,
++ 0x000000000000800a,
++ 0x800000008000000a,
++ 0x8000000080008081,
++ 0x8000000000008080,
++ 0x0000000080000001,
++ 0x8000000080008008,
++};
++
++void ethash_keccakf1600(uint64_t state[25])
++{
++ uint64_t Aba, Abe, Abi, Abo, Abu;
++ uint64_t Aga, Age, Agi, Ago, Agu;
++ uint64_t Aka, Ake, Aki, Ako, Aku;
++ uint64_t Ama, Ame, Ami, Amo, Amu;
++ uint64_t Asa, Ase, Asi, Aso, Asu;
++
++ uint64_t Eba, Ebe, Ebi, Ebo, Ebu;
++ uint64_t Ega, Ege, Egi, Ego, Egu;
++ uint64_t Eka, Eke, Eki, Eko, Eku;
++ uint64_t Ema, Eme, Emi, Emo, Emu;
++ uint64_t Esa, Ese, Esi, Eso, Esu;
++
++ uint64_t Ba, Be, Bi, Bo, Bu;
++
++ uint64_t Da, De, Di, Do, Du;
++
++ Aba = state[0];
++ Abe = state[1];
++ Abi = state[2];
++ Abo = state[3];
++ Abu = state[4];
++ Aga = state[5];
++ Age = state[6];
++ Agi = state[7];
++ Ago = state[8];
++ Agu = state[9];
++ Aka = state[10];
++ Ake = state[11];
++ Aki = state[12];
++ Ako = state[13];
++ Aku = state[14];
++ Ama = state[15];
++ Ame = state[16];
++ Ami = state[17];
++ Amo = state[18];
++ Amu = state[19];
++ Asa = state[20];
++ Ase = state[21];
++ Asi = state[22];
++ Aso = state[23];
++ Asu = state[24];
++
++ for (int round = 0; round < 24; round += 2)
++ {
++ /* Round (round + 0): Axx -> Exx */
++
++ Ba = Aba ^ Aga ^ Aka ^ Ama ^ Asa;
++ Be = Abe ^ Age ^ Ake ^ Ame ^ Ase;
++ Bi = Abi ^ Agi ^ Aki ^ Ami ^ Asi;
++ Bo = Abo ^ Ago ^ Ako ^ Amo ^ Aso;
++ Bu = Abu ^ Agu ^ Aku ^ Amu ^ Asu;
++
++ Da = Bu ^ rol(Be, 1);
++ De = Ba ^ rol(Bi, 1);
++ Di = Be ^ rol(Bo, 1);
++ Do = Bi ^ rol(Bu, 1);
++ Du = Bo ^ rol(Ba, 1);
++
++ Ba = Aba ^ Da;
++ Be = rol(Age ^ De, 44);
++ Bi = rol(Aki ^ Di, 43);
++ Bo = rol(Amo ^ Do, 21);
++ Bu = rol(Asu ^ Du, 14);
++ Eba = Ba ^ (~Be & Bi) ^ round_constants[round];
++ Ebe = Be ^ (~Bi & Bo);
++ Ebi = Bi ^ (~Bo & Bu);
++ Ebo = Bo ^ (~Bu & Ba);
++ Ebu = Bu ^ (~Ba & Be);
++
++ Ba = rol(Abo ^ Do, 28);
++ Be = rol(Agu ^ Du, 20);
++ Bi = rol(Aka ^ Da, 3);
++ Bo = rol(Ame ^ De, 45);
++ Bu = rol(Asi ^ Di, 61);
++ Ega = Ba ^ (~Be & Bi);
++ Ege = Be ^ (~Bi & Bo);
++ Egi = Bi ^ (~Bo & Bu);
++ Ego = Bo ^ (~Bu & Ba);
++ Egu = Bu ^ (~Ba & Be);
++
++ Ba = rol(Abe ^ De, 1);
++ Be = rol(Agi ^ Di, 6);
++ Bi = rol(Ako ^ Do, 25);
++ Bo = rol(Amu ^ Du, 8);
++ Bu = rol(Asa ^ Da, 18);
++ Eka = Ba ^ (~Be & Bi);
++ Eke = Be ^ (~Bi & Bo);
++ Eki = Bi ^ (~Bo & Bu);
++ Eko = Bo ^ (~Bu & Ba);
++ Eku = Bu ^ (~Ba & Be);
++
++ Ba = rol(Abu ^ Du, 27);
++ Be = rol(Aga ^ Da, 36);
++ Bi = rol(Ake ^ De, 10);
++ Bo = rol(Ami ^ Di, 15);
++ Bu = rol(Aso ^ Do, 56);
++ Ema = Ba ^ (~Be & Bi);
++ Eme = Be ^ (~Bi & Bo);
++ Emi = Bi ^ (~Bo & Bu);
++ Emo = Bo ^ (~Bu & Ba);
++ Emu = Bu ^ (~Ba & Be);
++
++ Ba = rol(Abi ^ Di, 62);
++ Be = rol(Ago ^ Do, 55);
++ Bi = rol(Aku ^ Du, 39);
++ Bo = rol(Ama ^ Da, 41);
++ Bu = rol(Ase ^ De, 2);
++ Esa = Ba ^ (~Be & Bi);
++ Ese = Be ^ (~Bi & Bo);
++ Esi = Bi ^ (~Bo & Bu);
++ Eso = Bo ^ (~Bu & Ba);
++ Esu = Bu ^ (~Ba & Be);
++
++
++ /* Round (round + 1): Exx -> Axx */
++
++ Ba = Eba ^ Ega ^ Eka ^ Ema ^ Esa;
++ Be = Ebe ^ Ege ^ Eke ^ Eme ^ Ese;
++ Bi = Ebi ^ Egi ^ Eki ^ Emi ^ Esi;
++ Bo = Ebo ^ Ego ^ Eko ^ Emo ^ Eso;
++ Bu = Ebu ^ Egu ^ Eku ^ Emu ^ Esu;
++
++ Da = Bu ^ rol(Be, 1);
++ De = Ba ^ rol(Bi, 1);
++ Di = Be ^ rol(Bo, 1);
++ Do = Bi ^ rol(Bu, 1);
++ Du = Bo ^ rol(Ba, 1);
++
++ Ba = Eba ^ Da;
++ Be = rol(Ege ^ De, 44);
++ Bi = rol(Eki ^ Di, 43);
++ Bo = rol(Emo ^ Do, 21);
++ Bu = rol(Esu ^ Du, 14);
++ Aba = Ba ^ (~Be & Bi) ^ round_constants[round + 1];
++ Abe = Be ^ (~Bi & Bo);
++ Abi = Bi ^ (~Bo & Bu);
++ Abo = Bo ^ (~Bu & Ba);
++ Abu = Bu ^ (~Ba & Be);
++
++ Ba = rol(Ebo ^ Do, 28);
++ Be = rol(Egu ^ Du, 20);
++ Bi = rol(Eka ^ Da, 3);
++ Bo = rol(Eme ^ De, 45);
++ Bu = rol(Esi ^ Di, 61);
++ Aga = Ba ^ (~Be & Bi);
++ Age = Be ^ (~Bi & Bo);
++ Agi = Bi ^ (~Bo & Bu);
++ Ago = Bo ^ (~Bu & Ba);
++ Agu = Bu ^ (~Ba & Be);
++
++ Ba = rol(Ebe ^ De, 1);
++ Be = rol(Egi ^ Di, 6);
++ Bi = rol(Eko ^ Do, 25);
++ Bo = rol(Emu ^ Du, 8);
++ Bu = rol(Esa ^ Da, 18);
++ Aka = Ba ^ (~Be & Bi);
++ Ake = Be ^ (~Bi & Bo);
++ Aki = Bi ^ (~Bo & Bu);
++ Ako = Bo ^ (~Bu & Ba);
++ Aku = Bu ^ (~Ba & Be);
++
++ Ba = rol(Ebu ^ Du, 27);
++ Be = rol(Ega ^ Da, 36);
++ Bi = rol(Eke ^ De, 10);
++ Bo = rol(Emi ^ Di, 15);
++ Bu = rol(Eso ^ Do, 56);
++ Ama = Ba ^ (~Be & Bi);
++ Ame = Be ^ (~Bi & Bo);
++ Ami = Bi ^ (~Bo & Bu);
++ Amo = Bo ^ (~Bu & Ba);
++ Amu = Bu ^ (~Ba & Be);
++
++ Ba = rol(Ebi ^ Di, 62);
++ Be = rol(Ego ^ Do, 55);
++ Bi = rol(Eku ^ Du, 39);
++ Bo = rol(Ema ^ Da, 41);
++ Bu = rol(Ese ^ De, 2);
++ Asa = Ba ^ (~Be & Bi);
++ Ase = Be ^ (~Bi & Bo);
++ Asi = Bi ^ (~Bo & Bu);
++ Aso = Bo ^ (~Bu & Ba);
++ Asu = Bu ^ (~Ba & Be);
++ }
++
++ state[0] = Aba;
++ state[1] = Abe;
++ state[2] = Abi;
++ state[3] = Abo;
++ state[4] = Abu;
++ state[5] = Aga;
++ state[6] = Age;
++ state[7] = Agi;
++ state[8] = Ago;
++ state[9] = Agu;
++ state[10] = Aka;
++ state[11] = Ake;
++ state[12] = Aki;
++ state[13] = Ako;
++ state[14] = Aku;
++ state[15] = Ama;
++ state[16] = Ame;
++ state[17] = Ami;
++ state[18] = Amo;
++ state[19] = Amu;
++ state[20] = Asa;
++ state[21] = Ase;
++ state[22] = Asi;
++ state[23] = Aso;
++ state[24] = Asu;
++}
++
+ void keccakF(MachineState& m) {
+ m.stack.prepForMod(1);
+ auto tup = assumeTuple(m, m.stack[0]);
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_carbcore.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_carbcore.cpp
new file mode 100644
index 000000000000..e2af00bacedf
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_carbcore.cpp
@@ -0,0 +1,56 @@
+--- packages/arb-avm-cpp/cavm/carbcore.cpp.orig 2022-01-14 20:19:18 UTC
++++ packages/arb-avm-cpp/cavm/carbcore.cpp
+@@ -362,7 +362,7 @@ Uint256Result arbCoreLogsCursorGetPosition(CArbCore* a
+ auto cursor_index = receiveUint256(index_ptr);
+ try {
+ auto count_result = arb_core->logsCursorPosition(
+- intx::narrow_cast<size_t>(cursor_index));
++ narrow_cast<size_t>(cursor_index));
+ if (!count_result.status.ok()) {
+ return {{}, false};
+ }
+@@ -381,7 +381,7 @@ int arbCoreLogsCursorRequest(CArbCore* arbcore_ptr,
+
+ try {
+ auto status = arbcore->logsCursorRequest(
+- intx::narrow_cast<size_t>(cursor_index), count);
++ narrow_cast<size_t>(cursor_index), count);
+
+ return status;
+ } catch (const std::exception& e) {
+@@ -399,7 +399,7 @@ IndexedDoubleByteSliceArrayResult arbCoreLogsCursorGet
+
+ try {
+ auto result =
+- arbcore->logsCursorGetLogs(intx::narrow_cast<size_t>(cursor_index));
++ arbcore->logsCursorGetLogs(narrow_cast<size_t>(cursor_index));
+ if (!result.status.ok()) {
+ if (!result.status.IsTryAgain()) {
+ std::cerr << "Error getting logs from logs cursor: "
+@@ -450,7 +450,7 @@ int arbCoreLogsCursorConfirmReceived(CArbCore* arbcore
+
+ try {
+ auto status = arbcore->logsCursorConfirmReceived(
+- intx::narrow_cast<size_t>(cursor_index));
++ narrow_cast<size_t>(cursor_index));
+
+ return status;
+ } catch (const std::exception& e) {
+@@ -466,7 +466,7 @@ int arbCoreLogsCursorCheckError(CArbCore* arbcore_ptr,
+
+ try {
+ return arbcore->logsCursorCheckError(
+- intx::narrow_cast<size_t>(cursor_index));
++ narrow_cast<size_t>(cursor_index));
+ } catch (const std::exception& e) {
+ std::cerr << "Exception while checking error for logscursor "
+ << e.what() << std::endl;
+@@ -482,7 +482,7 @@ char* arbCoreLogsCursorClearError(CArbCore* arbcore_pt
+
+ try {
+ auto str = arbcore->logsCursorClearError(
+- intx::narrow_cast<size_t>(cursor_index));
++ narrow_cast<size_t>(cursor_index));
+
+ if (str.empty()) {
+ return nullptr;
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_cmachine.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_cmachine.cpp
new file mode 100644
index 000000000000..df7932d6f219
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_cavm_cmachine.cpp
@@ -0,0 +1,20 @@
+--- packages/arb-avm-cpp/cavm/cmachine.cpp.orig 2022-01-14 20:19:39 UTC
++++ packages/arb-avm-cpp/cavm/cmachine.cpp
+@@ -230,14 +230,14 @@ RawAssertionResult executeAssertion(CMachine* m,
+
+ // TODO extend usage of uint256
+ return {
+- {intx::narrow_cast<uint64_t>(assertion.inbox_messages_consumed),
++ {narrow_cast<uint64_t>(assertion.inbox_messages_consumed),
+ returnCharVector(sendData),
+ static_cast<int>(assertion.sends.size()),
+ returnCharVector(logData), static_cast<int>(assertion.logs.size()),
+ returnCharVector(debugPrintData),
+ static_cast<int>(assertion.debug_prints.size()),
+- intx::narrow_cast<uint64_t>(assertion.step_count),
+- intx::narrow_cast<uint64_t>(assertion.gas_count)},
++ narrow_cast<uint64_t>(assertion.step_count),
++ narrow_cast<uint64_t>(assertion.gas_count)},
+ false};
+ } catch (const DataStorage::shutting_down_exception& e) {
+ return {makeEmptyAssertion(), true};
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_include_data__storage_value_valuecache.hpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_include_data__storage_value_valuecache.hpp
new file mode 100644
index 000000000000..95479ee93f76
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_include_data__storage_value_valuecache.hpp
@@ -0,0 +1,11 @@
+--- packages/arb-avm-cpp/data_storage/include/data_storage/value/valuecache.hpp.orig 2021-12-14 20:02:23 UTC
++++ packages/arb-avm-cpp/data_storage/include/data_storage/value/valuecache.hpp
+@@ -30,7 +30,7 @@ class ValueCache {
+ private:
+ struct ValueCacheHasher {
+ std::size_t operator()(const uint256_t& hash) const noexcept {
+- return intx::narrow_cast<std::size_t>(hash);
++ return narrow_cast<std::size_t>(hash);
+ }
+ };
+
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_src_arbcore.cpp b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_src_arbcore.cpp
new file mode 100644
index 000000000000..a3b1f1bc3dd4
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_data__storage_src_arbcore.cpp
@@ -0,0 +1,11 @@
+--- packages/arb-avm-cpp/data_storage/src/arbcore.cpp.orig 2022-01-14 20:20:15 UTC
++++ packages/arb-avm-cpp/data_storage/src/arbcore.cpp
+@@ -3063,7 +3063,7 @@ rocksdb::Status ArbCore::handleLogsCursorReorg(size_t
+ log_count) {
+ // Only part of the data needs to be removed
+ auto logs_to_keep =
+- intx::narrow_cast<long>(log_count - current_count_result.data);
++ narrow_cast<long>(log_count - current_count_result.data);
+ logs_cursors[cursor_index].data.erase(
+ logs_cursors[cursor_index].data.begin() + logs_to_keep,
+ logs_cursors[cursor_index].data.end());
diff --git a/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_external_CMakeLists.txt b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_external_CMakeLists.txt
new file mode 100644
index 000000000000..0fdc6bab902b
--- /dev/null
+++ b/net-p2p/arbitrum-avm/files/patch-packages_arb-avm-cpp_external_CMakeLists.txt
@@ -0,0 +1,29 @@
+--- packages/arb-avm-cpp/external/CMakeLists.txt.orig 2022-01-18 18:15:08 UTC
++++ packages/arb-avm-cpp/external/CMakeLists.txt
+@@ -1,23 +1,12 @@
+ include(ExternalProject)
+
+-ExternalProject_Add(secp256k1_ext
+- SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/secp256k1"
+- INSTALL_DIR "${CMAKE_BINARY_DIR}"
+- CONFIGURE_COMMAND ./autogen.sh COMMAND <SOURCE_DIR>/configure --enable-module-recovery --prefix <INSTALL_DIR>
+- BUILD_COMMAND make
+- UPDATE_COMMAND ""
+- BUILD_IN_SOURCE 1
+-)
+-
+ add_library(secp256k1 IMPORTED STATIC GLOBAL)
+-add_dependencies (secp256k1 secp256k1_ext)
+-ExternalProject_Get_Property(secp256k1_ext install_dir)
+
+-file(MAKE_DIRECTORY ${install_dir}/include)
++file(MAKE_DIRECTORY /usr/local/include)
+
+ set_target_properties(secp256k1 PROPERTIES
+- "IMPORTED_LOCATION" "${install_dir}/lib/libsecp256k1.a"
+- "INTERFACE_INCLUDE_DIRECTORIES" "${install_dir}/include"
++ "IMPORTED_LOCATION" "/usr/local/lib/libsecp256k1.a"
++ "INTERFACE_INCLUDE_DIRECTORIES" "/usr/local/include"
+
+ )
+
diff --git a/net-p2p/arbitrum-avm/pkg-descr b/net-p2p/arbitrum-avm/pkg-descr
new file mode 100644
index 000000000000..2349123ce982
--- /dev/null
+++ b/net-p2p/arbitrum-avm/pkg-descr
@@ -0,0 +1,7 @@
+Arbitrum is a Layer 2 cryptocurrency platform that makes smart contracts
+scalable, fast, and private. Arbitrum interoperates closely with Ethereum,
+so Ethereum developers can easily cross-compile their contracts to run on
+Arbitrum. Arbitrum achieves these goals through a unique combination of
+incentives, network protocol design, and virtual machine architecture.
+
+WWW: https://arbitrum.io/