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
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "sys-asm"]
path = sys-asm
url = https://github.com/wemeetagain/sys-asm.git
url = https://github.com/ethereum/sys-asm.git
branch = main
90 changes: 54 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,39 @@ clean:
rm -f miner/kernel/*.o miner/kernel/*.a

# ---------------------------------------------------------------------------
# Contract init code (assembled from the sys-asm submodule)
# Contract init code (pre-assembled bytecode from the sys-asm submodule)
#
# The predeploy contracts are geas assembly in the `sys-asm` submodule.
# Assembling ctor.eas yields `ctor ++ runtime` = the deployment init code,
# whose bytes determine the vanity address. These targets emit it 0x-prefixed,
# ready for `./nick search --initcode`.
# sys-asm commits the assembled bytecode under bytecode/<contract>/ctor.hex
# precisely so consumers don't need the geas assembler (whose output could
# differ between versions). ctor.hex is the full deployment init code
# (`ctor ++ runtime`), whose bytes determine the vanity address. These
# targets emit it 0x-prefixed, ready for `./nick search --initcode`.
#
# REF selects the sys-asm revision (a SHA is used from the local clone; a
# branch is fetched at runtime). Default = the pinned commit below.
# make initcode-deposit # pinned default (offline)
# By default the submodule is used as pinned by this repo's gitlink -- the
# init code bytes determine the vanity address, so the revision must not float
# silently. Bump the pin with: git submodule update --remote sys-asm
# (then commit the gitlink). REF optionally overrides the revision (a SHA is
# used from the local clone; a branch is fetched at runtime):
# make initcode-deposit # submodule as pinned (offline)
# make initcode-deposit REF=<sha> # any commit
# make initcode-deposit REF=<branch> # latest branch tip (fetches)
# TODO: when the contracts land on sys-asm main, point
# SYS_ASM_REMOTE=https://github.com/ethereum/sys-asm.git and REF=main.
# make initcode-deposit REF=main # latest upstream tip (fetches)
# ---------------------------------------------------------------------------
GEAS ?= $(shell command -v geas 2>/dev/null || echo "$$(go env GOPATH)/bin/geas")
SYS_ASM_DIR ?= sys-asm
SYS_ASM_REMOTE ?= https://github.com/wemeetagain/sys-asm.git
REF ?= 537b9c17d14705e77bc3f512e17dd253ad69b020
DEPOSIT_CTOR := $(SYS_ASM_DIR)/src/builder_deposits/ctor.eas
EXIT_CTOR := $(SYS_ASM_DIR)/src/builder_exits/ctor.eas
SYS_ASM_REMOTE ?= https://github.com/ethereum/sys-asm.git
REF ?=
DEPOSIT_HEX := $(SYS_ASM_DIR)/bytecode/builder_deposits/ctor.hex
EXIT_HEX := $(SYS_ASM_DIR)/bytecode/builder_exits/ctor.hex

# Vanity search parameters (override on the command line). The target address
# is 0x0000-leading with a 00<eip> suffix; sig-r spells the EIP number too.
# EIP has no default -- set it, or pass SUFFIX/SIG_R explicitly.
# make mine-deposit EIP=<num> # suffix 0x00<num>, sig-r 0x<num>
# make mine-deposit SUFFIX=0xdead SIG_R=0xdead # override directly
#
# The GPU search picks a random start offset by default, so each run scans a
# fresh range. Set START_NONCE to pin the offset for a reproducible search
# (requires a miner with --start-nonce support):
# make mine-deposit EIP=<num> START_NONCE=<n>
EIP ?=
PREFIX ?= 0x0000
SUFFIX ?= $(if $(EIP),0x00$(EIP))
Expand All @@ -110,47 +116,59 @@ SCORE ?= 10
GPU_BACKEND ?= cuda
GPU_DEVICES ?= all
BATCH ?= 67108864
START_NONCE ?=
RUNS_DIR ?= runs

# Ensure the sys-asm submodule is present, checked out at $(REF), and that geas
# is available. Run as a prerequisite of the init code / mining targets.
# Ensure the sys-asm submodule is present (checked out at $(REF) if set) and
# that the committed bytecode exists there. Run as a prerequisite of the init
# code / mining targets.
.sys-asm-ref:
@test -e $(DEPOSIT_CTOR) || git submodule update --init $(SYS_ASM_DIR) >/dev/null 2>&1 || { \
@test -e $(SYS_ASM_DIR)/.git || git submodule update --init $(SYS_ASM_DIR) >/dev/null 2>&1 || { \
echo "ERROR: sys-asm submodule missing; run: git submodule update --init $(SYS_ASM_DIR)"; exit 1; }
@if echo "$(REF)" | grep -qE '^[0-9a-fA-F]{7,40}$$'; then \
git -C $(SYS_ASM_DIR) checkout -q $(REF) 2>/dev/null || { \
@if test -n "$(REF)"; then \
if echo "$(REF)" | grep -qE '^[0-9a-fA-F]{7,40}$$'; then \
git -C $(SYS_ASM_DIR) checkout -q $(REF) 2>/dev/null || { \
git -C $(SYS_ASM_DIR) fetch -q $(SYS_ASM_REMOTE) $(REF) && \
git -C $(SYS_ASM_DIR) checkout -q FETCH_HEAD; }; \
else \
git -C $(SYS_ASM_DIR) fetch -q $(SYS_ASM_REMOTE) $(REF) && \
git -C $(SYS_ASM_DIR) checkout -q FETCH_HEAD; }; \
else \
git -C $(SYS_ASM_DIR) fetch -q $(SYS_ASM_REMOTE) $(REF) && \
git -C $(SYS_ASM_DIR) checkout -q FETCH_HEAD; \
git -C $(SYS_ASM_DIR) checkout -q FETCH_HEAD; \
fi; \
fi
@command -v $(GEAS) >/dev/null 2>&1 || test -x $(GEAS) || { \
echo "ERROR: geas not found; run: go install github.com/fjl/geas/cmd/geas@latest"; exit 1; }
@test -s $(DEPOSIT_HEX) -a -s $(EXIT_HEX) || { \
echo "ERROR: no committed bytecode at sys-asm $$(git -C $(SYS_ASM_DIR) rev-parse --short HEAD) ($(DEPOSIT_HEX) missing);"; \
echo " the builder contracts' bytecode is only committed on newer sys-asm revisions"; exit 1; }

## initcode-deposit: Print 0x-prefixed builder-deposit init code (pipeable)
initcode-deposit: .sys-asm-ref
@printf '0x%s\n' "$$($(GEAS) $(DEPOSIT_CTOR))"
@printf '0x%s\n' "$$(cat $(DEPOSIT_HEX))"

## initcode-exit: Print 0x-prefixed builder-exit init code (pipeable)
initcode-exit: .sys-asm-ref
@printf '0x%s\n' "$$($(GEAS) $(EXIT_CTOR))"
@printf '0x%s\n' "$$(cat $(EXIT_HEX))"

## initcode: Show both init codes with byte sizes and the assembled sys-asm commit
## initcode: Show both init codes with byte sizes and the sys-asm commit
initcode: .sys-asm-ref
@echo "sys-asm @ $$(git -C $(SYS_ASM_DIR) rev-parse --short HEAD) (REF=$(REF))"
@dep=$$($(GEAS) $(DEPOSIT_CTOR)); echo "deposit ($$(( $${#dep}/2 )) bytes): 0x$$dep"
@ext=$$($(GEAS) $(EXIT_CTOR)); echo "exit ($$(( $${#ext}/2 )) bytes): 0x$$ext"
@echo "sys-asm @ $$(git -C $(SYS_ASM_DIR) rev-parse --short HEAD)$(if $(REF), (REF=$(REF)))"
@dep=$$(cat $(DEPOSIT_HEX)); echo "deposit ($$(( $${#dep}/2 )) bytes): 0x$$dep"
@ext=$$(cat $(EXIT_HEX)); echo "exit ($$(( $${#ext}/2 )) bytes): 0x$$ext"

## mine-deposit: Assemble the deposit init code and run the GPU vanity search
## mine-deposit: Run the GPU vanity search on the committed deposit init code
mine-deposit: .sys-asm-ref
@test -n "$(SUFFIX)" -a -n "$(SIG_R)" || { \
echo "ERROR: which EIP do you want to mine for? Set EIP=<num>, e.g.:"; \
echo " make mine-deposit EIP=<num>"; \
echo " (or override SUFFIX=0x... SIG_R=0x... directly)"; exit 1; }
@test -x ./$(BINARY_NAME) || { echo "ERROR: ./$(BINARY_NAME) not built; run: make build-cuda"; exit 1; }
@mkdir -p $(RUNS_DIR)
@ts=$$(date +%Y-%m-%d_%H%M); log=$(RUNS_DIR)/mine-deposit-$$ts.log; res=$(RUNS_DIR)/mine-deposit-$$ts.result.txt; \
echo "logging to $$log"; \
./$(BINARY_NAME) search --gpu --gpu-backend $(GPU_BACKEND) --gpu-devices $(GPU_DEVICES) \
--batch-size $(BATCH) --initcode 0x$$($(GEAS) $(DEPOSIT_CTOR)) \
--prefix $(PREFIX) --suffix $(SUFFIX) --sig-r $(SIG_R) --score $(SCORE)
--batch-size $(BATCH) --initcode 0x$$(cat $(DEPOSIT_HEX)) \
--prefix $(PREFIX) --suffix $(SUFFIX) --sig-r $(SIG_R) --score $(SCORE) \
$(if $(START_NONCE),--start-nonce $(START_NONCE)) 2>&1 | tee $$log; \
awk '/^Found!/{f=1} f{print}' $$log > $$res; \
echo "result saved: $$res"

## help: Show this help
help:
Expand Down
2 changes: 1 addition & 1 deletion sys-asm
Submodule sys-asm updated 47 files
+20 βˆ’6 .github/workflows/test.yml
+3 βˆ’2 .gitignore
+0 βˆ’3 .gitmodules
+60 βˆ’0 Makefile
+21 βˆ’13 README.md
+1 βˆ’0 bytecode/beacon_root/ctor.hex
+1 βˆ’0 bytecode/beacon_root/main.hex
+1 βˆ’0 bytecode/builder_deposits/ctor.hex
+1 βˆ’0 bytecode/builder_deposits/main.hex
+1 βˆ’0 bytecode/builder_exits/ctor.hex
+1 βˆ’0 bytecode/builder_exits/main.hex
+1 βˆ’0 bytecode/consolidations/ctor.hex
+1 βˆ’0 bytecode/consolidations/main.hex
+1 βˆ’0 bytecode/execution_hash/ctor.hex
+1 βˆ’0 bytecode/execution_hash/main.hex
+1 βˆ’0 bytecode/factory/main.hex
+1 βˆ’0 bytecode/fake_expo_test/main.hex
+1 βˆ’0 bytecode/withdrawals/ctor.hex
+1 βˆ’0 bytecode/withdrawals/main.hex
+9 βˆ’0 checksums.txt
+1 βˆ’0 foundry.toml
+1 βˆ’1 lib/forge-std
+0 βˆ’1 lib/geas-ffi
+15 βˆ’17 scripts/addr.sh
+8 βˆ’8 src/beacon_root/ctor.eas
+110 βˆ’110 src/beacon_root/main.eas
+8 βˆ’14 src/builder_deposits/ctor.eas
+514 βˆ’547 src/builder_deposits/main.eas
+13 βˆ’13 src/builder_exits/ctor.eas
+403 βˆ’373 src/builder_exits/main.eas
+45 βˆ’46 src/common/fake_expo.eas
+31 βˆ’34 src/common/fake_expo_test.eas
+60 βˆ’0 src/common/mstore.eas
+13 βˆ’13 src/consolidations/ctor.eas
+385 βˆ’384 src/consolidations/main.eas
+8 βˆ’8 src/execution_hash/ctor.eas
+84 βˆ’84 src/execution_hash/main.eas
+58 βˆ’0 src/factory/main.eas
+13 βˆ’13 src/withdrawals/ctor.eas
+390 βˆ’447 src/withdrawals/main.eas
+1 βˆ’2 test/BeaconRoot.t.sol
+94 βˆ’24 test/BuilderDeposit.t.sol
+105 βˆ’23 test/BuilderExit.t.sol
+2 βˆ’3 test/Consolidation.t.sol
+1 βˆ’2 test/ExecutionHash.t.sol
+1 βˆ’2 test/FakeExpo.t.sol
+2 βˆ’3 test/Withdrawal.t.sol