Skip to content

Commit

Permalink
Merge pull request #16 from lightclient/addr-gen
Browse files Browse the repository at this point in the history
scripts: add script to mine deployment addr
  • Loading branch information
lightclient authored Jul 10, 2024
2 parents 2ff402a + 1ad38d1 commit dea4517
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 14 deletions.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ go install github.com/fjl/geas/cmd/geas@latest
To assemble `src/withdrawals/main.eas` you will need to invoke `geas`:

```console
$ geas src/main.eas
$ geas src/withdrawals/main.eas
3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b36603814156101215760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012157600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f5460015460028282011161010f5750505f610115565b01600290035b5f555f600155604c025ff35b5f5ffd
```

Expand All @@ -46,8 +46,47 @@ Test result: ok. 5 passed; 0 failed; 0 skipped; finished in 870.90ms
Ran 1 test suites: 5 tests passed, 0 failed, 0 skipped (5 total tests)
```

## Deployment

System contracts are typically deployed using [Nick's method][nm] for predictable
deployment on all chains. To mine a deployment tx and address using this
technique, run the following:

```console
$ ./scripts/addr.sh withdrawals
searching for withdrawals deployment data
New highscore: 5
Sender: 0x96aeE04D69562D087EC52847Fc1a4FDAF2526002
Address: 0x0bb308c8c1F4933388CA65F63d941B76a829aAaA
Tx:
{
"type": "0x0",
"nonce": "0x0",
"to": null,
"gas": "0x3d090",
"gasPrice": "0xe8d4a51000",
"maxPriorityFeePerGas": null,
"maxFeePerGas": null,
"value": "0x0",
"input": "0x61049d5f5561013280600f5f395ff33373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff3
5b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e576001
54600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a457506010
5b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b91018092
1460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b016002
90035b5f555f600155604c025ff35b5f5ffd",
"v": "0x1b",
"r": "0x539",
"s": "0x2a68889c60a01e96",
"hash": "0x7e28e6a01f362160d9916ee19ed9079d46b0773d91fc80245edcec6dd855ffd7"
}
```

To deploy this transaction, simply fund the "sender" account and submit the tx
to the network.

[geas]: https://github.com/fjl/geas
[7002]: https://eips.ethereum.org/EIPS/eip-7002
[7251]: https://eips.ethereum.org/EIPS/eip-7251
[foundry]: https://getfoundry.sh/
[forge]: https://github.com/foundry-rs/foundry/blob/master/forge
[nm]: https://yamenmerhi.medium.com/nicks-method-ethereum-keyless-execution-168a6659479c
12 changes: 0 additions & 12 deletions script/Counter.s.sol

This file was deleted.

44 changes: 44 additions & 0 deletions scripts/addr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

if ! command -v go &> /dev/null
then
echo "Go is not installed. Please install Go and try again."
exit 1
fi

if ! command -v nick &> /dev/null
then
echo "nick could not be found, installing..."
go install github.com/lightclient/nick@latest
if [ $? -ne 0 ]; then
echo "Failed to install nick."
exit 1
fi
fi

if ! command -v geas &> /dev/null
then
echo "geas could not be found, installing..."
go install github.com/fjl/geas@latest
if [ $? -ne 0 ]; then
echo "Failed to install geas."
exit 1
fi
fi

default_score=5
score=${2:-$default_score}

case $1 in
withdrawals|wxs|7002)
echo "searching for withdrawals deployment data "
nick search --score=$score --initcode="0x$(geas src/withdrawals/ctor.eas)" --prefix=0x0000 --suffix=0xaaaa
;;
consolidations|cxs|7251)
echo "searching for consolidations deployment data "
nick search --score=$score --initcode="0x$(geas src/consolidations/ctor.eas)" --prefix=0x0000 --suffix=0xbbbb
;;
*)
echo "Invalid option. Usage: $0 {withdrawals|consolidations}"
;;
esac
2 changes: 1 addition & 1 deletion src/consolidations/ctor.eas
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ push0
return

.start:
#assemble "consolidation.eas"
#assemble "main.eas"
.end:

0 comments on commit dea4517

Please sign in to comment.