Skip to content
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
8 changes: 8 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ jobs:
"python3 integration_test/scripts/runner.py integration_test/upgrade_module/minor_upgrade_test.yaml"
]
},
{
name: "SeiDB State Store",
scripts: [
"docker exec sei-node-0 integration_test/contracts/deploy_wasm_contracts.sh",
"docker exec sei-node-0 integration_test/contracts/create_tokenfactory_denoms.sh",
"python3 integration_test/scripts/runner.py integration_test/seidb/state_store_test.yaml",
]
},
]
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ replace (
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.26
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.27
// Latest goleveldb is broken, we have to stick to this version
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.2.37
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,8 @@ github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQp
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.2.72 h1:pv1J3fBIpVJwYqTV3unRSJ0/krEGDN5bByZLCkPOIG4=
github.com/sei-protocol/sei-cosmos v0.2.72/go.mod h1:CykNPmj90YkwBorkvnc05u9k9MBNDHC3h4CIdmq3R98=
github.com/sei-protocol/sei-db v0.0.26 h1:/jC5AZ1aq9+SpYx+VL9HJfLFoW7/KrGN//QyWVqRsqs=
github.com/sei-protocol/sei-db v0.0.26/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI=
github.com/sei-protocol/sei-db v0.0.27 h1:IdmzGavY5yP6T2sAM+wLOISTPd+AXp0S5aLmzpozC7c=
github.com/sei-protocol/sei-db v0.0.27/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI=
github.com/sei-protocol/sei-iavl v0.1.9 h1:y4mVYftxLNRs6533zl7N0/Ch+CzRQc04JDfHolIxgBE=
github.com/sei-protocol/sei-iavl v0.1.9/go.mod h1:7PfkEVT5dcoQE+s/9KWdoXJ8VVVP1QpYYPLdxlkSXFk=
github.com/sei-protocol/sei-ibc-go/v3 v3.3.0 h1:/mjpTuCSEVDJ51nUDSHU92N0bRSwt49r1rmdC/lqgp8=
Expand Down
28 changes: 27 additions & 1 deletion integration_test/bank_module/send_funds_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,38 @@
env: ADMIN_ACC
- cmd: seid keys show -a bank-test --keyring-backend test
env: BANK_TEST_ACC
- cmd: seid q block | jq -r ".block.header.height"
env: BEGINNING_BLOCK_HEIGHT
- cmd: seid q bank balances $ADMIN_ACC --denom usei --output json | jq -r .amount
env: BEGINNING_ADMIN_BALANCE
# Send funds
- cmd: printf "12345678\n" | seid tx bank send $ADMIN_ACC $BANK_TEST_ACC 1sei -b block --fees 2000usei --chain-id sei -y
# Validate
- cmd: seid q bank balances $BANK_TEST_ACC --output json | jq -r .balances[0].amount
- cmd: seid q bank balances $BANK_TEST_ACC --denom usei --output json | jq -r .amount
env: BANK_TEST_BAL
# Get current height
- cmd: seid q block | jq -r ".block.header.height"
env: FIRST_BLOCK_HEIGHT
# Sleep 20s to let chain progress
- cmd: sleep 20
# Send more funds
- cmd: printf "12345678\n" | seid tx bank send $ADMIN_ACC $BANK_TEST_ACC 1sei -b block --fees 2000usei --chain-id sei -y
# Verify historical balance correct
- cmd: seid q bank balances $BANK_TEST_ACC --denom usei --height $FIRST_BLOCK_HEIGHT --output json | jq -r .amount
env: FIRST_BANK_TEST_BAL
# Validate
- cmd: seid q bank balances $BANK_TEST_ACC --denom usei --output json | jq -r .amount
env: SECOND_BANK_TEST_BAL
# Validate original admin balance historical query
- cmd: seid q bank balances $ADMIN_ACC --height $BEGINNING_BLOCK_HEIGHT --denom usei --output json | jq -r .amount
env: HISTORICAL_ADMIN_BANK_TEST_BAL
verifiers:
# Bank balance should be 1sei
- type: eval
expr: BANK_TEST_BAL == 1000000
- type: eval
expr: FIRST_BANK_TEST_BAL == 1000000
- type: eval
expr: SECOND_BANK_TEST_BAL == 2000000
- type: eval
expr: BEGINNING_ADMIN_BALANCE == HISTORICAL_ADMIN_BANK_TEST_BAL
60 changes: 60 additions & 0 deletions integration_test/contracts/create_tokenfactory_denoms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

seidbin=$(which ~/go/bin/seid | tr -d '"')
keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"')
keyaddress=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].address" | tr -d '"')
chainid=$($seidbin status | jq ".NodeInfo.network" | tr -d '"')
seihome=$(git rev-parse --show-toplevel | tr -d '"')

