-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/store-block-number-and-hashes
- Loading branch information
Showing
36 changed files
with
505 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,3 +121,45 @@ jobs: | |
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: contracts/output.sarif | ||
|
||
abis: | ||
needs: init | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Restore cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: contracts | ||
key: ci-solidity-${{ github.ref }} | ||
|
||
- name: Restore forge | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: forge | ||
path: /usr/local/bin | ||
|
||
- run: chmod +x /usr/local/bin/forge | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
|
||
- name: Install abigen | ||
run: go install github.com/ethereum/go-ethereum/cmd/[email protected] | ||
|
||
- name: Generate ABIs | ||
run: dev/generate | ||
|
||
- name: Check for ABI changes | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
if git diff --exit-code --ignore-space-change --ignore-all-space --ignore-cr-at-eol -- contracts/pkg; then | ||
echo "No ABI changes detected." | ||
else | ||
echo "ERROR: Generated files are not up to date. Please run 'contracts/dev/generate' and commit the changes." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
#!/bin/bash | ||
# Deploy the smart contracts to the local anvil node | ||
set -euo pipefail | ||
|
||
# Make sure the build directory exists | ||
mkdir -p ./build | ||
############################################ | ||
# Work always from the contracts directory # | ||
############################################ | ||
export source_dir="${SOURCE_DIR:-src}" | ||
export build_dir="${BUILD_DIR:-build}" | ||
export output_dir="${OUTPUT_DIR:-pkg}" | ||
export localnet_dir="${LOCALNET_DIR:-config/anvil_localnet}" | ||
|
||
# Always work from the contracts directory | ||
script_dir=$(dirname "$(realpath "$0")") | ||
repo_root=$(realpath "${script_dir}/../") | ||
cd "${repo_root}" | ||
|
||
mkdir -p "${build_dir}" \ | ||
"${output_dir}" \ | ||
"${localnet_dir}" | ||
|
||
source dev/lib/env | ||
source dev/lib/common | ||
|
||
# Update depencencies | ||
forge soldeer update &> /dev/null | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: Failed to update dependencies" | ||
exit 1 | ||
fi | ||
|
||
############################################ | ||
# Deploy the smart contracts to ${RPC_URL} # | ||
############################################ | ||
forge_clean | ||
forge_soldeer_update | ||
forge_build_contracts | ||
forge_test_contracts | ||
forge_deploy_script group_messages | ||
forge_deploy_script identity_updates | ||
forge_deploy_script nodes src/Nodes.sol Nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,103 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
function get_chain_id() { | ||
hex_chain_id=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","id":1}' ${RPC_URL} | jq -r '.result') | ||
export chain_id=$((hex_chain_id)) | ||
} | ||
|
||
function forge_deploy_script() { | ||
get_chain_id | ||
case $1 in | ||
group_messages) | ||
forge script --rpc-url "${DOCKER_RPC_URL}" --broadcast script/DeployGroupMessages.s.sol &> /dev/null | ||
echo "⧖ Deploying GroupMessages to chainId ${chain_id} using RPC ${RPC_URL}" | ||
forge script --quiet --rpc-url "${RPC_URL}" --broadcast script/DeployGroupMessages.s.sol | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to deploy group messages contract" | ||
exit 1 | ||
fi | ||
|
||
echo -e "✅ GroupMessages contract deployed.\n" | ||
cat config/anvil_localnet/GroupMessages.json | ||
echo -e "\n" | ||
echo -e "\033[32m✔\033[0m GroupMessages deployed. Deployment details in contracts/config/anvil_localnet/GroupMessages.json\n" | ||
;; | ||
|
||
identity_updates) | ||
forge script --rpc-url "${DOCKER_RPC_URL}" --broadcast script/DeployIdentityUpdates.s.sol &> /dev/null | ||
echo "⧖ Deploying IdentityUpdates to chainId ${chain_id} using RPC ${RPC_URL}" | ||
forge script --quiet --rpc-url "${RPC_URL}" --broadcast script/DeployIdentityUpdates.s.sol | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to deploy identity updates contract" | ||
exit 1 | ||
fi | ||
|
||
echo -e "✅ IdentityUpdates contract deployed.\n" | ||
cat config/anvil_localnet/IdentityUpdates.json | ||
echo -e "\n" | ||
echo -e "\033[32m✔\033[0m IdentityUpdates deployed. Deployment details in contracts/config/anvil_localnet/IdentityUpdates.json\n" | ||
;; | ||
|
||
nodes) | ||
# TODO: Migrate to forge script | ||
forge create --broadcast --legacy --json --rpc-url $DOCKER_RPC_URL --private-key $PRIVATE_KEY "$2:$3" > ../build/$3.json | ||
echo -e "✅ Nodes contract deployed.\n" | ||
cat ../build/$3.json | ||
echo -e "\n" | ||
echo "⧖ Deploying Nodes to chainId ${chain_id} using RPC ${RPC_URL}" | ||
forge create --broadcast --legacy --json --rpc-url $RPC_URL --private-key $PRIVATE_KEY "$2:$3" > config/anvil_localnet/$3.json | ||
echo -e "\033[32m✔\033[0m Nodes deployed. Deployment details in contracts/config/anvil_localnet/$3.json\n" | ||
;; | ||
|
||
*) | ||
echo "Invalid option. Use 'group_messages' or 'identity_updates'." | ||
echo "Invalid option. Use 'group_messages', 'identity_updates' or 'nodes'." | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
function forge_clean() { | ||
echo -e "⧖ Cleaning old artifacts" | ||
|
||
forge clean &> .forge_clean.tmp.log | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: Failed to clean old artifacts" | ||
cat .forge_clean.tmp.log | ||
exit 1 | ||
fi | ||
rm .forge_clean.tmp.log | ||
|
||
echo -e "\033[32m✔\033[0m Old artifacts cleaned successfully\n" | ||
} | ||
|
||
function forge_soldeer_update() { | ||
echo -e "⧖ Updating dependencies" | ||
|
||
forge soldeer update &> .forge_soldeer_update.tmp.log | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: Failed to update dependencies" | ||
cat .forge_soldeer_update.tmp.log | ||
exit 1 | ||
fi | ||
rm .forge_soldeer_update.tmp.log | ||
|
||
echo -e "\033[32m✔\033[0m Dependencies updated successfully\n" | ||
} | ||
|
||
function forge_build_contracts() { | ||
echo -e "⧖ Building contracts" | ||
|
||
forge build &> .forge_build.tmp.log | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: Failed to build contracts" | ||
cat .forge_build.tmp.log | ||
exit 1 | ||
fi | ||
rm .forge_build.tmp.log | ||
|
||
echo -e "\033[32m✔\033[0m Contracts built successfully\n" | ||
} | ||
|
||
function forge_test_contracts() { | ||
echo -e "⧖ Running contract tests" | ||
|
||
forge test &> .forge_test.tmp.log | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: Tests failed" | ||
cat .forge_test.tmp.log | ||
exit 1 | ||
fi | ||
rm .forge_test.tmp.log | ||
|
||
echo -e "\033[32m✔\033[0m Tests passed successfully\n" | ||
} | ||
|
Oops, something went wrong.