-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #857 from ouwenkg/upgrade-scripts
Upgrade script
- Loading branch information
Showing
5 changed files
with
102 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Amend the code of [System contract](0xffffffffffffffffffffffffffffffffff020000). | ||
""" | ||
|
||
import argparse | ||
import json | ||
from utils import rpc_request, get_receipt, amend_code, send_tx | ||
|
||
SYS_CONF = '0xffffffffffffffffffffffffffffffffff020000' | ||
|
||
def parse_arguments(): | ||
""" parse the arguments: privkey, url """ | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'--privkey', required=True, help='The admin private key.') | ||
parser.add_argument('--url', required=True, help='The url of the chain.') | ||
|
||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def main(): | ||
""" Load the genesis file and amend """ | ||
args = parse_arguments() | ||
|
||
with open('../../genesis.json', 'r') as gene: | ||
genesis = json.load(gene) | ||
|
||
alloc = genesis['alloc'] | ||
for addr in alloc: | ||
# amend code | ||
args.value = 2 | ||
if addr == SYS_CONF: | ||
amend_code(addr, alloc[addr]['code'], args) | ||
print(f'amend code successfully') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
# This is a updrade helper for CITA from version 1.0.0 to version 1.1.0. | ||
# | ||
# 1. why this bash needed? | ||
# | ||
# In cita 1.1.0, a interface named `setBlockInterval` was added in system contract. | ||
# So, if you were using cita version 1.1 below and wanted to upgrade to version 1.1, this file is prepared for you. | ||
# | ||
# II. How to use this bash? | ||
# | ||
# 1. Download the cita version 1.1 release package from https://github.com/cryptape/cita/releases | ||
# 2. Extract the package and copy directory bin/ and scripts/ to corresponding dir under your nodes. | ||
# 3. Next, upgrade your node use this helper. Tap the command below, remember to update the admin privkey | ||
# and node url params. | ||
|
||
# ./scripts/upgrade/v1.0-to-v1.1.sh \ | ||
# 0x5f0258a4778057a8a7d97809bd209055b2fbafa654ce7d31ec7191066b9225e6 \ | ||
# http://127.0.0.1:1337 \ | ||
set -e | ||
|
||
if [[ $(uname) == 'Darwin' ]] | ||
then | ||
SOURCE_DIR=$(realpath "$(dirname "$0")"/..) | ||
else | ||
SOURCE_DIR=$(readlink -f "$(dirname "$0")"/..) | ||
fi | ||
|
||
if [ "$1" = "help" ]; then | ||
echo "Admin private key, url as the params. | ||
For example: \\ | ||
bin/cita scripts/upgrade/v1.0-to-v1.1.sh \\ | ||
0x5f0258a4778057a8a7d97809bd209055b2fbafa654ce7d31ec7191066b9225e6 \\ | ||
http://127.0.0.1:1337" | ||
exit 0 | ||
fi | ||
|
||
echo "==> Prepare environment" | ||
rm -rf tmp/ | ||
rm -f "${SOURCE_DIR}"/genesis.json | ||
|
||
echo "==> Create temp chain and get new genesis.json" | ||
python3 scripts/create_cita_config.py create \ | ||
--chain_name tmp \ | ||
--super_admin "0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523" \ | ||
--nodes "127.0.0.1:4000" | ||
|
||
cp tmp/0/genesis.json scripts/ | ||
|
||
echo "==> Send tx to amend code" | ||
cd ./scripts/txtool/txtool | ||
python3 "${SOURCE_DIR}"/upgrade/v1.0-to-v1.1.py --privkey "$1" --url "$2" | ||
cd - | ||
|
||
echo "==> Clean temp data" | ||
rm -rf tmp/ | ||
rm -f "${SOURCE_DIR}"/genesis.json |