Skip to content

Commit

Permalink
feat: resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Feb 17, 2023
2 parents 1f45a10 + 170ee16 commit 31f8d4e
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 143 deletions.
32 changes: 19 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"fmt"
"io"
"math/big"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -185,6 +186,8 @@ func init() {
}

DefaultNodeHome = filepath.Join(userHomeDir, "."+ShortName)

sdk.DefaultPowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil))
}

// App extends an ABCI application, but with most of its parameters exported.
Expand Down Expand Up @@ -617,9 +620,6 @@ func New(
app.MountMemoryStores(memKeys)

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)

anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
Expand All @@ -638,6 +638,9 @@ func New(
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.SetUpgradeChecker(app.UpgradeKeeper.IsUpgraded)

ms := app.CommitMultiStore()
ctx := sdk.NewContext(ms, tmproto.Header{ChainID: app.ChainID(), Height: app.LastBlockHeight()}, true, app.UpgradeKeeper.IsUpgraded, app.Logger())
if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
Expand All @@ -646,27 +649,24 @@ func New(
// Execute the upgraded register, such as the newly added Msg type
// ex.
// app.GovKeeper.Router().RegisterService(...)
ms := app.CommitMultiStore()
ctx := sdk.NewContext(ms, tmproto.Header{ChainID: app.ChainID(), Height: app.LastBlockHeight()}, true, app.UpgradeKeeper.IsUpgraded, app.Logger())
if loadLatest {
err = app.UpgradeKeeper.InitUpgraded(ctx)
if err != nil {
panic(err)
}
err = app.UpgradeKeeper.InitUpgraded(ctx)
if err != nil {
panic(err)
}
}

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

app.initModules()
app.initModules(ctx)

return app
}

func (app *App) initModules() {
func (app *App) initModules(ctx sdk.Context) {
app.initBridge()

app.initCrossChain()

app.initGashub(ctx)
}

func (app *App) initCrossChain() {
Expand All @@ -678,6 +678,12 @@ func (app *App) initBridge() {
bridgemodulekeeper.RegisterCrossApps(app.BridgeKeeper)
}

func (app *App) initGashub(ctx sdk.Context) {
if app.LastBlockHeight() > 0 {
app.GashubKeeper.RegisterGasCalculators(ctx)
}
}

// Name returns the name of the App
func (app *App) Name() string { return app.BaseApp.Name() }

Expand Down
2 changes: 1 addition & 1 deletion app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewDefaultAppConfig() *AppConfig {
// own app.toml to override, or use this default value.
//
// In simapp, we set the min gas prices to 0.
srvCfg.MinGasPrices = "0stake"
srvCfg.MinGasPrices = "1000000000BNB"

return &AppConfig{
Config: *srvCfg,
Expand Down
1 change: 1 addition & 0 deletions cmd/gnfd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {
flags.FlagChainID: app.Name + "_" + app.EIP155ChainID + "-" + app.Epoch,
flags.FlagKeyringBackend: "test",
flags.FlagSignMode: flags.SignModeEIP712,
flags.FlagGas: "auto",
})

return rootCmd, encodingConfig
Expand Down
12 changes: 6 additions & 6 deletions deployment/localup/.env
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
## BASIC CONFIG
CHAIN_ID=greenfield_9000-121
STAKING_BOND_DENOM=bnb
BASIC_DENOM=bnb
STAKING_BOND_AMOUNT=10000000000
STAKING_BOND_DENOM=BNB
BASIC_DENOM=BNB
STAKING_BOND_AMOUNT=10000000000000000000000000
SNAPSHOT_INTERVAL=10
SNAPSHOT_KEEP_RECENT=0
KPASS=12345678
GENESIS_ACCOUNT_BALANCE=100000000000
GENESIS_ACCOUNT_BALANCE=100000000000000000000000000
COMMISSION_MAX_CHANGE_RATE=0.01
COMMISSION_MAX_RATE=1.0
COMMISSION_RATE=0.07
NATIVE_COIN_DESC='{"description":"The native staking token of the Greenfield.","denom_units":[{"denom":"weibnb","exponent":0,"aliases":["ether"]},{"denom":"gweibnb","exponent":9,"aliases":["gwei"]},{"denom":"bnb","exponent":18 }],"base":"wei","display":"bnb"}'
NATIVE_COIN_DESC='{"description":"The native staking token of the Greenfield.","denom_units":[{"denom":"BNB","exponent":0,"aliases":["wei"]}],"base":"BNB","display":"BNB"}'
DEPOSIT_VOTE_PERIOD=300s
MIN_DEPOSIT_AMOUNT=100
GOV_MIN_DEPOSIT_AMOUNT=1000000000000000000

## CROSS CHAIN
SRC_CHAIN_ID=18
Expand Down
6 changes: 3 additions & 3 deletions deployment/localup/create_sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"approval_address": "0x78FeF615b06251ecfA9Ba01B7DB2BFA892722dDC",
"endpoint": "sp0.greenfield.io",
"deposit":{
"denom":"bnb",
"amount":"10000"
"denom":"BNB",
"amount":"10000000000000000000000"
},
"creator":"0x7b5Fe22B5446f7C62Ea27B8BD71CeF94e03f3dF2"
}
],
"metadata": "4pIMOgIGx1vZGU=",
"deposit": "1bnb"
"deposit": "1000000000000000000BNB"
}

32 changes: 16 additions & 16 deletions deployment/localup/localup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function generate_genesis() {
spfund_addr=("$(${bin} keys show sp${i}_fund -a --keyring-backend test --home ${workspace}/.local/sp${i})")
spseal_addr=("$(${bin} keys show sp${i}_seal -a --keyring-backend test --home ${workspace}/.local/sp${i})")
spapproval_addr=("$(${bin} keys show sp${i}_approval -a --keyring-backend test --home ${workspace}/.local/sp${i})")
${bin} add-genesis-account $sp_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0
${bin} add-genesis-account $sp_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0
${bin} add-genesis-account $spfund_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0
${bin} add-genesis-account $spseal_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0
${bin} add-genesis-account $spseal_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0
${bin} add-genesis-account $spapproval_addr ${GENESIS_ACCOUNT_BALANCE}${STAKING_BOND_DENOM} --home ${workspace}/.local/validator0
done

Expand Down Expand Up @@ -100,9 +100,10 @@ function generate_genesis() {
--commission-rate=${COMMISSION_RATE} \
--details="validator${i}" \
--website="http://website" \
--node tcp://localhost:$((${VALIDATOR_P2P_PORT_START}+${i})) \
--node tcp://localhost:$((${VALIDATOR_RPC_PORT_START}+${i})) \
--node-id "validator${i}" \
--ip 127.0.0.1
--ip 127.0.0.1 \
--gas ""
cp ${workspace}/.local/validator${i}/config/gentx/gentx-validator${i}.json ${workspace}/.local/gentx/
done

Expand Down Expand Up @@ -133,8 +134,7 @@ function generate_genesis() {
sed -i -e "s/\"reserve_time\": \"15552000\"/\"reserve_time\": \"600\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"forced_settle_time\": \"86400\"/\"forced_settle_time\": \"100\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/172800s/${DEPOSIT_VOTE_PERIOD}/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"10000000\"/\"${MIN_DEPOSIT_AMOUNT}\"/g" ${workspace}/.local/validator${i}/config/genesis.json

sed -i -e "s/\"10000000\"/\"${GOV_MIN_DEPOSIT_AMOUNT}\"/g" ${workspace}/.local/validator${i}/config/genesis.json
done

# enable swagger API for validator0
Expand Down Expand Up @@ -182,12 +182,12 @@ function sp_join() {
sp_addr=("$(${bin} keys show sp${i} -a --keyring-backend test --home ${workspace}/.local/sp${i})")
sleep 6
${bin} tx sp grant 0x7b5Fe22B5446f7C62Ea27B8BD71CeF94e03f3dF2 \
--spend-limit 1000000bnb \
--spend-limit 10000000000000000000000BNB \
--SPAddress "${sp_addr}" \
--from sp${i}_fund \
--home "${workspace}/.local/sp${i}" \
--keyring-backend test \
--node http://localhost:26750 \
--node http://localhost:${VALIDATOR_RPC_PORT_START} \
--yes
done

Expand All @@ -213,17 +213,17 @@ function sp_join() {
--from sp${i} \
--keyring-backend test \
--home ${workspace}/.local/sp${i} \
--node http://localhost:26750 \
--node http://localhost:${VALIDATOR_RPC_PORT_START} \
--broadcast-mode block \
--yes

sleep 6
# deposit the proposal
${bin} tx gov deposit $((${PROPOSAL_ID_START} + ${i})) 10000bnb \
${bin} tx gov deposit $((${PROPOSAL_ID_START} + ${i})) 1000000000000000000BNB \
--from sp${i} \
--keyring-backend test \
--home ${workspace}/.local/sp${i} \
--node http://localhost:26750 \
--node http://localhost:${VALIDATOR_RPC_PORT_START} \
--broadcast-mode block \
--yes

Expand All @@ -233,7 +233,7 @@ function sp_join() {
--from validator0 \
--keyring-backend test \
--home ${workspace}/.local/validator0 \
--node http://localhost:26750 \
--node http://localhost:${VALIDATOR_RPC_PORT_START} \
--broadcast-mode block \
--yes
sleep 1
Expand All @@ -248,7 +248,7 @@ function sp_check() {
# wait 360s , and then check the sp if ready
n=0
while [ $n -le 360 ]; do
cnt=("$(${bin} query sp storage-providers --node http://localhost:26750 | grep approval_address | wc -l)")
cnt=("$(${bin} query sp storage-providers --node http://localhost:${VALIDATOR_RPC_PORT_START} | grep approval_address | wc -l)")
((n++))
sleep 1
if [ "$cnt" -eq "$sp_size" ]; then
Expand All @@ -274,12 +274,12 @@ fi
case ${CMD} in
init)
echo "===== init ===="
init $SIZE
init $SIZE $SP_SIZE
echo "===== end ===="
;;
generate)
echo "===== generate genesis ===="
generate_genesis $SIZE
generate_genesis $SIZE $SP_SIZE
echo "===== end ===="
;;
start)
Expand Down Expand Up @@ -320,4 +320,4 @@ all)
# TODO: implement create sp in genesis use genesis transaction like validator.
echo "Usage: localup.sh all | init | generate | start | sp_join | sp_check | stop"
;;
esac
esac
8 changes: 4 additions & 4 deletions deployment/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ make build
2. Creates all the configuration files
```bash
# The argument <moniker> is the custom username of your node, it should be human-readable.
./build/bin/gnfd init <moniker> --chain-id greenfield_9000-01 --staking-bond-denom bnb
./build/bin/gnfd init <moniker> --chain-id greenfield_9000-01 --staking-bond-denom BNB
```

All these configuration files are in ~/.gnfd by default, but you can overwrite the location of this folder by passing the --home flag.
Expand Down Expand Up @@ -46,13 +46,13 @@ Before starting the chain, you need to populate the state with at least one acco
VALIDATOR=$(./build/bin/gnfd keys show validator -a --keyring-backend test)
RELAYER=$(./build/bin/gnfd keys show relayer -a --keyring-backend test)
RELAYER_BLS=$(./build/bin/gnfd keys show relayer --keyring-backend test --output json | jq -r .pubkey_hex)
./build/bin/gnfd add-genesis-account $VALIDATOR 100000000000bnb
./build/bin/gnfd add-genesis-account $VALIDATOR 100000000000000000000000000BNB
```

5. Create validator in genesis state
```bash
# create a gentx.
./build/bin/gnfd gentx validator 1000000000bnb $VALIDATOR $RELAYER $RELAYER_BLS --keyring-backend=test --chain-id=greenfield_9000-121 \
./build/bin/gnfd gentx validator 10000000000000000000000000BNB $VALIDATOR $RELAYER $RELAYER_BLS --keyring-backend=test --chain-id=greenfield_9000-121 \
--moniker="validator" \
--commission-max-change-rate=0.01 \
--commission-max-rate=1.0 \
Expand Down Expand Up @@ -81,7 +81,7 @@ bash ./deployment/localup/localup.sh stop

3. Send Tx
```bash
./build/bin/gnfd tx bank send validator0 0x32Ff14Fa1547314b95991976DB432F9Aa648A423 500bnb --home ./deployment/localup/.local/validator0 --keyring-backend test --node http://localhost:26750 -b block
./build/bin/gnfd tx bank send validator0 0x32Ff14Fa1547314b95991976DB432F9Aa648A423 500000000000000000000BNB --home ./deployment/localup/.local/validator0 --keyring-backend test --node http://localhost:26750 -b block
```

4. Restart the chain without state initialization
Expand Down
Loading

0 comments on commit 31f8d4e

Please sign in to comment.