cd $seihome || exit
echo "Deploying first set of tokenfactory denoms..."

beginning_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$beginning_block_height" > $seihome/integration_test/contracts/tfk_beginning_block_height.txt
echo "$keyaddress" > $seihome/integration_test/contracts/tfk_creator_id.txt

# create first set of tokenfactory denoms
for i in {1..100}
do
echo "Creating first set of tokenfactory denoms #$i..."
create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=block --output=json)
new_token_denom=$(echo "$create_denom_result" | jq -r '.logs[].events[].attributes[] | select(.key == "new_token_denom").value')
echo "Got token $new_token_denom for iteration $i"
done


first_set_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$first_set_block_height" > $seihome/integration_test/contracts/tfk_first_set_block_height.txt

sleep 5

# create second set of tokenfactory denoms
for i in {101..200}
do
echo "Creating first set of tokenfactory denoms #$i..."
create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=block --output=json)
new_token_denom=$(echo "$create_denom_result" | jq -r '.logs[].events[].attributes[] | select(.key == "new_token_denom").value')
echo "Got token $new_token_denom for iteration $i"
done

second_set_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$second_set_block_height" > $seihome/integration_test/contracts/tfk_second_set_block_height.txt

sleep 5

# create third set of tokenfactory denoms
for i in {201..300}
do
echo "Creating first set of tokenfactory denoms #$i..."
create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=block --output=json)
new_token_denom=$(echo "$create_denom_result" | jq -r '.logs[].events[].attributes[] | select(.key == "new_token_denom").value')
echo "Got token $new_token_denom for iteration $i"
done

third_set_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$third_set_block_height" > $seihome/integration_test/contracts/tfk_third_set_block_height.txt

num_denoms=$(seid q tokenfactory denoms-from-creator $CREATOR_ID --output json | jq -r ".denoms | length")
echo $num_denoms

exit 0
2 changes: 1 addition & 1 deletion integration_test/contracts/deploy_dex_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration
rm -rf integration_test/contracts/"$contract_name"-pair.json


sleep 10s
sleep 10

echo "Deployed contracts:"
echo "$contract_addr"
Expand Down
62 changes: 62 additions & 0 deletions integration_test/contracts/deploy_wasm_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

seidbin=$(which ~/go/bin/seid | tr -d '"')
keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"')
keyaddress=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].address" | tr -d '"')
chainid=$($seidbin status | jq ".NodeInfo.network" | tr -d '"')
seihome=$(git rev-parse --show-toplevel | tr -d '"')

cd $seihome || exit
echo "Deploying first set of contracts..."

beginning_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$beginning_block_height" > $seihome/integration_test/contracts/wasm_beginning_block_height.txt
echo "$keyaddress" > $seihome/integration_test/contracts/wasm_creator_id.txt

# store first set of contracts
for i in {1..100}
do
echo "Storing first set contract #$i..."
store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/mars.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json)
contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value')
printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json
echo "Got contract id $contract_id for iteration $i"
done

first_set_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$first_set_block_height" > $seihome/integration_test/contracts/wasm_first_set_block_height.txt

sleep 5

# store second set of contracts
for i in {101..200}
do
echo "Storing second set contract #$i..."
store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/saturn.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json)
contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value')
printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json
echo "Got contract id $contract_id for iteration $i"
done

