Skip to content

Commit

Permalink
Provide script to help with settings upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Mar 11, 2024
1 parent 22b53eb commit e1a86bf
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/software/soroban-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ proposed upgrade.**
1. `curl -G 'http://localhost:11626/upgrades?mode=set&upgradetime=YYYY-MM-DDTHH:MM:SSZ' --data-urlencode 'configupgradesetkey=<LINE_7_OUTPUT>'`
6. Update https://github.com/stellar-expert/staged-soroban-upgrades so https://stellar.expert/explorer/pubnet/protocol-history will show the proposed upgrade.

### Helper script
A script to help with crafting the transactions above is available [here](../../scripts/settings-helper.sh) with usage details in [README.md](../../scripts/README.md), but it's important to be aware of how the underlying process works in case the script has some issues.

### Debugging
If any of the transactions above fail during transaction submission, you should get a `TransactionResult` as a response with the reason.

Expand Down
10 changes: 10 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This folder is for storing any scripts that may be helpful for using stellar-cor
## List of scripts
- [Overlay survey](#overlay-survey)
- [Diff Tracy CSV](#diff-tracy-csv)
- [Parse Backtrace Dump](#parse-backtrace-dump)

### Overlay survey
- Name - `OverlaySurvey.py`
Expand Down Expand Up @@ -54,5 +55,14 @@ This folder is for storing any scripts that may be helpful for using stellar-cor
./src/stellar-core(+0x34f0c1) [0x55c7cd1000c1]"
```

### Soroban Settings Helper
- Name - `settings-helper.sh`
- Prequisites - `stellar-xdr` and `stellar-core`
- Description - This is a script to help with the [Soroban Settings Upgrade](../docs/software/soroban-settings.md). It's important to be aware of how the underlying process works
in case the script has some issues, so please read through that doc before attempting to use this script. This script should be run from the directory that contains your stellar-core binary. This script also queries the SDF Horizon for the sequence number of the account, so if the SDF Horizon instance is unavailable, then you'll need to provide the account's sequence number manually.
- Usage - Ex. `sh ../scripts/settings-helper.sh SCSQHJIUGUGTH2P4K6AOFTEW4HUMI2BRTUBBDDXMQ4FLHXCX25W3PGBJ 'Test SDF Network ; September 2015' ../soroban-settings/testnet_settings_phase2.json`. The first argument is the secret key of the source account that will be used for the transactions to set up the upgrade, the second argument is the the network passphrase, and the third is
the path to the JSON file with the proposed settings.


## Style guide
We follow [PEP-0008](https://www.python.org/dev/peps/pep-0008/).
50 changes: 50 additions & 0 deletions scripts/settings-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
set -e

SECRET_KEY="$1"
PUBLIC_KEY=$(./stellar-core convert-id "$SECRET_KEY" | sed -n '4p' | awk '{print $NF}')
echo "PUBLIC_KEY is $PUBLIC_KEY"

PUBNET_HORIZON="https://horizon.stellar.org/accounts"
PUBNET_PASSPHRASE="Public Global Stellar Network ; September 2015"

TESTNET_HORIZON="https://horizon-testnet.stellar.org/accounts"
TESTNET_PASSPHRASE="Test SDF Network ; September 2015"

HORIZON=""

#choose which horizon to hit for the SEQ_NUM. If Horizon is down, remove this code and manually set SEQ_NUM below
if [ "$2" == "$PUBNET_PASSPHRASE" ]
then
HORIZON=$PUBNET_HORIZON
elif [ "$2" == "$TESTNET_PASSPHRASE" ]
then
HORIZON=$TESTNET_HORIZON
else
echo "invalid passphrase"
fi

# get seq num
SEQ_NUM="$(curl -s "$HORIZON/$PUBLIC_KEY" | grep "\"sequence\":" | sed 's/[^0-9]//g')"
re='^[0-9]+$'
if ! [[ $SEQ_NUM =~ $re ]] ; then
echo "Error: SEQ_NUM not retrieved. Your account might not be funded, or Horizon might be down. Hardcode the SEQ_NUM below and remove the horizon code." >&2; exit 1
fi

OUTPUT="$(echo $SECRET_KEY | ./stellar-core get-settings-upgrade-txs "$PUBLIC_KEY" "$SEQ_NUM" "$2" --xdr $(stellar-xdr encode --type ConfigUpgradeSet $3) --signtxs)"

echo "----- TX #1 -----"
echo "curl -G 'http://localhost:11626/tx' --data-urlencode 'blob=$(echo "$OUTPUT" | sed -n '1p')'"

echo "----- TX #2 -----"
echo "curl -G 'http://localhost:11626/tx' --data-urlencode 'blob=$(echo "$OUTPUT" | sed -n '3p')'"

echo "----- TX #3 -----"
echo "curl -G 'http://localhost:11626/tx' --data-urlencode 'blob=$(echo "$OUTPUT" | sed -n '5p')'"
echo "-----"

echo "curl -G 'http://localhost:11626/dumpproposedsettings' --data-urlencode 'blob=$(echo "$OUTPUT" | sed -n '7p')'"
echo "-----"

echo "distribute the following command with the upgradetime set to an agreed upon point in the future"
echo "curl -G 'http://localhost:11626/upgrades?mode=set&upgradetime=YYYY-MM-DDT01:25:00Z' --data-urlencode 'configupgradesetkey=$(echo "$OUTPUT" | sed -n '7p')'"

5 comments on commit e1a86bf

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from dmkozh
at sisuresh@e1a86bf

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sisuresh/stellar-core/settings = e1a86bf into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sisuresh/stellar-core/settings = e1a86bf merged ok, testing candidate = 4c0c913

@latobarita
Copy link
Contributor

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4c0c913

Please sign in to comment.