Skip to content

Commit

Permalink
ci: update e2e pipeline (#1495)
Browse files Browse the repository at this point in the history
* set staging accounts

Signed-off-by: Gregory Edison <[email protected]>

* rename + update e2e pipeline workflow and script

Signed-off-by: Gregory Edison <[email protected]>

* update GH_TOKEN to GITHUB_TOKEN

Signed-off-by: Gregory Edison <[email protected]>

* update urls

Signed-off-by: Gregory Edison <[email protected]>

* fix addresses

Signed-off-by: Gregory Edison <[email protected]>

* fix script + karnot config

Signed-off-by: Gregory Edison <[email protected]>

* typos

Signed-off-by: Gregory Edison <[email protected]>

* skip CairoPrecompiles

Signed-off-by: Gregory Edison <[email protected]>

* fix e2e pipeline script

Signed-off-by: Gregory Edison <[email protected]>

* revert changes to other files

Signed-off-by: Gregory Edison <[email protected]>

* update workflow

Signed-off-by: Gregory Edison <[email protected]>

* fix workflow fmt

Signed-off-by: Gregory Edison <[email protected]>

* use github token in action

Signed-off-by: Gregory Edison <[email protected]>

* add comments

Signed-off-by: Gregory Edison <[email protected]>

---------

Signed-off-by: Gregory Edison <[email protected]>
  • Loading branch information
greged93 authored Oct 31, 2024
1 parent 1bceaf2 commit 55cbe3b
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
---
name: staging
name: e2e pipeline

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
environment:
description: Environment to run the action on.
required: true
type: choice
options:
- sepolia
- staging
action:
description:
Action to perform on the selected environment. `Deploy` will
upgrade/deploy the Kakarot contracts, while `test` will run the end 2
end tests on the currently deployed stack.
required: true
type: choice
options:
- deploy
- test

jobs:
stage:
Expand All @@ -12,7 +31,6 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
- name: install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -30,23 +48,32 @@ jobs:
scarb-version: 0.7.0
- name: Run staging script
env:
KAKAROT_STAGING_PRIVATE_KEY:
${{ secrets.KAKAROT_STAGING_PRIVATE_KEY }}
STARKNET_SEPOLIA_STAGING_PRIVATE_KEY:
${{ secrets.STARKNET_SEPOLIA_STAGING_PRIVATE_KEY }}
STARKNET_SEPOLIA_STAGING_ACCOUNT_ADDRESS:
${{ secrets.STARKNET_SEPOLIA_STAGING_ACCOUNT_ADDRESS }}
INFURA_KEY: ${{ secrets.INFURA_KEY }}
run: |
cd scripts
sh upgrade.sh deploy test --staging
sh e2e_pipeline.sh ${{ github.event.inputs.action }} --${{ github.event.inputs.environment }}
- name: Check diff in deployments
run: |
cd lib/kakarot
set +e
git diff --no-patch --exit-code -- deployments/kakarot-staging/
git diff --no-patch --exit-code -- deployments/
has_diff=$?
set -e
echo "has_diff=$has_diff" >> $GITHUB_ENV
- uses: actions/create-github-app-token@v1
id: github_token
with:
app-id: ${{ secrets.KAKAROT_BOT_APP_ID }}
private-key: ${{ secrets.KAKAROT_BOT_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Create PR for deployment updates
if: ${{ env.has_diff == 1 }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ steps.github_token.outputs.token }}
run: |
set +e
cd lib/kakarot
Expand Down
Binary file modified docker/hive/docs/hive_strategy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 61 additions & 61 deletions docker/hive/genesis-2.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
{
"config": {
"chainId": 1337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"shanghaiTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x0",
"extraData": "0x",
"gasLimit": "0x4c4b40",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"0000000000000000000000000000000000031ec7": {
"code": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033",
"balance": "0xde0b6b3a7640000"
"config": {
"chainId": 1337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"shanghaiTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"ethash": {}
},
"658bdf435d810c91414ec09147daa6db62406379": {
"balance": "0x487a9a304539440000"
"nonce": "0x0",
"timestamp": "0x0",
"extraData": "0x",
"gasLimit": "0x4c4b40",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"0000000000000000000000000000000000031ec7": {
"code": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033",
"balance": "0xde0b6b3a7640000"
},
"658bdf435d810c91414ec09147daa6db62406379": {
"balance": "0x487a9a304539440000"
},
"aa00000000000000000000000000000000000000": {
"code": "0x6042",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0100000000000000000000000000000000000000000000000000000000000000": "0x0100000000000000000000000000000000000000000000000000000000000000",
"0x0200000000000000000000000000000000000000000000000000000000000000": "0x0200000000000000000000000000000000000000000000000000000000000000",
"0x0300000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000303"
},
"balance": "0x1",
"nonce": "0x1"
},
"bb00000000000000000000000000000000000000": {
"code": "0x600154600354",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0100000000000000000000000000000000000000000000000000000000000000": "0x0100000000000000000000000000000000000000000000000000000000000000",
"0x0200000000000000000000000000000000000000000000000000000000000000": "0x0200000000000000000000000000000000000000000000000000000000000000",
"0x0300000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000303"
},
"balance": "0x2",
"nonce": "0x1"
}
},
"aa00000000000000000000000000000000000000": {
"code": "0x6042",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0100000000000000000000000000000000000000000000000000000000000000": "0x0100000000000000000000000000000000000000000000000000000000000000",
"0x0200000000000000000000000000000000000000000000000000000000000000": "0x0200000000000000000000000000000000000000000000000000000000000000",
"0x0300000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000303"
},
"balance": "0x1",
"nonce": "0x1"
},
"bb00000000000000000000000000000000000000": {
"code": "0x600154600354",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0100000000000000000000000000000000000000000000000000000000000000": "0x0100000000000000000000000000000000000000000000000000000000000000",
"0x0200000000000000000000000000000000000000000000000000000000000000": "0x0200000000000000000000000000000000000000000000000000000000000000",
"0x0300000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000303"
},
"balance": "0x2",
"nonce": "0x1"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "0x3b9aca00"
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "0x3b9aca00"
}
14 changes: 7 additions & 7 deletions docker/hive/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ cat /genesis.json
mv /genesis.json /genesis/hive-genesis.json
echo "Creating the genesis file..."
hive_genesis \
-k genesis/contracts \
--hive-genesis genesis/hive-genesis.json \
-g genesis.json \
-m manifest.json
-k genesis/contracts \
--hive-genesis genesis/hive-genesis.json \
-g genesis.json \
-m manifest.json
mv /genesis/hive-genesis.json /hive-genesis.json && rm -fr /genesis

# 2. Start Katana
Expand Down Expand Up @@ -40,9 +40,9 @@ if test -f "/chain.rlp"; then
echo "Launching Hive Chain..."
# THIS needs to be changed if Katana ever updates their predeployed accounts
hive_chain \
--chain-path /chain.rlp \
--relayer-address 0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca \
--relayer-pk 0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a
--chain-path /chain.rlp \
--relayer-address 0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca \
--relayer-pk 0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a
fi

# 3. Start the Indexer service: DNA Indexer, Indexer transformer, and MongoDB
Expand Down
58 changes: 34 additions & 24 deletions scripts/upgrade.sh → scripts/e2e_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ for arg in "$@"; do
deploy)
run_deploy=true
;;
--staging)
ENV="kakarot-staging"
;;
--sepolia)
ENV="sepolia"
;;
--staging)
ENV="sepolia-staging"
;;
*)
echo "Unknown argument: ${arg}"
usage
Expand All @@ -50,59 +50,69 @@ if [ -z "${ENV}" ]; then
echo "Please provide the environment to test against"
exit 1
fi
if [ -z "${INFURA_KEY}" ]; then
echo "Please provide the INFURA_KEY environment variable"
exit 1
fi

