Skip to content

Commit

Permalink
fix: fix deployment scripts and nil key bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Dec 14, 2023
1 parent 74aad54 commit 2a38eb2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
6 changes: 1 addition & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="bullseye"
FROM golang:1.20.4
FROM golang:1.21

ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -14,10 +14,6 @@ RUN apt-get -y install --no-install-recommends vim
# WASM dependencies + Rustup
RUN apt-get -y install --no-install-recommends binaryen

# Cosmos dependencies
# Sadly Ignite + Cosmos SDK v0.47.x is broken atm
# RUN curl https://get.ignite.com/cli@nightly! | bash

# Go language extension dependencies
RUN go install github.com/cweill/gotests/[email protected]
RUN go install github.com/fatih/[email protected]
Expand Down
12 changes: 7 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ func NewApp(
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey,
crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
feegrant.StoreKey, evidencetypes.StoreKey, circuittypes.StoreKey,
ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey,
icacontrollertypes.StoreKey, consensusparamtypes.StoreKey, wasmstoragetypes.StoreKey,
wasmtypes.StoreKey, randomnesstypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey,
feegrant.StoreKey, evidencetypes.StoreKey, circuittypes.StoreKey, group.StoreKey,
capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
wasmtypes.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
wasmstoragetypes.StoreKey, randomnesstypes.StoreKey,
)

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

