Skip to content

Commit

Permalink
Merge pull request #88 from sideprotocol/release/v0.9.x
Browse files Browse the repository at this point in the history
Release/v0.9.x
  • Loading branch information
liangping authored Jun 21, 2024
2 parents c585a15 + e70c608 commit 9b84854
Show file tree
Hide file tree
Showing 59 changed files with 13,493 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*.swl
*.swm
*.swn
.vscode
# .vscode
.idea
*.pyc
*.exe
Expand Down Expand Up @@ -85,4 +85,4 @@ contracts/@openzeppelin/*

# Ignore deploy script
development/setup_testnet.sh
development/join_testnet.sh
development/join_testnet.sh
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Query Best Block",
"type": "go",
"request": "launch",
"mode": "auto",
"args": ["q", "btclightclient", "best-block"],
"program": "cmd/sided/main.go --home ~/.side"
},
{
"name": "Query Block",
"type": "go",
"request": "launch",
"mode": "auto",
"args": ["q", "btclightclient", "block", "000000006c52128fcccbc0e5d9311cb9ffdfd3d6655dabc63c2871718c278b5f"],
"program": "cmd/sided/main.go"
},
{
"name": "Start Blockchain",
"type": "go",
"request": "launch",
"mode": "auto",
"args": ["start"],
"program": "cmd/sided/main.go"
}
]
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/make -f

PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
VERSION ?= $(shell echo $(shell git describe --tags --always) | sed 's/^v//')
VERSION ?= $(shell echo $(shell git tag --sort=creatordate | tail -1) | sed 's/^v//')
TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
Expand Down
6 changes: 4 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cast"

btcbridgetypes "github.com/sideprotocol/side/x/btcbridge/types"
gmmmoduletypes "github.com/sideprotocol/side/x/gmm/types"

yieldmoduletypes "github.com/sideprotocol/side/x/yield/types"
Expand All @@ -84,8 +85,8 @@ import (
)

const (
AccountAddressPrefix = "bc"
Name = "side"
// AccountAddressPrefix = "bc"
Name = "side"
)

var Upgrades = []upgrades.Upgrade{v1.Upgrade, v2.Upgrade}
Expand Down Expand Up @@ -270,6 +271,7 @@ func New(
wasmTypes.ModuleName,
gmmmoduletypes.ModuleName,
yieldmoduletypes.ModuleName,
btcbridgetypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
}
app.mm.SetOrderInitGenesis(OrderInitGenesis()...)
Expand Down
17 changes: 14 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ import (
yieldmodulekeeper "github.com/sideprotocol/side/x/yield/keeper"
yieldmoduletypes "github.com/sideprotocol/side/x/yield/types"

btcbridgekeeper "github.com/sideprotocol/side/x/btcbridge/keeper"
btcbridgetypes "github.com/sideprotocol/side/x/btcbridge/types"

// this line is used by starport scaffolding # stargate/app/moduleImport

appparams "github.com/sideprotocol/side/app/params"
Expand Down Expand Up @@ -126,9 +129,9 @@ type AppKeepers struct {
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper

GmmKeeper gmmmodulekeeper.Keeper

YieldKeeper yieldmodulekeeper.Keeper
GmmKeeper gmmmodulekeeper.Keeper
YieldKeeper yieldmodulekeeper.Keeper
BtcBridgeKeeper btcbridgekeeper.Keeper

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
Expand Down Expand Up @@ -389,6 +392,13 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.IcacallbacksKeeper,
)

appKeepers.BtcBridgeKeeper = *btcbridgekeeper.NewKeeper(
appCodec,
appKeepers.keys[btcbridgetypes.StoreKey],
appKeepers.keys[btcbridgetypes.StoreKey],
appKeepers.BankKeeper,
)

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate,side,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_4"
Expand Down Expand Up @@ -493,6 +503,7 @@ func KVStoreKeys() []string {
ibcfeetypes.StoreKey,
gmmmoduletypes.StoreKey,
yieldmoduletypes.StoreKey,
btcbridgetypes.StoreKey,
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (

yieldmodule "github.com/sideprotocol/side/x/yield"

btcmodule "github.com/sideprotocol/side/x/btcbridge"
// this line is used by starport scaffolding # stargate/app/moduleImport

// wasmd module integrate
Expand Down Expand Up @@ -74,6 +75,7 @@ var AppModuleBasics = module.NewBasicManager(
wasm.AppModuleBasic{},
gmmmodule.AppModuleBasic{},
yieldmodule.AppModuleBasic{},
btcmodule.AppModuleBasic{},
)

func getGovProposalHandlers() []govclient.ProposalHandler {
Expand Down
8 changes: 8 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ import (
yieldmodule "github.com/sideprotocol/side/x/yield"
yieldmoduletypes "github.com/sideprotocol/side/x/yield/types"

btcbridge "github.com/sideprotocol/side/x/btcbridge"
btcbridgetypes "github.com/sideprotocol/side/x/btcbridge/types"

// this line is used by starport scaffolding # stargate/app/moduleImport

appparams "github.com/sideprotocol/side/app/params"
Expand All @@ -92,6 +95,7 @@ var moduleAccountPermissions = map[string][]string{
wasmTypes.ModuleName: {authtypes.Burner},
gmmmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
yieldmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
btcbridgetypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

// appModules return modules to initialize module manager.
Expand Down Expand Up @@ -138,6 +142,7 @@ func appModules(
icaModule,
gmmModule,
yieldModule,
btcbridge.NewAppModule(appCodec, app.BtcBridgeKeeper),
// this line is used by starport scaffolding # stargate/app/appModule

crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
Expand Down Expand Up @@ -173,6 +178,7 @@ func orderBeginBlockers() []string {
wasmTypes.ModuleName,
gmmmoduletypes.ModuleName,
yieldmoduletypes.ModuleName,
btcbridgetypes.ModuleName,
}
return ord
}
Expand Down Expand Up @@ -205,6 +211,7 @@ func OrderEndBlockers() []string {
wasmTypes.ModuleName,
gmmmoduletypes.ModuleName,
yieldmoduletypes.ModuleName,
btcbridgetypes.ModuleName,
}
return ord
}
Expand Down Expand Up @@ -242,6 +249,7 @@ func OrderInitGenesis() []string {
wasmTypes.ModuleName,
gmmmoduletypes.ModuleName,
yieldmoduletypes.ModuleName,
btcbridgetypes.ModuleName,
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const Bech32Prefix = "cosmos"
const bech32Prefix = "cosmos"

func init() {
SetupConfig()
Expand All @@ -37,8 +37,8 @@ func SetupConfig() {
config := sdk.GetConfig()
valoper := sdk.PrefixValidator + sdk.PrefixOperator
valoperpub := sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
config.SetBech32PrefixForAccount(Bech32Prefix, Bech32Prefix+sdk.PrefixPublic)
config.SetBech32PrefixForValidator(Bech32Prefix+valoper, Bech32Prefix+valoperpub)
config.SetBech32PrefixForAccount(bech32Prefix, bech32Prefix+sdk.PrefixPublic)
config.SetBech32PrefixForValidator(bech32Prefix+valoper, bech32Prefix+valoperpub)

config.SetCoinType(84) // use the same coin type as bitcoin

Expand Down
17 changes: 9 additions & 8 deletions cmd/sided/cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package cmd

import (
"github.com/btcsuite/btcd/chaincfg"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/sideprotocol/side/app"
)

func initSDKConfig() {
// Set prefixes
accountPubKeyPrefix := app.AccountAddressPrefix + "pub"
validatorAddressPrefix := app.AccountAddressPrefix + "valoper"
validatorPubKeyPrefix := app.AccountAddressPrefix + "valoperpub"
consNodeAddressPrefix := app.AccountAddressPrefix + "valcons"
consNodePubKeyPrefix := app.AccountAddressPrefix + "valconspub"
bech32Prefix := "side"
accountPubKeyPrefix := bech32Prefix + "pub"
validatorAddressPrefix := bech32Prefix + "valoper"
validatorPubKeyPrefix := bech32Prefix + "valoperpub"
consNodeAddressPrefix := bech32Prefix + "valcons"
consNodePubKeyPrefix := bech32Prefix + "valconspub"

// Set and seal config
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(app.AccountAddressPrefix, accountPubKeyPrefix)
config.SetBech32PrefixForAccount(bech32Prefix, accountPubKeyPrefix)
config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
config.SetBtcChainCfg(&chaincfg.SigNetParams)

config.Seal()
}
14 changes: 9 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/aead/siphash v1.0.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go v1.44.203 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/bufbuild/connect-go v1.0.0 // indirect
github.com/bufbuild/protocompile v0.8.0 // indirect
Expand Down Expand Up @@ -131,6 +128,7 @@ require (
github.com/jhump/protoreflect v1.15.6 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
Expand Down Expand Up @@ -174,6 +172,7 @@ require (
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.16.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand Down Expand Up @@ -216,6 +215,11 @@ require (
github.com/CosmWasm/wasmd v0.45.0
github.com/CosmWasm/wasmvm v1.5.2
github.com/Stride-Labs/stride/v16 v16.0.0
github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/btcutil/psbt v1.1.9
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/bufbuild/buf v1.7.0
github.com/cosmos/cosmos-proto v1.0.0-beta.4
github.com/cosmos/ics23/go v0.10.0
Expand All @@ -230,7 +234,7 @@ require (
)

replace (
github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.116
github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.11-btc1
// github.com/cosmos/cosmos-sdk => ../cosmos-sdk
github.com/cosmos/interchain-security/v3 => github.com/Stride-Labs/interchain-security/v3 v3.1.0-remove-validation-bug-7d3d9d
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ github.com/Stride-Labs/stride/v16 v16.0.0/go.mod h1:0I+YGZ6EiuN8XCbeg+KHpo+gge+R
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -281,6 +282,8 @@ github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9Ur
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8=
github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00=
github.com/btcsuite/btcd/btcutil/psbt v1.1.9 h1:UmfOIiWMZcVMOLaN+lxbbLSuoINGS1WmK1TZNI0b4yk=
github.com/btcsuite/btcd/btcutil/psbt v1.1.9/go.mod h1:ehBEvU91lxSlXtA+zZz3iFYx7Yq9eqnKx4/kSrnsvMY=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ=
Expand Down Expand Up @@ -754,6 +757,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
Expand Down Expand Up @@ -973,8 +977,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sideprotocol/cosmos-sdk v0.47.116 h1:9qXEko5qj+RVHR5a01dheCjqzw5MlnYqxu36fqJm5MU=
github.com/sideprotocol/cosmos-sdk v0.47.116/go.mod h1:Ql8d4j8oRXssuNQfVIaa6LRo7VsFMJgSy2Qckd/dcr0=
github.com/sideprotocol/cosmos-sdk v0.47.11-btc1 h1:I34aYrAD/kvm6OqB7dlCterLNSLGwo0CSFzkMuQeCDA=
github.com/sideprotocol/cosmos-sdk v0.47.11-btc1/go.mod h1:lZq3Vdy3Mph8+unX5Afbmf1hsvj9FaYGMLEdCGjOY6g=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
Expand Down
16 changes: 14 additions & 2 deletions local_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ CHAINID="S2-testnet-1"
MONIKER="Side Labs"
BINARY="$HOME/go/bin/sided"
DENOM_STR="uside,ubtct,uusdc,uusdc.axl,uusdc.noble,uusdt,uusdt.kava,uusdt.axl,uwbtc.axl,uwbtc.osmo,uwbtc"

INITIAL_ACCOUNT_STR="bc1q4h88d5xg2cxxcm2kaej32lx6gkdfrxslfaxm8n"
set -f
IFS=,
DENOMS=($DENOM_STR)
INITIAL_ACCOUNTS=($INITIAL_ACCOUNT_STR)

IFS=";"


INITIAL_SUPPLY="500000000000000"
BLOCK_GAS=10000000
MAX_GAS=10000000000
Expand Down Expand Up @@ -103,6 +103,18 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
$BINARY add-genesis-account "$KEY" ${BALANCES:1} --keyring-backend $KEYRING --home "$HOMEDIR"
done

# Allocate genesis accounts (cosmos formatted addresses)
for ADDR in "${INITIAL_ACCOUNTS[@]}"; do
BALANCES=""
for key in "${!DENOMS[@]}"; do
BALANCES+=",${INITIAL_SUPPLY}${DENOMS[$key]}"
done
echo ${BALANCES:1}
$BINARY add-genesis-account "$ADDR" ${BALANCES:1} --home "$HOMEDIR"
done



# Sign genesis transaction
echo $INITIAL_SUPPLY${DENOMS[0]}
$BINARY gentx "${KEYS[0]}" $INITIAL_SUPPLY${DENOMS[0]} --keyring-backend $KEYRING --chain-id $CHAINID --identity "666AC57CC678BEC4" --website="https://side.one" --home "$HOMEDIR"
Expand Down
Loading

0 comments on commit 9b84854

Please sign in to comment.