cd ../lib/kakarot || exit
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python"
export STARKNET_NETWORK="${ENV}"
export L1_RPC_URL="https://sepolia.infura.io/v3/${INFURA_KEY}"

# Set the environment variables based on the provided environment
if [ "${ENV}" = "sepolia" ]; then
# Note: you might need to modify the following values in `lib/kakarot/kakarot_scripts/constants.py`:
# - NETWORKS["sepolia"].rpc_url = https://juno-kakarot-sepolia.karnot.xyz
# - NETWORKS["sepolia"].max_wait = 40
export STARKNET_SEPOLIA_RPC_URL="https://juno-kakarot-sepolia.karnot.xyz"
export RPC_URL="https://juno-kakarot-sepolia.karnot.xyz"
export RPC_NAME="starknet-sepolia"
export CHECK_INTERVAL=1
export MAX_WAIT=50
export WEB3_HTTP_PROVIDER_URI="https://rpc-kakarot-sepolia.karnot.xyz/"
if [ -z "${STARKNET_SEPOLIA_ACCOUNT_ADDRESS}" ]; then
echo "Please provide the STARKNET_SEPOLIA_ACCOUNT_ADDRESS environment variable"
echo "Please provide the STARKNET_SEPOLIA_ACCOUNT_ADDRESS environment variable."
exit 1
fi
if [ -z "${STARKNET_SEPOLIA_PRIVATE_KEY}" ]; then
echo "Please provide the STARKNET_SEPOLIA_PRIVATE_KEY environment variable"
echo "Please provide the STARKNET_SEPOLIA_PRIVATE_KEY environment variable."
exit 1
fi
if [ -z "${EVM_PRIVATE_KEY}" ]; then
echo "Please provide the EVM_PRIVATE_KEY environment variable"
echo "Please provide the EVM_PRIVATE_KEY environment variable."
exit 1
fi
SKIP="--ignore tests/end_to_end/L1L2Messaging --ignore tests/end_to_end/CairoPrecompiles --ignore tests/end_to_end/EvmPrecompiles --ignore tests/end_to_end/test_kakarot.py"
elif [ "${ENV}" = "kakarot-staging" ]; then
SKIP="--ignore tests/end_to_end/L1L2Messaging --ignore tests/end_to_end/CairoPrecompiles -k 'not test_should_set_account_bytecode and not test_should_set_account_nonce and not test_should_upgrade_account_class and not test_should_raise_when_class_hash_is_not_declared and not test_should_upgrade_class_hash and not test_should_transfer_ownership and not test_should_return_transaction_count and not test_should_withdraw_all_eth'"
elif [ "${ENV}" = "sepolia-staging" ]; then
export EVM_PRIVATE_KEY="0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
export KAKAROT_STAGING_RPC_URL="https://juno-kakarot-testnet-stage.karnot.xyz"
export KAKAROT_STAGING_ACCOUNT_ADDRESS="0x7ecf6cd45c32ce84812e660cc176cb8b4de2e7a6d5916fe326bf871466fbe02"
export WEB3_HTTP_PROVIDER_URI="https://kkrt-rpc-kakarot-testnet-stage.karnot.xyz"
if [ -z "${KAKAROT_STAGING_PRIVATE_KEY}" ]; then
echo "Please provide the KAKAROT_STAGING_PRIVATE_KEY environment variable. The private key should be loaded using gpg: gpg -r [email protected] --decrypt path/to/encrypted/key.gpg"
export RPC_URL="https://juno-kakarot-sepolia.karnot.xyz/"
export RPC_NAME="starknet-sepolia-staging"
export CHECK_INTERVAL=1
export MAX_WAIT=50
export WEB3_HTTP_PROVIDER_URI="https://rpc-kakarot-sepolia-staging.karnot.xyz/"
if [ -z "${STARKNET_SEPOLIA_STAGING_ACCOUNT_ADDRESS}" ]; then
echo "Please provide the STARKNET_SEPOLIA_STAGING_ACCOUNT_ADDRESS environment variable."
exit 1
fi
if [ -z "${STARKNET_SEPOLIA_STAGING_PRIVATE_KEY}" ]; then
echo "Please provide the STARKNET_SEPOLIA_STAGING_PRIVATE_KEY environment variable."
exit 1
fi

