Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[submodule "go-ethereum"]
path = go-ethereum
url = https://github.com/morph-l2/go-ethereum.git
branch = release/2.0.x
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################## update dependencies ####################

ETHEREUM_SUBMODULE_COMMIT_OR_TAG := morph-v2.0.8
ETHEREUM_TARGET_VERSION := morph-v2.0.8
TENDERMINT_TARGET_VERSION := v0.3.2

Expand Down Expand Up @@ -39,7 +39,13 @@ update:

submodules:
git submodule update --init
git submodule update --remote
@if [ -d "go-ethereum" ]; then \
echo "Updating go-ethereum submodule to tag $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG)..."; \
cd go-ethereum && \
git fetch --tags && \
git checkout $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG) && \
cd ..; \
fi
Comment on lines +42 to +48
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Improve error handling and use explicit tag reference in submodule checkout.

The conditional checkout logic is a good defensive approach, but there are two concerns:

  1. Error recovery: If git fetch --tags or git checkout fails, the cd .. command won't execute due to the && chain, leaving the working directory inside go-ethereum. This breaks subsequent operations that expect to be in the repository root.

  2. Ambiguous tag reference: git checkout $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG) can match either a tag or a branch. Using an explicit tag prefix avoids ambiguity.

Apply this diff to ensure we always return to the root directory and use explicit tag reference:

 	git submodule update --init
-	@if [ -d "go-ethereum" ]; then \
+	@if [ -d "go-ethereum" ]; then \
 		echo "Updating go-ethereum submodule to tag $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG)..."; \
-		cd go-ethereum && \
+		(cd go-ethereum && \
 		git fetch --tags && \
-		git checkout $(ETHEREUM_SUBMODULE_COMMIT_OR_TAG) && \
-		cd ..; \
+		git checkout tags/$(ETHEREUM_SUBMODULE_COMMIT_OR_TAG)) || exit 1; \
 	fi

This uses a subshell (...) to ensure the directory change doesn't persist, and explicitly references the tag to avoid branch ambiguity.

🤖 Prompt for AI Agents
In Makefile around lines 42-48, ensure the submodule update always returns to
the repo root and the checkout explicitly references a tag: run the git commands
inside a subshell so cd into go-ethereum cannot leak (e.g. (cd go-ethereum &&
git fetch --tags && git checkout refs/tags/$(ETHEREUM_SUBMODULE_COMMIT_OR_TAG)))
and handle failures by checking the subshell exit status to fail the step
cleanly; replace the ambiguous git checkout argument with
refs/tags/$(ETHEREUM_SUBMODULE_COMMIT_OR_TAG) to avoid matching branches.

.PHONY: submodules

################## bindings ####################
Expand Down