Skip to content

Cleanups #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
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
7 changes: 3 additions & 4 deletions .github/integration-tests/bor_health.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
set -e

while true
do
while true; do
peers=$(docker exec bor0 bash -c "bor attach /var/lib/bor/data/bor.ipc -exec 'admin.peers'")
block=$(docker exec bor0 bash -c "bor attach /var/lib/bor/data/bor.ipc -exec 'eth.blockNumber'")

Expand All @@ -11,5 +10,5 @@ do
fi
done

echo "$peers"
echo "$block"
echo "Peers: $peers"
echo "Block number: $block"
20 changes: 0 additions & 20 deletions .github/integration-tests/fund_anvil_accounts.sh

This file was deleted.

15 changes: 7 additions & 8 deletions .github/integration-tests/smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ checkpointFound="false"
SECONDS=0
start_time=$SECONDS

while true
do
while true; do

balance=$(docker exec bor0 bash -c "bor attach /var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")

Expand All @@ -18,9 +17,9 @@ do
exit 1
fi

if (( balance > balanceInit )); then
if ((balance > balanceInit)); then
if [ $stateSyncFound != "true" ]; then
stateSyncTime=$(( SECONDS - start_time ))
stateSyncTime=$((SECONDS - start_time))
stateSyncFound="true"
fi
fi
Expand All @@ -29,16 +28,16 @@ do

if [ "$checkpointID" != "null" ]; then
if [ $checkpointFound != "true" ]; then
checkpointTime=$(( SECONDS - start_time ))
checkpointTime=$((SECONDS - start_time))
checkpointFound="true"
fi
fi

if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then
if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then
break
fi