SKIP="--ignore tests/end_to_end/L1L2Messaging"
SKIP="--ignore tests/end_to_end/L1L2Messaging --ignore tests/end_to_end/CairoPrecompiles -k 'not test_should_set_account_bytecode and not test_should_set_account_nonce and not test_should_upgrade_account_class and not test_should_raise_when_class_hash_is_not_declared and not test_should_upgrade_class_hash and not test_should_transfer_ownership and not test_should_return_transaction_count and not test_should_withdraw_all_eth'"
fi

# Deploy the contracts if the deploy command is provided
if ${run_deploy}; then
echo "Deploying the contracts to the ${ENV} environment"

make setup && make build-sol && make build && make fetch-ssj-artifacts && make build-cairo1
uv run python ./kakarot_scripts/deploy_kakarot.py
uv sync --all-extras --dev && make build-sol && make build
uv run deploy
fi

# Run the tests if the test command is provided
if ${run_test}; then
echo "Running tests for the ${ENV} environment. Skipping: ${SKIP}"

KAKAROT_ADDRESS=$(jq -r '.kakarot.address' ./deployments/kakarot-"${ENV}"/deployments.json)
UNINITIALIZED_ACCOUNT_CLASS_HASH=$(jq -r '.uninitialized_account' ./deployments/kakarot-"${ENV}"/declarations.json)
ACCOUNT_CONTRACT_CLASS_HASH=$(jq -r '.account_contract' ./deployments/kakarot-"${ENV}"/declarations.json)
KAKAROT_ADDRESS=$(jq -r '.kakarot' ./deployments/starknet-"${ENV}"/deployments.json)
UNINITIALIZED_ACCOUNT_CLASS_HASH=$(jq -r '.uninitialized_account' ./deployments/starknet-"${ENV}"/declarations.json)
ACCOUNT_CONTRACT_CLASS_HASH=$(jq -r '.account_contract' ./deployments/starknet-"${ENV}"/declarations.json)

export KAKAROT_ADDRESS="${KAKAROT_ADDRESS}"
export UNINITIALIZED_ACCOUNT_CLASS_HASH="${UNINITIALIZED_ACCOUNT_CLASS_HASH}"
Expand Down

0 comments on commit 55cbe3b

Please sign in to comment.