Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

lidofinance/terra-multisig-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terra Multisig Process Testnet

Installing Terra software from prebuilt binaries

There is no support of ledger devices in these prebuilt binaries. So if you want to use ledger, build binaries from sources (instructions below)

Step 1. Download binaries

Download an archive with binaries for your platform from the official Terra repository

Step 2. Install binaries

Open a folder with the downloaded archive in a terminal and execute one the following command (depends on your platform):

MacOS installation:
foo@bar:~$ tar -C /usr/local/bin -xzf terra_0.5.7_Darwin_x86_64.tar.gz && mv /usr/local/bin/libwasmvm.dylib /usr/local/lib/
Linux installation:
foo@bar:~$ tar -C /usr/local/bin -xzf terra_0.5.7_Linux_x86_64.tar.gz

Step 4: Verify your installation

Verify that everything is OK. If you get something like the following, you've successfully installed Terra Core on your system.

foo@bar:~$ terrad version --long
name: terra
server_name: terrad
version: 0.5.7
commit: 1581f2f7117b51363f0aca8127fcea8325cee928
build_tags: netgo,ledger
go: go version go1.17.1 darwin/amd64

Building Terra software from source (skip this, if you've installed prebuilt binaries)

Step 1. Install Golang

Go v1.13.1 or higher is required for Terra Core.

If you haven't already, install Golang by following the official docs. Make sure that your GOPATH and GOBIN environment variables are properly set up.

Step 2: Get Terra Core source code

Use git to retrieve Terra Core from the official repo, and checkout the main branch, which contains the latest stable release. That should install the terrad binary.

foo@bar:~$ git clone https://github.com/terra-project/core
foo@bar:~$ cd core
foo@bar:~$ git checkout main

Step 3: Build from source

You can now build Terra Core. Running the following command will install executables terrad to your GOPATH.

foo@bar:~$ make install

Step 4: Verify your installation

Verify that everything is OK. If you get something like the following, you've successfully installed Terra Core on your system.

foo@bar:~$ terrad version --long
name: terra
server_name: terrad
version: 0.5.7
commit: 1581f2f7117b51363f0aca8127fcea8325cee928
build_tags: netgo,ledger
go: go version go1.17.1 darwin/amd64

Multisig Helper

Disclaimer

At the first launch, you will be redirected to the authorization page for the Github App with permission to grant access to the account. It looks scary, but no one but you will have access to your private repositories and personal data. The helper script needs to get an Oauth token so that you can automatically create commits, pull requests and other stuff in our private repository (lido-multisigs/terra-testnet-multisigs). The token is stored only on your device (.token file in the root of repository) and is not sent anywhere. You can revoke access at any time here: https://github.com/settings/apps/authorizations

In a multisig process participants must sign transcations, share their individual signatures with other participants, someone must collect them, create final mutlisig transaction and broadcast it. In addition, participants should fill in Google Sheets spreadsheet to store an info about transactions. This process is a boring and tedious so we've developed a script called multsig_helper.py.

The script simplifies a process of signing, sharing signatures and updating a spreadsheet.

Requirements

Install the script

foo@bar:~$ git clone git@github.com:lidofinance/terra-multisig-helper.git

foo@bar:~$ cd terra-multisig-helper

foo@bar:~$ pip3 install virtualenv

foo@bar:~$ virtualenv venv

foo@bar:~$ source venv/bin/activate

foo@bar:~$ pip3 install -r requirements.txt

Configuration file

Configuration of the script is located in config.json file:

{
    "repo_name": "lidofinance/terra-multisig-testnet", // Name of the repository where signatures and transations will be located
    "app_client_id": "XXXXXXXXX", // Client ID of Github App
    "spreadsheet_id": "XXXXXXXX" // ID of a spreadsheet contained tx and participants info
}

You don't have to fill the file manually, a correct one will be shared in the private TG group.

But just in case:

Google API token

A pre-generated Google API token (with editor rights to the testnet spreadsheet only) will be shared in the private TG group.

But just in case there is an instruction on how to generate the service token manually.

Networks

Chain ID Description RPC Node
columbus-5 Columbus-5 Mainnet http://public-node.terra.dev:26657
bombay-12 Bombay-12 Testnet tcp://3.34.120.243:26657

Usage

To see all possible commands of the script, run:

foo@bar:~$ ./multisig-helper.py --help

Usage: multisig-helper.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  generate-key               Generates personal Terra key, saves it to your...
  generate-multisig-account  Imports public keys of another participants...
  issue-tx                   If enough signatures, creates a multisig...
  list-unsigned              Lists unsigned transactions (unmerged pull...
  new-tx                     Creates a new folder with unsigned_tx, makes a...
  share-pubkey               Updates the spreadsheet with the existed key
  sign                       Signs tx and makes a commit to an
                             corresponding...

  update-tx                  Updates a tx file in PR

To see more info about particular command, just specify --help flag when executing a command.

Generate keys
Sharing existing pubkey

If you have keys from the previous multisig run, or you already have generated keys in Ledger, execute share-pubkey command:

foo@bar:~$ ./multisig-helper.py share-pubkey --name your_key_name

Updating Google Sheets...
Done
  • your_key_name is the name of your key account. You will use this name to identify your account when you want to sign a transaction. The helper script uses your Github username by default, but you can change it by specifying --name flag in the command.*
Generate keys from scratch

You'll need an account private and public key pair (a.k.a. sk, pk respectively) to be able to be a part of a multisig account.

To generate an account, just use the following command:

foo@bar:~$ ./multisig-helper.py generate-key

name: yourKeyName
address: terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v
pubkey: terrapub1addwnpepqgcxazmq6wgt2j4rdfumsfwla0zfk8e5sws3p3zg5dkm9007hmfysxas0u2

**Important** write this mnemonic phrase in a safe place.
            It is the only way to recover your account if you ever forget your password.

Mnemonic: notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius

Updating Google Sheets...
Done
  • yourKeyName is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to sign a transaction. The helper script uses your Github username by default, but you can change it by specifying --name flag in the command. The command will generate a 24-words mnemonic and save the private and public keys for account 0 at the same time. You can always recover the private key with the mnemonic. Additionally, the command will update the spreadsheet in Google Sheets by adding your public key to i
Create the multisig key

To create a multisig account you need to import public keys of every participant of the process and after that generate a multisig account and save it to your local keybase.

That's a lot of commands, but with the helper script you can execute just one:

foo@bar:~$ ./multisig-helper.py generate-multisig-account

Adding key from test3...
Done
Adding key from test1...
Done

Generating multisig account
multisig account name: test1_test3_multisig
multisig address: terra_some_address
multisig pubkey: terrapub_some_public_key

Updating Google Sheets...
Done

The command will import public keys of another participants from the spreadsheet, generate a multisig account and update the spreadsheet with generated address of the multisig account

Example

Let's see usage of the script on a little example where we want to send 5 Lunas from a multisig account (terra1e0fx0q9meawrcq7fmma9x60gk35lpr4xk3884m in our case) to terra17htaxslph9mvyunj4clgw9mcrglqjej4l6pcxg

1) Create the multisig transaction
foo@bar:~$ terrad tx bank send \
    terra1e0fx0q9meawrcq7fmma9x60gk35lpr4xk3884m \
    terra17htaxslph9mvyunj4clgw9mcrglqjej4l6pcxg \
    5000000uluna \
    --gas=200000 \
    --fees=100000uluna \
    --chain-id=bombay-12 \
    --generate-only > unsignedTx.json

The command will generate an unsigned transaction and save it to unsignedTx.json

2) Share the unsigned tx with other participants
foo@bar:~$ ./multisig-helper.py new-tx "send_money_to_trofim" unsignedTx.json --description "description of your tx, optional"
  • "send_money_to_trofim" - just a little title of the transaction (without spaces!).
  • unsignedTx.json - a path to an unsigned tx file from previous step
  • --description - optional flag to provide an additional info about the transaction

