From 1880696e955d7b0334b8ecd3c634c9a8caaa07ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:40:46 -0300 Subject: [PATCH 1/7] feat: add Makefile target to generate bindings --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index f0ee3d6e..11841c89 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ PHONY: reset-anvil +REPO_ROOT:=$(shell pwd) + __CONTRACTS__: ## start-anvil-chain-with-contracts-deployed: ## @@ -30,5 +32,13 @@ lint: cargo fmt --all -- --check \ && cargo clippy --workspace --all-features --benches --examples --tests -- -D warnings +bindings: + @echo "Generating bindings..." + cd crates/contracts && \ + forge bind --alloy --bindings-path $(REPO_ROOT)/crates/utils --overwrite -C src/contracts + # Restore the Cargo.toml file + git restore crates/utils/Cargo.toml + @echo "Bindings generated" + start-anvil: reset-anvil ## $(MAKE) start-anvil-chain-with-contracts-deployed From 7ca72a84f5c2ff0a437f7819eff5ff01368d636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:51:44 -0300 Subject: [PATCH 2/7] docs: update readme's command --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2fb8e580..2e4648a9 100644 --- a/README.md +++ b/README.md @@ -39,17 +39,13 @@ cargo run --example get_quorum_count The main branch of this repo is intended to be syncronized with mainnet version of core contracts. -To update the bindings of this repo: - -- Inside the `crates/contracts` folder, run: +To update the bindings of this repo, run: ```bash -forge bind --alloy --bindings-path /crates/utils --overwrite -C src/contracts +forge bind --alloy --bindings-path crates/utils --overwrite --root crates/contracts ``` -where `path-eigensdk-rs` is the full path to the eigensdk-rs (this) repo. - -This command will generate the bindings files in the folder: `/crates/utils`. +This command will generate the bindings files in the folder: `crates/utils`. ⚠️ It rewrites Cargo.toml file, this file must be restored to the current version. From f19d9f181d1e57b6a2309b901643ad9fd8f9c2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:51:53 -0300 Subject: [PATCH 3/7] refactor: simplify bindings target --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 11841c89..f91568c1 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ PHONY: reset-anvil -REPO_ROOT:=$(shell pwd) - __CONTRACTS__: ## start-anvil-chain-with-contracts-deployed: ## @@ -34,8 +32,7 @@ lint: bindings: @echo "Generating bindings..." - cd crates/contracts && \ - forge bind --alloy --bindings-path $(REPO_ROOT)/crates/utils --overwrite -C src/contracts + forge bind --alloy --bindings-path crates/utils --overwrite --root crates/contracts # Restore the Cargo.toml file git restore crates/utils/Cargo.toml @echo "Bindings generated" From 80e34c980c32c18a0ea6aacda58ec9908c7e490e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:56:39 -0300 Subject: [PATCH 4/7] docs: update bindings command in readme --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e4648a9..44457f69 100644 --- a/README.md +++ b/README.md @@ -42,14 +42,12 @@ The main branch of this repo is intended to be syncronized with mainnet version To update the bindings of this repo, run: ```bash -forge bind --alloy --bindings-path crates/utils --overwrite --root crates/contracts +make bindings ``` This command will generate the bindings files in the folder: `crates/utils`. -⚠️ It rewrites Cargo.toml file, this file must be restored to the current version. - -- Fix all compilation warnings. +⚠️ Remember to fix all compilation warnings. ## Contributor Guidelines From 6c26365dbb47b32e5b2b31a251ef9d1a8e85cf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:56:56 -0300 Subject: [PATCH 5/7] chore: sync readmes --- crates/eigensdk/README.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/eigensdk/README.md b/crates/eigensdk/README.md index 2fb8e580..44457f69 100644 --- a/crates/eigensdk/README.md +++ b/crates/eigensdk/README.md @@ -39,21 +39,15 @@ cargo run --example get_quorum_count The main branch of this repo is intended to be syncronized with mainnet version of core contracts. -To update the bindings of this repo: - -- Inside the `crates/contracts` folder, run: +To update the bindings of this repo, run: ```bash -forge bind --alloy --bindings-path /crates/utils --overwrite -C src/contracts +make bindings ``` -where `path-eigensdk-rs` is the full path to the eigensdk-rs (this) repo. - -This command will generate the bindings files in the folder: `/crates/utils`. - -⚠️ It rewrites Cargo.toml file, this file must be restored to the current version. +This command will generate the bindings files in the folder: `crates/utils`. -- Fix all compilation warnings. +⚠️ Remember to fix all compilation warnings. ## Contributor Guidelines From 0eb45fbc089d116e072785ffdf4ed83f79073eb7 Mon Sep 17 00:00:00 2001 From: supernovahs Date: Thu, 9 Jan 2025 22:14:18 +0530 Subject: [PATCH 6/7] add forge build in make bindings --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index f91568c1..58f05d28 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,9 @@ lint: bindings: @echo "Generating bindings..." + cd crates/contracts + forge build + cd ../.. forge bind --alloy --bindings-path crates/utils --overwrite --root crates/contracts # Restore the Cargo.toml file git restore crates/utils/Cargo.toml From afa60f15700d9bf72cd884120af9feda1beec866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:01:12 -0300 Subject: [PATCH 7/7] fix: generate the bindings in steps --- Makefile | 60 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 58f05d28..1fabe965 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ deploy-contracts-to-anvil-and-save-state: ## __TESTING__: ## +start-anvil: reset-anvil ## + $(MAKE) start-anvil-chain-with-contracts-deployed + reset-anvil: -docker stop anvil -docker rm anvil @@ -30,15 +33,54 @@ lint: cargo fmt --all -- --check \ && cargo clippy --workspace --all-features --benches --examples --tests -- -D warnings +__BINDINGS__: ## + +### SDK bindings ### +SDK_CONTRACTS:="MockAvsServiceManager ContractsRegistry" +SDK_CONTRACTS_LOCATION:=crates/contracts +SDK_BINDINGS_PATH:=crates/utils/src/sdk +# The echo is to remove quotes, and the patsubst to make the regex match the full text only +SDK_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(SDK_CONTRACTS))) + + +### Middleware bindings ### +MIDDLEWARE_CONTRACTS:="RegistryCoordinator IndexRegistry OperatorStateRetriever StakeRegistry BLSApkRegistry IBLSSignatureChecker ServiceManagerBase IERC20" +MIDDLEWARE_CONTRACTS_LOCATION:=$(SDK_CONTRACTS_LOCATION)/lib/eigenlayer-middleware +MIDDLEWARE_BINDINGS_PATH:=crates/utils/src/middleware +# The echo is to remove quotes, and the patsubst to make the regex match the full text only +MIDDLEWARE_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(MIDDLEWARE_CONTRACTS))) + + +### Core bindings ### +CORE_CONTRACTS:="DelegationManager IRewardsCoordinator StrategyManager IEigenPod EigenPod IEigenPodManager EigenPodManager IStrategy AVSDirectory AllocationManager PermissionController" +CORE_CONTRACTS_LOCATION:=$(MIDDLEWARE_CONTRACTS_LOCATION)/lib/eigenlayer-contracts +CORE_BINDINGS_PATH:=crates/utils/src/core +# The echo is to remove quotes, and the patsubst to make the regex match the full text only +CORE_CONTRACTS_ARGS:=$(patsubst %, --select '^%$$', $(shell echo $(CORE_CONTRACTS))) + + +.PHONY: bindings bindings: @echo "Generating bindings..." - cd crates/contracts - forge build - cd ../.. - forge bind --alloy --bindings-path crates/utils --overwrite --root crates/contracts - # Restore the Cargo.toml file - git restore crates/utils/Cargo.toml - @echo "Bindings generated" + # Fetch submoduless + cd $(SDK_CONTRACTS_LOCATION) && forge install -start-anvil: reset-anvil ## - $(MAKE) start-anvil-chain-with-contracts-deployed + # Generate SDK bindings + cd $(SDK_CONTRACTS_LOCATION) && forge build --force --skip test --skip script + forge bind --alloy --skip-build --bindings-path $(SDK_BINDINGS_PATH) --overwrite \ + --root $(SDK_CONTRACTS_LOCATION) --module \ + $(SDK_CONTRACTS_ARGS) + + # Generate middleware bindings + cd $(MIDDLEWARE_CONTRACTS_LOCATION) && forge build --force --skip test --skip script + forge bind --alloy --skip-build --bindings-path $(MIDDLEWARE_BINDINGS_PATH) --overwrite \ + --root $(MIDDLEWARE_CONTRACTS_LOCATION) --module \ + $(MIDDLEWARE_CONTRACTS_ARGS) + + # Generate core bindings + cd $(CORE_CONTRACTS_LOCATION) && forge build --force --skip test --skip script + forge bind --alloy --skip-build --bindings-path $(CORE_BINDINGS_PATH) --overwrite \ + --root $(CORE_CONTRACTS_LOCATION) --module \ + $(CORE_CONTRACTS_ARGS) + + @echo "Bindings generated"