From e6e9eb1337238c46db2a92c2cfeaaf4027fdf378 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:26:21 -0300 Subject: [PATCH 01/13] Extract generation of `da-rpc-sys` libs --- Makefile | 3 +++ relayer/libs/Dockerfile | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 relayer/libs/Dockerfile diff --git a/Makefile b/Makefile index f9ea23e6..b34b017a 100644 --- a/Makefile +++ b/Makefile @@ -121,6 +121,9 @@ tests-unit: ## runs all unit tests tests-contract: ## runs all forge tests cd contracts/evm && forge test +near-da-rpc-sys: + docker build --file ./relayer/libs/Dockerfile --output ./relayer/libs . + # TODO: Currently we cannot use the race detector with `integration_test.go` tests-integration: ## runs all integration tests go test ./tests/integration/integration_test.go -v -count=1 diff --git a/relayer/libs/Dockerfile b/relayer/libs/Dockerfile new file mode 100644 index 00000000..0e4927ec --- /dev/null +++ b/relayer/libs/Dockerfile @@ -0,0 +1,16 @@ +FROM rust:1.77 AS builder + +# Install cbindgen for C bindings compilation +RUN cargo install --force cbindgen + +WORKDIR /near-da +RUN git clone https://github.com/taco-paco/rollup-data-availability.git + +WORKDIR /near-da/rollup-data-availability +RUN git checkout c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 + +# Build & copy libnear_da_rpc_sys static library for relayer compilation +RUN make da-rpc-sys + +FROM scratch AS export-stage +COPY --from=builder /near-da/rollup-data-availability/gopkg/da-rpc/lib . From 4fb60a36a6b320adabe5bb6c585611d95caa9f77 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:26:50 -0300 Subject: [PATCH 02/13] Ignore native lib files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 66e38368..d367a739 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,7 @@ setup/operator/config/keys/bls.json setup/operator/config/keys/ecdsa.json setup/plugin/config/keys/bls.json setup/plugin/config/keys/ecdsa.json + +# Near DA RPC libs +libnear_da_rpc_sys.* + From 116f0d8eee67a0152fd12e6dc7d7a052c97995af Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:27:25 -0300 Subject: [PATCH 03/13] Fix relayer - Link to native libs - Fix CLI args --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b34b017a..fd5e261b 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,8 @@ start-indexer: ## cargo run -p indexer --release -- --home-dir ~/.near/localnet run --da-contract-ids da.test.near --rollup-ids 2 --rmq-address "amqp://127.0.0.1:5672" start-test-relayer: ## - go run relayer/cmd/main.go --rpc-url ws://127.0.0.1:8546 --da-account-id da.test.near + export CGO_LDFLAGS="-L ./relayer/libs" + go run relayer/cmd/main.go run-args --rpc-url ws://127.0.0.1:8546 --da-account-id da.test.near --key-path ~/.near-credentials/localnet/da.test.near.json run-plugin: ## go run plugin/cmd/main.go --config config-files/operator.anvil.yaml From 103fe73a308b503c0738e5611fd06d04ec6d34a2 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:29:48 -0300 Subject: [PATCH 04/13] Update configs for make based commands - Based on `config-files/operator0-docker-compose.anvil.yaml` --- config-files/operator.anvil.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config-files/operator.anvil.yaml b/config-files/operator.anvil.yaml index 4349686c..85a1645b 100644 --- a/config-files/operator.anvil.yaml +++ b/config-files/operator.anvil.yaml @@ -1,7 +1,7 @@ # this sets the logger level (true = info, false = debug) -production: true +production: false -operator_address: 0x0000000000000000000000000000000000000000 +operator_address: 0xD5A0359da7B310917d7760385516B2426E86ab7f # EigenLayer Slasher contract address @@ -19,7 +19,7 @@ eth_ws_url: ws://localhost:8545 # this should be /operator_keys/ecdsa_key.json as the host path will be asked while running # # If you are running locally using go run main.go, this should be full path to your local ecdsa key file -ecdsa_private_key_store_path: tests/keys/ecdsa/1.ecdsa.key.json +ecdsa_private_key_store_path: tests/keys/ecdsa/1/key.json # If you running this using eigenlayer CLI and the provided AVS packaging structure, # this should be /operator_keys/bls_key.json as the host path will be asked while running @@ -27,7 +27,7 @@ ecdsa_private_key_store_path: tests/keys/ecdsa/1.ecdsa.key.json # We are using bn254 curve for bls keys # # If you are running locally using go run main.go, this should be full path to your local bls key file -bls_private_key_store_path: tests/keys/bls/1.bls.key.json +bls_private_key_store_path: tests/keys/bls/1/key.json aggregator_server_ip_port_address: localhost:8090 @@ -43,7 +43,7 @@ register_operator_on_startup: true token_strategy_addr: 0x95401dc811bb5740090279Ba06cfA8fcF6113778 near_da_indexer_rmq_ip_port_address: amqp://localhost:5672 -near_da_indexer_rollup_ids: [0] +near_da_indexer_rollup_ids: [2, 3] rollup_ids_to_rpc_urls: 1: ws://localhost:8545 From 948eb4c927825305025ad56e03afd9243d9352f6 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:40:52 -0300 Subject: [PATCH 05/13] Preserve `production = true` --- config-files/operator.anvil.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-files/operator.anvil.yaml b/config-files/operator.anvil.yaml index 85a1645b..d45fb609 100644 --- a/config-files/operator.anvil.yaml +++ b/config-files/operator.anvil.yaml @@ -1,5 +1,5 @@ # this sets the logger level (true = info, false = debug) -production: false +production: true operator_address: 0xD5A0359da7B310917d7760385516B2426E86ab7f From 9ce892fd831ee55d0e506eead691e00b6f563a4c Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:55:49 -0300 Subject: [PATCH 06/13] Remove lib Dockerfile --- relayer/libs/Dockerfile | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 relayer/libs/Dockerfile diff --git a/relayer/libs/Dockerfile b/relayer/libs/Dockerfile deleted file mode 100644 index 0e4927ec..00000000 --- a/relayer/libs/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:1.77 AS builder - -# Install cbindgen for C bindings compilation -RUN cargo install --force cbindgen - -WORKDIR /near-da -RUN git clone https://github.com/taco-paco/rollup-data-availability.git - -WORKDIR /near-da/rollup-data-availability -RUN git checkout c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 - -# Build & copy libnear_da_rpc_sys static library for relayer compilation -RUN make da-rpc-sys - -FROM scratch AS export-stage -COPY --from=builder /near-da/rollup-data-availability/gopkg/da-rpc/lib . From b790c4580004df36102a72e8502c6eba6b7a3d4d Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 15:56:14 -0300 Subject: [PATCH 07/13] Use direct commands to build native libs --- Makefile | 9 ++++++++- README.md | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fd5e261b..ee1e5d75 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,14 @@ tests-contract: ## runs all forge tests cd contracts/evm && forge test near-da-rpc-sys: - docker build --file ./relayer/libs/Dockerfile --output ./relayer/libs . + cd relayer/libs && \ + git clone https://github.com/taco-paco/rollup-data-availability.git && \ + cd rollup-data-availability && \ + git checkout c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 && \ + make da-rpc-sys && \ + cd .. && \ + cp rollup-data-availability/gopkg/da-rpc/lib/* . && \ + rm rollup-data-availability -rf # TODO: Currently we cannot use the race detector with `integration_test.go` tests-integration: ## runs all integration tests diff --git a/README.md b/README.md index 98ae9a51..501c2d66 100644 --- a/README.md +++ b/README.md @@ -86,12 +86,20 @@ make start-indexer make setup-near-da ``` -Lastly, start the operator and the relayer: +Then, start the operator: ```bash make start-operator ``` +Lastly, start the relayer. For this, certain native dependencies are required which need to be built at least once: + +```bash +make near-da-rpc-sys +``` + +Once the dependencies are built, start the relayer + ```bash make start-test-relayer ``` From 2a9fa65c49a179c6a5dd64896b999d9356ea1548 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Fri, 21 Jun 2024 16:03:31 -0300 Subject: [PATCH 08/13] Reuse existing submodule --- Makefile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ee1e5d75..c3a666ef 100644 --- a/Makefile +++ b/Makefile @@ -123,14 +123,11 @@ tests-contract: ## runs all forge tests cd contracts/evm && forge test near-da-rpc-sys: - cd relayer/libs && \ - git clone https://github.com/taco-paco/rollup-data-availability.git && \ - cd rollup-data-availability && \ - git checkout c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 && \ + rm -rf relayer/libs && \ + mkdir relayer/libs && \ + cd submodules/rollup-data-availability && \ make da-rpc-sys && \ - cd .. && \ - cp rollup-data-availability/gopkg/da-rpc/lib/* . && \ - rm rollup-data-availability -rf + cp gopkg/da-rpc/lib/* ../../relayer/libs # TODO: Currently we cannot use the race detector with `integration_test.go` tests-integration: ## runs all integration tests From e1d63cfda9ef51689b39f0b02cbcaaaea060dd9d Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Mon, 24 Jun 2024 09:55:15 -0300 Subject: [PATCH 09/13] Add lib dep submodule --- .gitmodules | 3 +++ submodules/rollup-data-availability | 1 + 2 files changed, 4 insertions(+) create mode 160000 submodules/rollup-data-availability diff --git a/.gitmodules b/.gitmodules index 9c4263aa..37e28d1a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "contracts/evm/lib/eigenlayer-middleware"] path = contracts/evm/lib/eigenlayer-middleware url = https://github.com/Layr-Labs/eigenlayer-middleware +[submodule "submodules/rollup-data-availability"] + path = submodules/rollup-data-availability + url = https://github.com/taco-paco/rollup-data-availability.git diff --git a/submodules/rollup-data-availability b/submodules/rollup-data-availability new file mode 160000 index 00000000..c9ec1292 --- /dev/null +++ b/submodules/rollup-data-availability @@ -0,0 +1 @@ +Subproject commit c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 From 6181ee82e76b08c5184c1a9a744b18b86e63fba8 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 25 Jun 2024 17:26:18 -0300 Subject: [PATCH 10/13] Prefer temp clone over submodule - Scope `CGO_LDFLAGS` to single command --- .gitmodules | 3 --- Makefile | 9 +++++---- submodules/rollup-data-availability | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 160000 submodules/rollup-data-availability diff --git a/.gitmodules b/.gitmodules index 37e28d1a..9c4263aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "contracts/evm/lib/eigenlayer-middleware"] path = contracts/evm/lib/eigenlayer-middleware url = https://github.com/Layr-Labs/eigenlayer-middleware -[submodule "submodules/rollup-data-availability"] - path = submodules/rollup-data-availability - url = https://github.com/taco-paco/rollup-data-availability.git diff --git a/Makefile b/Makefile index c3a666ef..e11e38d7 100644 --- a/Makefile +++ b/Makefile @@ -104,8 +104,7 @@ start-indexer: ## cargo run -p indexer --release -- --home-dir ~/.near/localnet run --da-contract-ids da.test.near --rollup-ids 2 --rmq-address "amqp://127.0.0.1:5672" start-test-relayer: ## - export CGO_LDFLAGS="-L ./relayer/libs" - go run relayer/cmd/main.go run-args --rpc-url ws://127.0.0.1:8546 --da-account-id da.test.near --key-path ~/.near-credentials/localnet/da.test.near.json + CGO_LDFLAGS="-L ./relayer/libs" go run relayer/cmd/main.go run-args --rpc-url ws://127.0.0.1:8546 --da-account-id da.test.near --key-path ~/.near-credentials/localnet/da.test.near.json run-plugin: ## go run plugin/cmd/main.go --config config-files/operator.anvil.yaml @@ -125,9 +124,11 @@ tests-contract: ## runs all forge tests near-da-rpc-sys: rm -rf relayer/libs && \ mkdir relayer/libs && \ - cd submodules/rollup-data-availability && \ + git clone https://github.com/taco-paco/rollup-data-availability.git && \ + cd rollup-data-availability && \ + git checkout c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 && \ make da-rpc-sys && \ - cp gopkg/da-rpc/lib/* ../../relayer/libs + cp gopkg/da-rpc/lib/* ../relayer/libs # TODO: Currently we cannot use the race detector with `integration_test.go` tests-integration: ## runs all integration tests diff --git a/submodules/rollup-data-availability b/submodules/rollup-data-availability deleted file mode 160000 index c9ec1292..00000000 --- a/submodules/rollup-data-availability +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 From 6e280931b517852c9ee15e7d9939d78bcb06e898 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 25 Jun 2024 18:13:34 -0300 Subject: [PATCH 11/13] Remove temp repo after build --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e11e38d7..d6c9b34c 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,9 @@ near-da-rpc-sys: cd rollup-data-availability && \ git checkout c9ec12924b27e37b8c40e7ab1a051a64b363cfd6 && \ make da-rpc-sys && \ - cp gopkg/da-rpc/lib/* ../relayer/libs + cp gopkg/da-rpc/lib/* ../relayer/libs && \ + cd .. && \ + rm -rf rollup-data-availability # TODO: Currently we cannot use the race detector with `integration_test.go` tests-integration: ## runs all integration tests From 9c85c10033d547d9b7307e47170ab3231acd9629 Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 2 Jul 2024 11:56:05 -0300 Subject: [PATCH 12/13] Append existing `CGO_LDFLAGS` if any --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d6c9b34c..2f952dec 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,7 @@ start-indexer: ## cargo run -p indexer --release -- --home-dir ~/.near/localnet run --da-contract-ids da.test.near --rollup-ids 2 --rmq-address "amqp://127.0.0.1:5672" start-test-relayer: ## - CGO_LDFLAGS="-L ./relayer/libs" go run relayer/cmd/main.go run-args --rpc-url ws://127.0.0.1:8546 --da-account-id da.test.near --key-path ~/.near-credentials/localnet/da.test.near.json + CGO_LDFLAGS="-L ./relayer/libs ${CGO_LDFLAGS}" go run relayer/cmd/main.go run-args --rpc-url ws://127.0.0.1:8546 --da-account-id da.test.near --key-path ~/.near-credentials/localnet/da.test.near.json run-plugin: ## go run plugin/cmd/main.go --config config-files/operator.anvil.yaml From 862c4a1ecea200a9e49e1dc2f8a22963f150f8cc Mon Sep 17 00:00:00 2001 From: Lautaro Emanuel Date: Tue, 2 Jul 2024 12:40:16 -0300 Subject: [PATCH 13/13] Update `introduction.md` build instructions --- docs/docs/introduction.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md index 27dd3a12..696fc3d4 100644 --- a/docs/docs/introduction.md +++ b/docs/docs/introduction.md @@ -91,12 +91,20 @@ make start-indexer make setup-near-da ``` -Lastly, start the operator and the relayer: +Then, start the operator: ```bash make start-operator ``` +Lastly, start the relayer. For this, certain native dependencies are required which need to be built at least once: + +```bash +make near-da-rpc-sys +``` + +Once the dependencies are built, start the relayer + ```bash make start-test-relayer ```