second_set_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$second_set_block_height" > $seihome/integration_test/contracts/wasm_second_set_block_height.txt

sleep 5

# store third set of contracts
for i in {201..300}
do
echo "Storing third set contract #$i..."
store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/venus.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json)
contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value')
printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json
echo "Got contract id $contract_id for iteration $i"
done

third_set_block_height=$($seidbin status | jq -r '.SyncInfo.latest_block_height')
echo "$third_set_block_height" > $seihome/integration_test/contracts/wasm_third_set_block_height.txt

num_stored=$(seid q wasm list-code --count-total --limit 400 --output json | jq -r ".code_infos | length")
echo $num_stored

exit 0
130 changes: 130 additions & 0 deletions integration_test/seidb/state_store_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
- name: Test state store iteration through wasm list code
inputs:
# Verify 300 stored wasm contracts
- cmd: seid q wasm list-code --count-total --limit 400 --output json | jq -r ".code_infos | length"
env: WASM_LIST_CODE_LENGTH
# Get height from beginning
- cmd: tail -1 integration_test/contracts/wasm_beginning_block_height.txt
env: BEGINNING_BLOCK_HEIGHT
# Verify 0 stored wasm contracts at beginning height
- cmd: seid q wasm list-code --count-total --limit 400 --height $BEGINNING_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: BEGINNING_LIST_CODE_LENGTH
# Get height from first set
- cmd: tail -1 integration_test/contracts/wasm_first_set_block_height.txt
env: FIRST_SET_BLOCK_HEIGHT
# Verify 100 stored wasm contracts at first height
- cmd: seid q wasm list-code --count-total --limit 400 --height $FIRST_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: FIRST_SET_LIST_CODE_LENGTH
# Verify 100 stored wasm contracts at first height reverse
- cmd: seid q wasm list-code --reverse --count-total --limit 400 --height $FIRST_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: FIRST_SET_LIST_CODE_LENGTH_REVERSE
# Get height from second set
- cmd: tail -1 integration_test/contracts/wasm_second_set_block_height.txt
env: SECOND_SET_BLOCK_HEIGHT
# Verify 200 stored wasm contracts at second height
- cmd: seid q wasm list-code --count-total --limit 400 --height $SECOND_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: SECOND_SET_LIST_CODE_LENGTH
# Verify 200 stored wasm contracts at second height reverse
- cmd: seid q wasm list-code --reverse --count-total --limit 400 --height $SECOND_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: SECOND_SET_LIST_CODE_LENGTH_REVERSE
# Get height from third set
- cmd: tail -1 integration_test/contracts/wasm_third_set_block_height.txt
env: THIRD_SET_BLOCK_HEIGHT
# Verify 300 stored wasm contracts at third height
- cmd: seid q wasm list-code --count-total --limit 400 --height $THIRD_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: THIRD_SET_LIST_CODE_LENGTH
# Verify 300 stored wasm contracts at third height reverse
- cmd: seid q wasm list-code --reverse --count-total --limit 400 --height $THIRD_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos | length"
env: THIRD_SET_LIST_CODE_LENGTH_REVERSE
verifiers:
# Verify number of wasm codes at each height
- type: eval
expr: BEGINNING_LIST_CODE_LENGTH == 0
- type: eval
expr: FIRST_SET_LIST_CODE_LENGTH == 100
- type: eval
expr: FIRST_SET_LIST_CODE_LENGTH_REVERSE == 100
- type: eval
expr: SECOND_SET_LIST_CODE_LENGTH == 200
- type: eval
expr: SECOND_SET_LIST_CODE_LENGTH_REVERSE == 200
- type: eval
expr: THIRD_SET_LIST_CODE_LENGTH == 300
- type: eval
expr: THIRD_SET_LIST_CODE_LENGTH_REVERSE == 300

