Skip to content

Commit

Permalink
Merge branch 'dev' into feat-improve-bls-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
taturosati authored Aug 23, 2024
2 parents 88dab6d + 9b3429c commit 225cc3f
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 34 deletions.
80 changes: 72 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
############################# HELP MESSAGE #############################
# Make sure the help command stays first, so that it's printed by default when `make` is called without arguments
.PHONY: help bindings mocks tests tests-cover fmt format-lines lint

GO_LINES_IGNORED_DIRS=contracts
GO_PACKAGES=./chainio/... ./crypto/... ./logging/... \
./types/... ./utils/... ./signer/... ./cmd/... \
./signerv2/... ./aws/... ./internal/... ./metrics/... \
./nodeapi/... ./cmd/... ./services/... ./testutils/...
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")

.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

bindings: ## generates contract bindings
cd contracts && rm -rf bindings/* && ./generate-bindings.sh

eigenpod-bindings: ## generates contract bindings for eigenpod
cd chainio/clients/eigenpod && ./generate.sh

.PHONY: mocks
mocks: ## generates mocks
go install go.uber.org/mock/[email protected]
go generate ./...

.PHONY: tests
tests: ## runs all tests
go test -race ./... -timeout=1m

.PHONY: tests-cover
tests-cover: ## run all tests with test coverge
go test -race ./... -coverprofile=coverage.out -covermode=atomic -v -count=1
go tool cover -html=coverage.out -o coverage.html
open coverage.html

godoc-port = 6060
.PHONY: godoc
godoc: ## runs godoc server and opens in browser
@echo "Starting godoc server on port $(godoc-port)..."
@-godoc -http=:$(godoc-port) & echo $$! > godoc.pid
Expand All @@ -42,22 +41,87 @@ godoc: ## runs godoc server and opens in browser
@# The read varname command will keep the make command running (waiting for input) until you press CTRL+C.
@trap 'kill `cat godoc.pid` && rm -f godoc.pid' EXIT; read varname

.PHONY: fmt
fmt: ## formats all go files
go fmt ./...
make format-lines

.PHONY: format-lines
format-lines: ## formats all go files with golines
go install github.com/segmentio/golines@latest
golines -w -m 120 --ignore-generated --shorten-comments --ignored-dirs=${GO_LINES_IGNORED_DIRS} ${GO_FOLDERS}

.PHONY: lint
lint: ## runs all linters
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./...


___BINDINGS___: ##

core_default := "DelegationManager IRewardsCoordinator ISlasher StrategyManager EigenPod EigenPodManager IStrategy IAVSDirectory"
core_location := "./lib/eigenlayer-middleware/lib/eigenlayer-contracts"
core_bindings_location := "../../../../bindings"

middleware_default := "RegistryCoordinator IndexRegistry OperatorStateRetriever StakeRegistry BLSApkRegistry IBLSSignatureChecker ServiceManagerBase IERC20"
middleware_location := "./lib/eigenlayer-middleware"
middleware_bindings_location := "../../bindings"

sdk_default := "MockAvsServiceManager ContractsRegistry"
sdk_location := "."
sdk_bindings_location := "./bindings"

# To generate bindings for specific contracts, run `make core-bindings contracts="DelegationManager IRewardsCoordinator"`
.PHONY: core-bindings ## generates core contracts bindings
core-bindings: ## generates core bindings
@echo "Starting core bindings generation"
ifneq ($(contracts),)
@echo "Contracts: $(contracts)"
cd contracts && ./generate-bindings.sh $(core_location) $(contracts) $(core_bindings_location)
else
@echo "Contracts: $(core_default)"
cd contracts && ./generate-bindings.sh $(core_location) $(core_default) $(core_bindings_location)
endif

# To generate bindings for specific contracts, run `make middleware-bindings contracts="RegistryCoordinator"`
.PHONY: middleware-bindings ## generates middleware contracts bindings
middleware-bindings: ## generates middleware bindings
@echo "Starting middleware bindings generation"
ifneq ($(contracts),)
@echo "Contracts: $(contracts)"
cd contracts && ./generate-bindings.sh $(middleware_location) $(contracts) $(middleware_bindings_location)
else
@echo "Contracts: $(middleware_default)"
cd contracts && ./generate-bindings.sh $(middleware_location) $(middleware_default) $(middleware_bindings_location)
endif

# To generate bindings for specific contracts, run `make sdk-bindings contracts="MockAvsServiceManager"`
.PHONY: sdk-bindings ## generates sdk contracts bindings
sdk-bindings: ## generates sdk bindings
@echo "Starting sdk bindings generation"
ifneq ($(contracts),)
@echo "Contracts: $(contracts)"
cd contracts && ./generate-bindings.sh $(sdk_location) $(contracts) $(sdk_bindings_location)
else
@echo "Contracts: $(middleware_default)"
cd contracts && ./generate-bindings.sh $(sdk_location) $(sdk_default) $(sdk_bindings_location)
endif

.PHONY: eigenpod-bindings
eigenpod-bindings: ## generates contract bindings for eigenpod
cd chainio/clients/eigenpod && ./generate.sh

.PHONY: bindings
bindings: ## generates all contract bindings
rm -rf bindings/* && make core-bindings middleware-bindings sdk-bindings eigenpod-bindings


___CONTRACTS___: ##

deploy-contracts-to-anvil-and-save-state: ##
.PHONY: deploy-contracts-to-anvil-and-save-state
deploy-contracts-to-anvil-and-save-state: ##
./contracts/anvil/deploy-contracts-save-anvil-state.sh

.PHONY: start-anvil-with-contracts-deployed
start-anvil-with-contracts-deployed: ##
./contracts/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
36 changes: 10 additions & 26 deletions contracts/generate-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,17 @@ function create_binding {
rm -rf data/tmp.abi data/tmp.bin
}

cd $script_path
forge build
sdk_contracts="MockAvsServiceManager ContractsRegistry"
for contract in $sdk_contracts; do
sleep 1 # this is a hack to fix the issue with abigen randomly failing for some contracts
create_binding . $contract ./bindings
done

EIGENLAYER_MIDDLEWARE_PATH=$script_path/lib/eigenlayer-middleware
cd $EIGENLAYER_MIDDLEWARE_PATH
# you might want to run forge clean if the contracts have changed
forge build
path=$1
echo "Generating bindings for contracts in path: $path"
cd "$path"
pwd

# No idea why but ordering of the contracts matters here... when I move them around sometimes bindings fail
avs_contracts="RegistryCoordinator IndexRegistry OperatorStateRetriever StakeRegistry BLSApkRegistry IBLSSignatureChecker ServiceManagerBase IERC20"
for contract in $avs_contracts; do
sleep 1 # this is a hack to fix the issue with abigen randomly failing for some contracts
create_binding . $contract ../../bindings
done
contracts=$2
bindings_path=$3

EIGENLAYER_CONTRACT_PATH=$EIGENLAYER_MIDDLEWARE_PATH/lib/eigenlayer-contracts
cd $EIGENLAYER_CONTRACT_PATH
forge build

# No idea why but the ordering of the contracts matters, and for some orderings abigen fails...
el_contracts="DelegationManager IRewardsCoordinator ISlasher StrategyManager EigenPod EigenPodManager IStrategy IAVSDirectory"
for contract in $el_contracts; do
echo "Generating bindings for contracts: $contracts"
for contract in $contracts; do
sleep 1 # this is a hack to fix the issue with abigen randomly failing for some contracts
create_binding . $contract ../../../../bindings
done
create_binding . "$contract" "$bindings_path"
done

0 comments on commit 225cc3f

Please sign in to comment.