Skip to content

Commit

Permalink
chore: bump version (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond authored Dec 20, 2024
1 parent 5921715 commit 4c722bd
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 47 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/cosmos/cosmos-sdk v0.50.9
github.com/cosmos/ibc-go/modules/capability v1.0.1
github.com/cosmos/ibc-go/v8 v8.5.1
github.com/elys-network/elys v1.0.0
github.com/elys-network/elys v1.4.0
github.com/spf13/cobra v1.8.1
github.com/vbauerster/mpb/v8 v8.8.3
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,8 @@ github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkg
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elys-network/bandchain-packet v0.0.3-sdk47 h1:W4sP/JOXAoABhsV+ck1NTphLuqpuxGg+uul1nDLbgxk=
github.com/elys-network/bandchain-packet v0.0.3-sdk47/go.mod h1:/CtU24lu2E4RbPRcZFJfEagwW6TUdFcxv7pX0cYYSgk=
github.com/elys-network/elys v1.0.0 h1:iQEcZNYT0pRkewhq1wJj298E5bRX9FetrLEKmDLjxHY=
github.com/elys-network/elys v1.0.0/go.mod h1:NZ52jlKhFT3/l4C2Y6boQqeUga+npWmlE7opK9BtZVA=
github.com/elys-network/elys v1.4.0 h1:OS9UroRxjnf9WgpN6yxpOFkfeGPeOUOWjr06X3roXsA=
github.com/elys-network/elys v1.4.0/go.mod h1:NZ52jlKhFT3/l4C2Y6boQqeUga+npWmlE7opK9BtZVA=
github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A=
github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
Expand Down
109 changes: 75 additions & 34 deletions scripts/create-and-upload-snapshot.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# R2 credentials
export R2_ACCESS_KEY=
export R2_SECRET_KEY=
export R2_BUCKET_NAME=
export R2_ENDPOINT=

# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
Expand All @@ -13,6 +19,36 @@ INFO_JSON_PATH="/tmp/info.json"
SERVICE_NAME="elysd"
HOME_PATH="$HOME/.elys"

# Check if the binary exists
if ! command -v $BINARY_NAME &> /dev/null; then
echo -e "${RED}Binary $BINARY_NAME not found. Please install post-upgrade-snapshot-generator first.${NC}"
exit 1
fi

# Check if the service exists
if ! systemctl is-active --quiet $SERVICE_NAME; then
echo -e "${RED}Service $SERVICE_NAME not found. Please install the service first.${NC}"
exit 1
fi

# Check if the home path exists
if [ ! -d $HOME_PATH ]; then
echo -e "${RED}Home path $HOME_PATH not found. Please set the home path first.${NC}"
exit 1
fi

# Check if rclone is installed
if ! command -v rclone &> /dev/null; then
echo -e "${RED}Rclone not found. Please install rclone first.${NC}"
exit 1
fi

# Check if lz4 is installed
if ! command -v lz4 &> /dev/null; then
echo -e "${RED}Lz4 not found. Please install lz4 first.${NC}"
exit 1
fi

echo -e "${YELLOW}Starting snapshot creation and upload process...${NC}"

# Stop the systemd service
Expand All @@ -38,11 +74,26 @@ if [ $? -ne 0 ]; then
fi
echo -e "${GREEN}Successfully created snapshot${NC}"

# Restart the service
echo -e "${YELLOW}Restarting $SERVICE_NAME service...${NC}"
sudo systemctl start $SERVICE_NAME
if [ $? -ne 0 ]; then
echo -e "${RED}Failed to restart $SERVICE_NAME service${NC}"
exit 1
fi

# Wait a few seconds and check if service is running
sleep 5
if ! systemctl is-active --quiet $SERVICE_NAME; then
echo -e "${RED}Warning: $SERVICE_NAME service failed to start properly${NC}"
exit 1
fi

# Get snapshot file size
file_size=$(ls -lh $SNAPSHOT_PATH | awk '{print $5}')

# Generate info.json
echo -e "${YELLOW}Generating info.json...${NC}"
echo -e "${YELLOW}Generating ${INFO_JSON_PATH}...${NC}"
# Fetch the JSON data from the Elys testnet RPC endpoint
input_json=$(curl -s https://rpc.testnet.elys.network/abci_info?)

Expand All @@ -55,44 +106,49 @@ version=$(echo "$input_json" | jq -r '.result.response.version')
created_at=$(date -Iseconds)
jq -n \
--arg blockHeight "$block_height" \
--arg fileName "snapshot.tar.lz4" \
--arg fileName "$SNAPSHOT_PATH" \
--arg fileSize "$file_size" \
--arg createdAt "$created_at" \
--arg version "$version" \
'{blockHeight: $blockHeight, fileName: $fileName, fileSize: $fileSize, createdAt: $createdAt, version: $version}' > $INFO_JSON_PATH

if [ $? -ne 0 ]; then
echo -e "${RED}Failed to generate info.json${NC}"
# Cleanup and restart service before exiting
echo -e "${RED}Failed to generate ${INFO_JSON_PATH}${NC}"
# Cleanup before exiting
rm -f $SNAPSHOT_PATH
sudo systemctl start $SERVICE_NAME
exit 1
fi
echo -e "${GREEN}Successfully generated info.json${NC}"
echo -e "${GREEN}Successfully generated ${INFO_JSON_PATH}${NC}"

# Set rclone environment variables
export RCLONE_CONFIG_R2_TYPE=s3
export RCLONE_CONFIG_R2_PROVIDER=Cloudflare
export RCLONE_CONFIG_R2_ACCESS_KEY_ID=$R2_ACCESS_KEY
export RCLONE_CONFIG_R2_SECRET_ACCESS_KEY=$R2_SECRET_KEY
export RCLONE_CONFIG_R2_REGION=enam
export RCLONE_CONFIG_R2_ENDPOINT=$R2_ENDPOINT

# Upload the snapshot
echo -e "${YELLOW}Uploading snapshot...${NC}"
$BINARY_NAME upload-snapshot $SNAPSHOT_PATH
rclone -vv copy $SNAPSHOT_PATH r2:${R2_BUCKET_NAME}/
if [ $? -ne 0 ]; then
echo -e "${RED}Failed to upload snapshot${NC}"
# Cleanup and restart service before exiting
# Cleanup before exiting
rm -f $SNAPSHOT_PATH $INFO_JSON_PATH
sudo systemctl start $SERVICE_NAME
exit 1
fi
echo -e "${GREEN}Successfully uploaded snapshot${NC}"

# Upload info.json
echo -e "${YELLOW}Uploading info.json...${NC}"
$BINARY_NAME upload-snapshot $INFO_JSON_PATH
echo -e "${YELLOW}Uploading ${INFO_JSON_PATH}...${NC}"
rclone -vv copy $INFO_JSON_PATH r2:${R2_BUCKET_NAME}/
if [ $? -ne 0 ]; then
echo -e "${RED}Failed to upload info.json${NC}"
# Cleanup and restart service before exiting
echo -e "${RED}Failed to upload ${INFO_JSON_PATH}${NC}"
# Cleanup before exiting
rm -f $SNAPSHOT_PATH $INFO_JSON_PATH
sudo systemctl start $SERVICE_NAME
exit 1
fi
echo -e "${GREEN}Successfully uploaded info.json${NC}"
echo -e "${GREEN}Successfully uploaded ${INFO_JSON_PATH}${NC}"

# Clean up the temporary files
echo -e "${YELLOW}Cleaning up temporary files...${NC}"
Expand All @@ -101,23 +157,8 @@ if [ $? -ne 0 ]; then
echo -e "${RED}Warning: Failed to clean up temporary files${NC}"
fi

# Restart the service
echo -e "${YELLOW}Restarting $SERVICE_NAME service...${NC}"
sudo systemctl start $SERVICE_NAME
if [ $? -ne 0 ]; then
echo -e "${RED}Failed to restart $SERVICE_NAME service${NC}"
exit 1
fi

# Wait a few seconds and check if service is running
sleep 5
if ! systemctl is-active --quiet $SERVICE_NAME; then
echo -e "${RED}Warning: $SERVICE_NAME service failed to start properly${NC}"
exit 1
fi

echo -e "${GREEN}Process completed successfully!${NC}"
echo -e "${GREEN}- Snapshot created and uploaded${NC}"
echo -e "${GREEN}- info.json created and uploaded${NC}"
echo -e "${GREEN}- Temporary files cleaned up${NC}"
echo -e "${GREEN}- $SERVICE_NAME service restarted${NC}"
echo -e "${GREEN}- $SNAPSHOT_PATH created and uploaded${NC}"
echo -e "${GREEN}- $SERVICE_NAME service restarted${NC}"
echo -e "${GREEN}- $INFO_JSON_PATH created and uploaded${NC}"
echo -e "${GREEN}- Temporary files cleaned up${NC}"
32 changes: 22 additions & 10 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,33 @@ type Commitment struct {

Params CommitmentParams `json:"params"`
Commitments []interface{} `json:"commitments"`
KolList []KolList `json:"kol_list"`
AtomStakers []AtomStaker `json:"atom_stakers"`
}

type AtomStaker struct {
commitmenttypes.AtomStaker

Address string `json:"address"`
Amount string `json:"amount"`
}

type KolList struct {
commitmenttypes.KolList

Address string `json:"address"`
Amount string `json:"amount"`
}

type CommitmentParams struct {
commitmenttypes.Params

VestingInfos []CommitmentVestingInfo `json:"vesting_infos"`
NumberOfCommitments json.Number `json:"number_of_commitments"`
StartAtomStakersHeight json.Number `json:"start_atom_stakers_height"`
EndAtomStakersHeight json.Number `json:"end_atom_stakers_height"`
StartCadetsHeight json.Number `json:"start_cadets_height"`
EndCadetsHeight json.Number `json:"end_cadets_height"`
StartNftHoldersHeight json.Number `json:"start_nft_holders_height"`
EndNftHoldersHeight json.Number `json:"end_nft_holders_height"`
StartGovernorsHeight json.Number `json:"start_governors_height"`
EndGovernorsHeight json.Number `json:"end_governors_height"`
VestingInfos []CommitmentVestingInfo `json:"vesting_infos"`
NumberOfCommitments json.Number `json:"number_of_commitments"`
StartAirdropClaimHeight json.Number `json:"start_airdrop_claim_height"`
EndAirdropClaimHeight json.Number `json:"end_airdrop_claim_height"`
StartKolClaimHeight json.Number `json:"start_kol_claim_height"`
EndKolClaimHeight json.Number `json:"end_kol_claim_height"`
}

type CommitmentVestingInfo struct {
Expand Down
21 changes: 21 additions & 0 deletions utils/update-genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ func UpdateGenesis(cmdPath, homePath, genesisFilePath string, balances []string,
// update AMM params to whitelist validator address
genesis.AppState.Amm.Params.AllowedPoolCreators = append(genesis.AppState.Amm.Params.AllowedPoolCreators, validatorAddress)

// update commitment airdrop params
// genesis.AppState.Commitment.Params.EnableClaim = true
// genesis.AppState.Commitment.Params.StartAirdropClaimHeight = json.Number("111046")
// genesis.AppState.Commitment.Params.EndAirdropClaimHeight = json.Number("111600")
// genesis.AppState.Commitment.Params.StartKolClaimHeight = json.Number("111046")
// genesis.AppState.Commitment.Params.EndKolClaimHeight = json.Number("111600")

// genesis.AppState.Commitment.KolList = []types.KolList{
// {
// Address: "elys1wluheavcjknwnagskt0994rrtuvap9jcz0ng5q",
// Amount: "1000000000000",
// },
// }

// genesis.AppState.Commitment.AtomStakers = []types.AtomStaker{
// {
// Address: "elys1wluheavcjknwnagskt0994rrtuvap9jcz0ng5q",
// Amount: "1000000000000",
// },
// }

// write genesis file
outputFilePath := homePath + "/config/genesis.json"
if err := WriteGenesisFile(outputFilePath, genesis); err != nil {
Expand Down

0 comments on commit 4c722bd

Please sign in to comment.