Expand Down
21 changes: 14 additions & 7 deletions scripts/testnet/add_wasm_state_to_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ function download_contract_release() {
mkdir -p $WASM_DIR

function gh_curl() {
set +x
curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3.raw" \
$@
set -x
}

if [ "$CONTRACTS_VERSION" = "latest" ]; then
Expand All @@ -35,18 +37,20 @@ function download_contract_release() {
exit 1
fi;

set +x
curl -sL --header "Authorization: token $GITHUB_TOKEN" \
--header 'Accept: application/octet-stream' \
https://$GITHUB_TOKEN:@api.github.com/repos/$repo/releases/assets/$asset_id \
--output-dir $WASM_DIR --output ${1}
set -x
}

# store_and_instantiate() stores and instantiates a contract and returns its address
# Arguments:
# $1: Contract file name
# $2: Initial state
function store_and_instantiate() {
local TX_OUTPUT=$($BIN tx wasm store $WASM_DIR/$1 --from $ADDR --keyring-backend test --gas auto --gas-adjustment 1.2 --home $TMP_HOME -y --output json)
local TX_OUTPUT=$($BIN tx wasm store $WASM_DIR/$1 --from $ADDR --keyring-backend test --gas auto --gas-adjustment 1.2 --home $TMP_HOME --chain-id $TEMP_CHAIN_ID -y --output json)
[[ -z "$TX_OUTPUT" ]] && { echo "failed to get tx output" ; exit 1; }
local TX_HASH=$(echo $TX_OUTPUT | jq -r .txhash)
sleep 10;
Expand All @@ -55,12 +59,12 @@ function store_and_instantiate() {
local CODE_ID=$(echo $STORE_TX_OUTPUT | jq -r '.events[] | select(.type | contains("store_code")).attributes[] | select(.key | contains("code_id")).value')
[[ -z "$CODE_ID" ]] && { echo "failed to get code ID" ; exit 1; }

local INSTANTIATE_OUTPUT=$($BIN tx wasm instantiate $CODE_ID "$2" --no-admin --from $ADDR --keyring-backend test --label $CODE_ID --gas auto --gas-adjustment 1.2 --home $TMP_HOME -y --output json)
local INSTANTIATE_OUTPUT=$($BIN tx wasm instantiate $CODE_ID "$2" --no-admin --from $ADDR --keyring-backend test --label $CODE_ID --gas auto --gas-adjustment 1.2 --home $TMP_HOME --chain-id $TEMP_CHAIN_ID -y --output json)
TX_HASH=$(echo "$INSTANTIATE_OUTPUT" | jq -r '.txhash')
sleep 10;

local INSTANTIATE_TX_OUTPUT=$($BIN query tx $TX_HASH --home $TMP_HOME --output json)
local CONTRACT_ADDRESS=$(echo $INSTANTIATE_TX_OUTPUT | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value')
local CONTRACT_ADDRESS=$(echo $INSTANTIATE_TX_OUTPUT | jq -r '.events[] | select(.type == "instantiate") | .attributes[] | select(.key == "_contract_address") | .value')
[[ -z "$CONTRACT_ADDRESS" ]] && { echo "failed to get contract address for ${1}" ; exit 1; }

echo $CONTRACT_ADDRESS
Expand All @@ -86,16 +90,19 @@ download_contract_release proxy_contract.wasm
download_contract_release staking.wasm
download_contract_release data_requests.wasm

TEMP_CHAIN_ID=temp-seda-chain

#
# SCRIPT BEGINS - START CHAIN
#
$BIN init new node0 --home $TMP_HOME
$BIN init new node0 --home $TMP_HOME --chain-id $TEMP_CHAIN_ID

cat $TMP_HOME/config/genesis.json | jq '.consensus["params"]["validator"]["pub_key_types"]=["secp256k1"]' > $TMP_HOME/config/tmp_genesis.json && mv $TMP_HOME/config/tmp_genesis.json $TMP_HOME/config/genesis.json

$BIN keys add deployer --home $TMP_HOME --keyring-backend test
ADDR=$($BIN keys show deployer --home $TMP_HOME --keyring-backend test -a)
$BIN add-genesis-account $ADDR 100000000000000000seda --home $TMP_HOME --keyring-backend test
$BIN gentx deployer 10000000000000000seda --home $TMP_HOME --keyring-backend test
$BIN gentx deployer 10000000000000000seda --home $TMP_HOME --keyring-backend test --chain-id $TEMP_CHAIN_ID
$BIN collect-gentxs --home $TMP_HOME


Expand All @@ -117,9 +124,9 @@ DR_ADDR=$(store_and_instantiate data_requests.wasm "$ARG")


# Call SetStaking and SetDataRequests on Proxy contract to set circular dependency
$BIN tx wasm execute $PROXY_ADDR '{"set_staking":{"contract":"'$STAKING_ADDR'"}}' --from $ADDR --gas auto --gas-adjustment 1.2 --keyring-backend test --home $TMP_HOME -y
$BIN tx wasm execute $PROXY_ADDR '{"set_staking":{"contract":"'$STAKING_ADDR'"}}' --from $ADDR --gas auto --gas-adjustment 1.2 --keyring-backend test --home $TMP_HOME --chain-id $TEMP_CHAIN_ID -y
sleep 10
$BIN tx wasm execute $PROXY_ADDR '{"set_data_requests":{"contract":"'$DR_ADDR'"}}' --from $ADDR --gas auto --gas-adjustment 1.2 --keyring-backend test --home $TMP_HOME -y
$BIN tx wasm execute $PROXY_ADDR '{"set_data_requests":{"contract":"'$DR_ADDR'"}}' --from $ADDR --gas auto --gas-adjustment 1.2 --keyring-backend test --home $TMP_HOME --chain-id $TEMP_CHAIN_ID -y
sleep 10


Expand Down
3 changes: 2 additions & 1 deletion scripts/testnet/create_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $BIN init new node0 --chain-id $CHAIN_ID
cat $HOME/.seda-chain/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="180s"' > $HOME/.seda-chain/config/tmp_genesis.json && mv $HOME/.seda-chain/config/tmp_genesis.json $HOME/.seda-chain/config/genesis.json
cat $HOME/.seda-chain/config/genesis.json | jq '.app_state["gov"]["params"]["voting_period"]="180s"' > $HOME/.seda-chain/config/tmp_genesis.json && mv $HOME/.seda-chain/config/tmp_genesis.json $HOME/.seda-chain/config/genesis.json
cat $HOME/.seda-chain/config/genesis.json | jq '.app_state["gov"]["params"]["max_deposit_period"]="180s"' > $HOME/.seda-chain/config/tmp_genesis.json && mv $HOME/.seda-chain/config/tmp_genesis.json $HOME/.seda-chain/config/genesis.json
cat $HOME/.seda-chain/config/genesis.json | jq '.consensus["params"]["validator"]["pub_key_types"]=["secp256k1"]' > $HOME/.seda-chain/config/tmp_genesis.json && mv $HOME/.seda-chain/config/tmp_genesis.json $HOME/.seda-chain/config/genesis.json

# TO-DO?
# - chain id
Expand Down Expand Up @@ -66,7 +67,7 @@ for i in ${!MONIKERS[@]}; do
# to output geneis file
$BIN add-genesis-account $VALIDATOR_ADDRESS 500000000000000000seda

$BIN gentx ${MONIKERS[$i]} ${SELF_DELEGATION_AMOUNTS[$i]} --moniker=${MONIKERS[$i]} --keyring-backend=test --home $INDIVIDUAL_VAL_HOME_DIR --ip=${IPS[$i]}
$BIN gentx ${MONIKERS[$i]} ${SELF_DELEGATION_AMOUNTS[$i]} --moniker=${MONIKERS[$i]} --keyring-backend=test --home $INDIVIDUAL_VAL_HOME_DIR --ip=${IPS[$i]} --chain-id $CHAIN_ID

cp -a $INDIVIDUAL_VAL_CONFIG_DIR/gentx/. $GENTX_DIR
done
Expand Down

0 comments on commit 2a38eb2

Please sign in to comment.