done
echo "Both state sync and checkpoint went through. All tests have passed!"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $((stateSyncTime%3600/60)) $((stateSyncTime%60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $((checkpointTime%3600/60)) $((checkpointTime%60)))"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $((stateSyncTime % 3600 / 60)) $((stateSyncTime % 60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $((checkpointTime % 3600 / 60)) $((checkpointTime % 60)))"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
sed -i 's,gcp-key,matic-cli-ci-key,' .env
sed -i 's,/absolute/path/to/your/,/home/runner/work/matic-cli/matic-cli/matic-cli/gcp/,' .env
sed -i 's,YOUR_PROJECT_ID,prj-polygonlabs-pos-v1-dev,' .env
sed -i 's,MATIC_CLI_BRANCH=master,MATIC_CLI_BRANCH=$GITHUB_HEAD_REF,' .env
sed -i "s,MATIC_CLI_BRANCH=master,MATIC_CLI_BRANCH=$GITHUB_HEAD_REF," .env

- name: Get GitHub action runner IP
id: ip
Expand Down
2 changes: 0 additions & 2 deletions src/express/commands/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import { maxRetries, runSshCommand } from '../common/remote-worker.js'
import { timer } from '../common/time-utils.js'
import dotenv from 'dotenv'
import { fundAnvilAccounts } from '../common/anvil-utils.js'

export async function cleanup() {
dotenv.config({ path: `${process.cwd()}/.env` })
Expand All @@ -16,7 +15,6 @@ export async function cleanup() {
await cleanupServices(doc)
await startServices(doc)
await deployBorContractsAndStateSync(doc)
await fundAnvilAccounts(doc)
}

export async function stopServices(doc) {
Expand Down
40 changes: 19 additions & 21 deletions src/express/commands/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function getStateSyncTxList(ip, startTime, endTime) {
async function lastStateIdFromBor(ip) {
const web3 = new Web3(`http://${ip}:8545`)

const StateReceiverContract = await new web3.eth.Contract(
const StateReceiverContract = new web3.eth.Contract(
lastStateIdABI,
stateReceiverAddress
)
Expand All @@ -110,7 +110,7 @@ async function lastStateIdFromBor(ip) {
async function getLatestCheckpointFromRootChain(ip, rootChainProxyAddress) {
const web3 = new Web3(`http://${ip}:9545`)

const RootChainContract = await new web3.eth.Contract(
const RootChainContract = new web3.eth.Contract(
currentHeaderBlockABI,
rootChainProxyAddress
)
Expand Down Expand Up @@ -152,15 +152,12 @@ export async function monitor(exitWhenDone) {

// noinspection InfiniteLoopJS
while (true) {
await timer(1000)
await timer(5000)
console.log()

const checkpointCount = await checkCheckpoint(machine0)
if (checkpointCount > 0) {
console.log(
'📍Checkpoint found on Heimdall ✅ ; Count: ',
checkpointCount
)
console.log('📍Checkpoint found on Heimdall ✅; Count:', checkpointCount)
} else {
console.log('📍Awaiting Checkpoint on Heimdall 🚌')
}
Expand All @@ -171,7 +168,7 @@ export async function monitor(exitWhenDone) {
)
if (checkpointCountFromRootChain > 0) {
console.log(
'📍Checkpoint found on Root chain ✅ ; Count: ',
'📍Checkpoint found on Root chain ✅; Count:',
checkpointCountFromRootChain
)
} else {
Expand All @@ -180,7 +177,7 @@ export async function monitor(exitWhenDone) {

const firstStateSyncTx = await checkStateSyncTx(machine0, 1)
let stateSyncTxList
let lastStateID
let lastStateSyncTxID
if (firstStateSyncTx) {
const timeOfFirstStateSyncTx = firstStateSyncTx.record_time
const firstEpochTime = parseInt(
Expand All @@ -193,32 +190,33 @@ export async function monitor(exitWhenDone) {
currentEpochTime
)
if (stateSyncTxList) {
lastStateID = stateSyncTxList.length
const lastStateSyncTxHash = stateSyncTxList[lastStateID - 1].tx_hash
lastStateSyncTxID = stateSyncTxList.length
const lastStateSyncTxHash =
stateSyncTxList[lastStateSyncTxID - 1].tx_hash
console.log(
'📍StateSyncs found on Heimdall ✅ ; Count: ',
lastStateID,
' ; Last Tx Hash: ',
'📍StateSyncs found on Heimdall ✅; Count:',
lastStateSyncTxID,
'; Last Tx Hash:',
lastStateSyncTxHash
)
}
} else {
console.log('📍Awaiting StateSync 🚌')
}

const lastStateId = await lastStateIdFromBor(machine0)
if (lastStateId) {
console.log('📍LastStateId on Bor: ', lastStateId)
const lastStateIDFromBor = await lastStateIdFromBor(machine0)
if (lastStateIDFromBor) {
console.log('📍LastStateId on Bor:', lastStateIDFromBor)
} else {
console.log('📍Unable to fetch LastStateId ')
console.log('📍Unable to fetch LastStateId')
}

if (
exitWhenDone === true &&
lastStateId &&
lastStateID > 0 &&
checkpointCount > 0 &&
checkpointCountFromRootChain > 0 &&
checkpointCount > 0
lastStateSyncTxID > 0 &&
lastStateIDFromBor > 0
) {
console.log('📍All checks executed successfully')
process.exit(0)
Expand Down
3 changes: 0 additions & 3 deletions src/express/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import fs from 'fs'

import shell from 'shelljs'
import dotenv from 'dotenv'
import { fundAnvilAccounts } from '../common/anvil-utils.js'

async function terraformApply(devnetId) {
console.log('📍Executing terraform apply...')
Expand Down Expand Up @@ -502,6 +501,4 @@ export async function start() {
'utf8'
)
)

await fundAnvilAccounts(doc)
}
42 changes: 0 additions & 42 deletions src/setup/anvil/templates/ANVIL_README.sh.njk

This file was deleted.

9 changes: 4 additions & 5 deletions src/setup/anvil/templates/anvil-deploy-dependencies.sh.njk
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ cd {{ obj.contracts.repositoryDir }}

export PATH="$HOME/.foundry/bin:$PATH"

forge create --rpc-url http://localhost:$SERVER_PORT --private-key $ANVIL_ACC contracts/common/lib/Common.sol:Common --broadcast

forge create --rpc-url http://localhost:$SERVER_PORT --private-key $ANVIL_ACC contracts/common/lib/Common.sol:Common --broadcast

forge create --rpc-url http://localhost:$SERVER_PORT --private-key $ANVIL_ACC contracts/root/predicates/TransferWithSigUtils.sol:TransferWithSigUtils --broadcast
forge create --rpc-url http://localhost:$SERVER_PORT --private-key $ANVIL_ACC contracts/root/predicates/TransferWithSigUtils.sol:TransferWithSigUtils --broadcast

{% for acc in obj.config.accounts %}
cast send --rpc-url http://localhost:$SERVER_PORT --private-key $ANVIL_ACC {{ acc.address }} --value 10000ether
sleep 10
cast send --rpc-url http://localhost:$SERVER_PORT --private-key $ANVIL_ACC {{ acc.address }} --value 10000ether
sleep 10
{% endfor %}
2 changes: 0 additions & 2 deletions src/setup/anvil/templates/anvil-deployment-bor.sh.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export DIR={{ obj.contracts.repositoryDir }}
# cd matic contracts repo
cd {{ obj.contracts.repositoryDir }}


export PATH="$HOME/.foundry/bin:$PATH"

forge script --legacy scripts/deployment-scripts/childContractDeployment.s.sol:ChildContractDeploymentScript --rpc-url http://localhost:8545 --private-key $PRIVATE_KEY --broadcast

2 changes: 0 additions & 2 deletions src/setup/anvil/templates/anvil-deployment-sync.sh.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export SERVER_PORT={{ obj.serverPort }}
# cd matic contracts repo
cd {{ obj.contracts.repositoryDir }}


export PATH="$HOME/.foundry/bin:$PATH"


forge script --legacy scripts/deployment-scripts/syncChildStateToRoot.s.sol:SyncChildStateToRootScript --rpc-url http://localhost:$SERVER_PORT --private-key $PRIVATE_KEY --broadcast
5 changes: 2 additions & 3 deletions src/setup/anvil/templates/anvil-deployment.sh.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export SERVER_PORT={{ obj.serverPort }}
# cd matic contracts repo
cd {{ obj.contracts.repositoryDir }}

echo "DEPLOYER_PRIVATE_KEY=$PRIVATE_KEY" >> .env
echo "HEIMDALL_ID='$HEIMDALL_ID'" >> .env
echo "DEPLOYER_PRIVATE_KEY=$PRIVATE_KEY" >>.env
echo "HEIMDALL_ID='$HEIMDALL_ID'" >>.env

export PATH="$HOME/.foundry/bin:$PATH"

Expand All @@ -27,4 +27,3 @@ forge script scripts/deployment-scripts/deployContracts.s.sol:DeploymentScript -
forge script scripts/deployment-scripts/drainStakeManager.s.sol:DrainStakeManagerDeployment --rpc-url http://localhost:$SERVER_PORT --private-key $PRIVATE_KEY --broadcast

forge script scripts/deployment-scripts/initializeState.s.sol:InitializeStateScript --rpc-url http://localhost:$SERVER_PORT --private-key $PRIVATE_KEY --broadcast

3 changes: 1 addition & 2 deletions src/setup/anvil/templates/anvil-stake.sh.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ FEE={{ obj.config.defaultFee }}

export SERVER_PORT={{ obj.serverPort }}


# Navigate to the matic contracts directory
cd {{ obj.contracts.repositoryDir }}

# Loop over accounts and run the stake script for each
{% for acc in obj.config.accounts %}
forge script scripts/matic-cli-scripts/stake.s.sol:MaticStake --rpc-url http://localhost:$SERVER_PORT --private-key $PRIVATE_KEY --broadcast --sig "run(address,bytes,uint256,uint256)" {{ acc.address }} {{ acc.pub_key }} 10000000000000000000000 2000000000000000000000
forge script scripts/matic-cli-scripts/stake.s.sol:MaticStake --rpc-url http://localhost:$SERVER_PORT --private-key $PRIVATE_KEY --broadcast --sig "run(address,bytes,uint256,uint256)" {{ acc.address }} {{ acc.pub_key }} 10000000000000000000000 2000000000000000000000
sleep 10
{% endfor %}
1 change: 0 additions & 1 deletion src/setup/anvil/templates/anvil-start.sh.njk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ anvil \
--verbosity \
--mnemonic "$MNEMONIC" \
--block-time 1

8 changes: 4 additions & 4 deletions util-scripts/docker/devnet_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ bash docker-bor-start-all.sh || { echo "Failed to start Bor"; exit 1; }

sleep 2m

# Deploy Bor to Anvil
bash anvil-deployment-bor.sh || { echo "Failed to deploy Bor to Anvil"; exit 1; }
# Deploy contracts on Bor
bash anvil-deployment-bor.sh || { echo "Failed to deploy contracts on Bor"; exit 1; }

# Sync Anvil deployment
bash anvil-deployment-sync.sh || { echo "Failed to sync Anvil deployment"; exit 1; }
# Sync Bor contracts deployment
bash anvil-deployment-sync.sh || { echo "Failed to sync Bor contracts deployment"; exit 1; }

echo "Devnet setup complete."
2 changes: 1 addition & 1 deletion util-scripts/docker/fund_anvil_accounts.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

host='localhost'
host="localhost"

echo "Transferring 10 ETH from anvil account[0] to all others..."

Expand Down
19 changes: 0 additions & 19 deletions util-scripts/docker/fund_ganache_accounts.sh

This file was deleted.

Loading
Loading