- name: Test state store historical data checking specific wasm codes
inputs:
# Get height from first set
- cmd: tail -1 integration_test/contracts/wasm_first_set_block_height.txt
env: FIRST_SET_BLOCK_HEIGHT
# Get code id from first contract returned at first set height in forward order (0)
- cmd: seid q wasm list-code --count-total --limit 400 --height $FIRST_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos[0].code_id"
env: FIRST_ID_FIRST_SET
# Get creator from first contract returned at first set height in forward order
- cmd: seid q wasm list-code --count-total --limit 400 --height $FIRST_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos[0].creator"
env: FIRST_CREATOR_FIRST_SET
# Get height from second set
- cmd: tail -1 integration_test/contracts/wasm_second_set_block_height.txt
env: SECOND_SET_BLOCK_HEIGHT
# Get code id from first contract returned at second set height in reverse order (200)
- cmd: seid q wasm list-code --reverse --count-total --limit 400 --height $SECOND_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos[0].code_id"
env: SECOND_ID_FIRST_SET
# Get creator from second contract returned at second set height in reverse order
- cmd: seid q wasm list-code --reverse --count-total --limit 400 --height $SECOND_SET_BLOCK_HEIGHT --output json | jq -r ".code_infos[0].creator"
env: FIRST_CREATOR_SECOND_SET
# Get creator id
- cmd: tail -1 integration_test/contracts/wasm_creator_id.txt
env: CREATOR_ID
verifiers:
# Verify we have all same creator id
- type: eval
expr: FIRST_CREATOR_FIRST_SET == CREATOR_ID
- type: eval
expr: FIRST_CREATOR_SECOND_SET == CREATOR_ID
# Verify correct code ids
# NOTE: Since chain is continually running / stateful, may have remove
- type: eval
expr: FIRST_ID_FIRST_SET == 1
- type: eval
expr: SECOND_ID_FIRST_SET == 200

- name: Test state store iteration through tokenfactory denoms
inputs:
# Get creator id
- cmd: tail -1 integration_test/contracts/tfk_creator_id.txt
env: CREATOR_ID
# Get height from beginning
- cmd: tail -1 integration_test/contracts/tfk_beginning_block_height.txt
env: BEGINNING_BLOCK_HEIGHT
# Verify 0 tfk denoms created at beginning
- cmd: seid q tokenfactory denoms-from-creator $CREATOR_ID --height $BEGINNING_BLOCK_HEIGHT --output json | jq -r ".denoms | length"
env: BEGINNING_TFK_DENOMS
# Get height from first set
- cmd: tail -1 integration_test/contracts/tfk_first_set_block_height.txt
env: FIRST_SET_BLOCK_HEIGHT
# Verify 100 tfk denoms created at first
- cmd: seid q tokenfactory denoms-from-creator $CREATOR_ID --height $FIRST_SET_BLOCK_HEIGHT --output json | jq -r ".denoms | length"
env: FIRST_SET_TFK_DENOMS
# Get height from second set
- cmd: tail -1 integration_test/contracts/tfk_second_set_block_height.txt
env: SECOND_SET_BLOCK_HEIGHT
# Verify 200 tfk denoms created at second set
- cmd: seid q tokenfactory denoms-from-creator $CREATOR_ID --height $SECOND_SET_BLOCK_HEIGHT --output json | jq -r ".denoms | length"
env: SECOND_SET_TFK_DENOMS
# Get height from third set
- cmd: tail -1 integration_test/contracts/tfk_third_set_block_height.txt
env: THIRD_SET_BLOCK_HEIGHT
# Verify 300 tfk denoms created at third set
- cmd: seid q tokenfactory denoms-from-creator $CREATOR_ID --height $THIRD_SET_BLOCK_HEIGHT --output json | jq -r ".denoms | length"
env: THIRD_SET_TFK_DENOMS
verifiers:
# Verify number of wasm codes at each height
- type: eval
expr: BEGINNING_TFK_DENOMS == 0
- type: eval
expr: FIRST_SET_TFK_DENOMS == 100
- type: eval
expr: SECOND_SET_TFK_DENOMS == 200
- type: eval
expr: THIRD_SET_TFK_DENOMS == 300