If your output looks like that, everything is all right:

PR #1 for tx send_money_to_trofim created
See on Github: https://github.com/lidofinance/terra-multisig-testnet/pull/1
Updating Google Sheets...
Done
3) See list of unsigned transactions
foo@bar:~$ ./multisig-helper.py list-unsigned

You'll see something like:

TX ID #1 - send_money_to_trofim

Where the most important part is TX ID. This id is required for the next steps.

4) Sign a transaction
foo@bar:~$ ./multisig-helper.py sign TX_ID --chain-id="bombay-12" --node="tcp://3.34.120.243:26657"
  • TX_ID is a number from the previous step

In this case command looks like:

foo@bar:~$ ./multisig-helper.py sign 1 --chain-id="bombay-12" --node="tcp://3.34.120.243:26657"
Transaction send_money_to_trofim successfully signed by test1
See signature on github: https://github.com/lidofinance/terra-multisig-testnet/blob/send_money_to_trofim_2021-04-28/send_money_to_trofim_2021-04-28/test1_sign.json
Updating Google Sheets...
Done

After the command execution you can run list-unsigned again:

foo@bar:~$ ./multisig-helper.py list-unsigned

SigID #1 - send_money_to_trofim
	 Signed by: test1

And you'll see that tx is signed by test1.

5) Issue tx

When a sufficient number of participants have signed a transaction, anyone can issue it:

foo@bar:~$ ./multisig-helper.py issue-tx TX_ID --chain-id="bombay-12" --node="tcp://3.34.120.243:26657"

The command will create a multisig transaction, merge a corresponding PR in the repository and update the spreadsheet. But if you specify --broadcast flag, the command will broadcast the transaction right into blockchain.

In our case the command looks like:

foo@bar:~$ ./multisig-helper.py issue-tx TX_ID --chain-id="bombay-12" --node="tcp://3.34.120.243:26657"

PR #1 has merged successfully
Updating Google Sheets...
Broadcasting tx..
Updating Google Sheets...
Done

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages