Skip to content

Commit

Permalink
Merge branch 'develop' into special-allocation-order
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Johnson authored May 31, 2022
2 parents 23c1561 + 0cb81a6 commit 4465ab4
Show file tree
Hide file tree
Showing 120 changed files with 2,636 additions and 144 deletions.
16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ release/
.DS_Store

# Localnet
localnet/node?/data/*.db
localnet/node?/data/snapshots
localnet/node?/data/cs.wal
localnet/node?/config/genesis.json
localnet/node?/config/addrbook.json
localnet/node?/config/write-file-atomic-*
localnet/*/node?/data/*.db
localnet/*/node?/data/snapshots
localnet/*/node?/data/cs.wal
localnet/*/node?/config/genesis.json
localnet/*/node?/config/addrbook.json
localnet/*/node?/config/write-file-atomic-*
localnet/__pycache__/
localnet/spncs.yaml
localnet/cs.yaml
localnet/vs.yaml

# Generate report files
*.out
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ require (
github.com/tendermint/fundraising v0.3.0
github.com/tendermint/tendermint v0.34.19
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.27.1
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down Expand Up @@ -79,6 +79,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gookit/color v1.5.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -2222,8 +2223,8 @@ google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ6
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e h1:fNKDNuUyC4WH+inqDMpfXDdfvwfYILbsX+oskGZ8hxg=
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E=
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I=
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
Expand All @@ -2240,8 +2241,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
13 changes: 13 additions & 0 deletions localnet/auctions/auction_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"start_price": "",
"min_bid_price": "",
"selling_coin": {
"denom": "",
"amount": ""
},
"paying_coin_denom": "",
"start_time": "",
"end_time": "",
"max_extended_round": 0,
"extended_round_rate": "0.05"
}
12 changes: 12 additions & 0 deletions localnet/auctions/sale_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"start_price": "",
"min_bid_price": "",
"selling_coin": {
"denom": "",
"amount": ""
},
"paying_coin_denom": "",
"vesting_schedules": [],
"start_time": "",
"end_time": ""
}
28 changes: 12 additions & 16 deletions localnet/clear.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import os
import pathlib

if pathlib.PurePath(os.getcwd()).name != 'localnet':
print('script must be run from localnet folder')
exit(1)
def clear_home(home):
if pathlib.PurePath(os.getcwd()).name != 'localnet':
print('script must be run from localnet folder')
exit(1)

os.system("rm ./node1/config/write-file-atomic-*")
os.system("rm ./node2/config/write-file-atomic-*")
os.system("rm ./node3/config/write-file-atomic-*")
for i in [1,2,3]:
os.system('rm {}/node{}/config/write-file-atomic-*'.format(home, i))
os.system('rm {}/node{}/config/genesis.json'.format(home, i))
os.system("rm {}/node{}/config/addrbook.json".format(home, i))
os.system('spnd tendermint unsafe-reset-all --home {}/node{}'.format(home, i))

os.system("rm ./node1/config/genesis.json")
os.system("rm ./node2/config/genesis.json")
os.system("rm ./node3/config/genesis.json")
os.system("rm ./node1/config/addrbook.json")
os.system("rm ./node2/config/addrbook.json")
os.system("rm ./node3/config/addrbook.json")

os.system('spnd tendermint unsafe-reset-all --home ./node1')
os.system('spnd tendermint unsafe-reset-all --home ./node2')
os.system('spnd tendermint unsafe-reset-all --home ./node3')
if __name__ == "__main__":
clear_home('spn')
clear_home('testnet')
2 changes: 1 addition & 1 deletion localnet/conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ staking_denom: "uspn"

# Unbonding time in seconds, low value allows to experiment validator set changes
# Default: 21 days = 1814400 seconds
unbonding_time: 1000
unbonding_time: 1814400

# List of validator names used for delegate and undelegate scripts
validator_names:
Expand Down
46 changes: 24 additions & 22 deletions localnet/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@ def delegate_cmd(valNumber, amount):

return cmd

# Perform delegation
for s in sys.argv[1:]:
if not s.isnumeric():
print(s + ' must be a number')
exit(1)

i = 0
for s in sys.argv[1:]:
if int(s) > 0:
print(i)
cmd = delegate_cmd(i, s)
print('running: ' + " ".join(cmd))
subprocess.run(cmd, check=True)
i += 1

print()
print()
print('delegation performed, to show validator set:')
print('spnd q tendermint-validator-set')
print()
print('to show consensus state')
print('spnd q ibc client self-consensus-state')
def delegate(amounts):
for s in amounts:
if not s.isnumeric():
print(s + ' must be a number')
exit(1)

i = 0
for s in amounts:
if int(s) > 0:
print(i)
cmd = delegate_cmd(i, s)
print('running: ' + " ".join(cmd))
subprocess.run(cmd, check=True)
i += 1

if __name__ == "__main__":
delegate(sys.argv[1:])

print()
print('delegation performed, to show validator set:')
print('spnd q tendermint-validator-set')
print()
print('to show consensus state')
print('spnd q ibc client self-consensus-state')
72 changes: 72 additions & 0 deletions localnet/hermes/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[global]
log_level = 'info'

[mode]
[mode.clients]
enabled = true
refresh = true
misbehaviour = false

[mode.connections]
enabled = false

[mode.channels]
enabled = false

[mode.packets]
enabled = true
clear_interval = 100
clear_on_start = true
tx_confirmation = true

[rest]
enabled = false
host = '127.0.0.1'
port = 3000

[telemetry]
enabled = false
host = '127.0.0.1'
port = 3001

[[chains]]
id = 'spn-1'
rpc_addr = 'http://0.0.0.0:26657'
grpc_addr = 'http://0.0.0.0:9090'
websocket_addr = 'ws://0.0.0.0:26657/websocket'
rpc_timeout = '10s'
account_prefix = 'spn'
key_name = 'steve'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 400000
gas_price = { price = 0.025, denom = 'uspn' }
gas_adjustment = 0.1
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }

[[chains]]
id = 'orbit-1'
rpc_addr = 'http://localhost:26659'
grpc_addr = 'http://localhost:9092'
websocket_addr = 'ws://localhost:26659/websocket'
rpc_timeout = '10s'
account_prefix = 'spn'
key_name = 'joe'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 400000
gas_price = { price = 0.025, denom = 'uspn' }
gas_adjustment = 0.1
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }
58 changes: 58 additions & 0 deletions localnet/initialize_rewards.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import argparse
from utils import cmd_devnull

parser = argparse.ArgumentParser(description='Initialize the rewards on SPN for the testnet')
parser.add_argument('--last_block_height',
type=int,
default=100,
help='Last block for the reward pool',
)
parser.add_argument('--self_delegation_1',
default='10000000uspn',
help='Self delegation for validator 1',
)
parser.add_argument('--self_delegation_2',
default='10000000uspn',
help='Self delegation for validator 2',
)
parser.add_argument('--self_delegation_3',
default='10000000uspn',
help='Self delegation for validator 3',
)

def initialize_rewards(lastBlockHeight, selfDelegationVal1, selfDelegationVal2, selfDelegationVal3):
cmd_devnull('spnd tx profile create-coordinator --from alice -y')
cmd_devnull('spnd tx launch create-chain orbit-1 orbit.com 0xaaa --from alice -y')
cmd_devnull('spnd tx campaign create-campaign orbit 1000000orbit --from alice -y')
cmd_devnull('spnd tx campaign mint-vouchers 1 50000orbit --from alice -y')
cmd_devnull('spnd tx reward set-rewards 1 50000v/1/orbit {} --from alice -y'.format(lastBlockHeight))

gentx1 = './testnet/node1/config/gentx/gentx.json'
gentx2 = './testnet/node2/config/gentx/gentx.json'
gentx3 = './testnet/node3/config/gentx/gentx.json'
pub1 = '"Q5D7koejne/P2F1iIcSSVo6M4siL5anwHH7iopX66ps="'
pub2 = '"JzzB4Kr09x3k1MdatVL7MBMrZUn0D3Lx9AK+nHWjbq0="'
pub3 = '"4TwlBGJhu4ZDRBDK57GiFyAFafDAapa6nVQ0VvG5rjA="'
val1 = 'spn1aqn8ynvr3jmq67879qulzrwhchq5dtrvtx0nhe'
val2 = 'spn1pkdk6m2nh77nlaep84cylmkhjder3arey7rll5'
val3 = 'spn1twckcceyw43da9j247pfs3yhqsv25j38grh68q'

cmd_devnull('spnd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx1, pub1, selfDelegationVal1, val1)),
cmd_devnull('spnd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx2, pub2, selfDelegationVal2, val2)),
cmd_devnull('spnd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx3, pub3, selfDelegationVal3, val3)),

# Uncomment for testing incomplete validator set
# cmd_devnull('spnd tx launch request-add-validator 1 ./node3/config/gentx/gentx.json "FyTmyvZhwRjwqhY6eWykTfiE+0mwe+U0aSo3ti8DCW8=" 16000000stake aaa foo.com --validator-address spn1ezptsm3npn54qx9vvpah4nymre59ykr9exx2ul --from alice -y')

cmd_devnull('spnd tx launch trigger-launch 1 5 --from alice -y')


if __name__ == "__main__":
# Parse params
args = parser.parse_args()
lastBlockHeight = args.last_block_height
selfDelegationVal1 = args.self_delegation_1
selfDelegationVal2 = args.self_delegation_2
selfDelegationVal3 = args.self_delegation_3

rewards(lastBlockHeight, selfDelegationVal1, selfDelegationVal2, selfDelegationVal3)
12 changes: 9 additions & 3 deletions localnet/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ starport chain build
The localnet can be started from the following script:
(must be run in `localnet` directory)
```
python3 start.py
python3 start_spn.py
```

The logs of the Node 1 are printed in the console.
Expand All @@ -58,7 +58,7 @@ When `0` is provided for a validator, the delegation is not updated

Run the localnet in a terminal
```
python3 start.py
python3 start_spn.py
```

Show the validator set
Expand Down Expand Up @@ -147,4 +147,10 @@ validators:
type: tendermint/PubKeyEd25519
value: SIbr/rY/55BiXE6NBay7PmzBw25ADIrVtfVRqsqQBZM=
voting_power: "10"
```
```

### Other scripts

- `run_incentivized.py`: start a testnet and connect it to SPN with the IBC monitoring module
- `run_sale.py`: run a fixed-price auction
- `run_auction.py` run a batch auction
Loading

0 comments on commit 4465ab4

Please sign in to comment.