Skip to content

Commit

Permalink
Merge pull request #78 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: draft release v0.0.6
  • Loading branch information
unclezoro authored Feb 24, 2023
2 parents 5b72432 + e4a7ccf commit 34e4430
Show file tree
Hide file tree
Showing 194 changed files with 62,695 additions and 7,844 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CGO_CFLAGS="-O -D__BLST_PORTABLE__"
CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"
13 changes: 10 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ jobs:
- name: Build
run: |
make build
- name: Env modify
run: |
sed -i 's/DEPOSIT_VOTE_PERIOD=300s/DEPOSIT_VOTE_PERIOD=60s/g' ./deployment/localup/.env
cat ./deployment/localup/.env
- name: run local chain
run: bash ./deployment/localup/localup.sh all 1
- name: run cli test
run: bash ./e2e/cli_test.sh
run: bash ./deployment/localup/localup.sh all 1 1
- name: check sp
run: bash ./deployment/localup/localup.sh sp_check 1 1
- name: run e2e test
run: |
make e2e_test
52 changes: 52 additions & 0 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: gosec

on:
push:
branches:
- main
- develop
pull_request:
branches:
- master
- develop
jobs:
gosec:
name: gosec
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_SECRET }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: Setup GitHub Token
run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: |
go mod tidy
go mod download
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -quiet -confidence high -severity high ./...
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## v0.0.6
This release includes following features:
1. Support cross chain governance;
2. Storage module improvement;
3. Add e2e test framework and swagger API script;

* [\#76](https://github.com/bnb-chain/greenfield/pull/76) feat: update tx simulation in sdk
* [\#63](https://github.com/bnb-chain/greenfield/pull/63) feat: enable params change proposal for cross chain governance
* [\#74](https://github.com/bnb-chain/greenfield/pull/74) docs: local network
* [\#72](https://github.com/bnb-chain/greenfield/pull/72) doc: add overview and tutorial doc for governance
* [\#73](https://github.com/bnb-chain/greenfield/pull/73) doc: add doc for the bridge module
* [\#71](https://github.com/bnb-chain/greenfield/pull/71) docs: add consensus and staking part
* [\#69](https://github.com/bnb-chain/greenfield/pull/69) ci: add gosec checker
* [\#65](https://github.com/bnb-chain/greenfield/pull/65) docs: add the key management docs and keyring module tutorial
* [\#66](https://github.com/bnb-chain/greenfield/pull/66) feat: add decimals of BNB and gweiBNB and e2e test of gashub module
* [\#67](https://github.com/bnb-chain/greenfield/pull/67) docs: add the overview of architecture && cross chain
* [\#64](https://github.com/bnb-chain/greenfield/pull/64) feat: sdk gas price simulation
* [\#57](https://github.com/bnb-chain/greenfield/pull/57) feat: storage module improvement
* [\#53](https://github.com/bnb-chain/greenfield/pull/53) feat: add init function for gashub module
* [\#60](https://github.com/bnb-chain/greenfield/pull/60) fix: unify denom as BNB
* [\#62](https://github.com/bnb-chain/greenfield/pull/62) refactor: rewrite the NewGreenfieldClient function by option pattern
* [\#58](https://github.com/bnb-chain/greenfield/pull/58) docs: add the token economics docs and bank module tutorial
* [\#59](https://github.com/bnb-chain/greenfield/pull/59) feat: gov RegisterInterfaces for sdk
* [\#54](https://github.com/bnb-chain/greenfield/pull/54) feat: Add deploy scripts for sp
* [\#48](https://github.com/bnb-chain/greenfield/pull/48) feat: add go-sdk and e2e test framework
* [\#56](https://github.com/bnb-chain/greenfield/pull/56) docs: build the framework of docs
* [\#49](https://github.com/bnb-chain/greenfield/pull/49) feat: Add event for storage module
* [\#55](https://github.com/bnb-chain/greenfield/pull/55) feat: enable swagger api for local deployment
* [\#51](https://github.com/bnb-chain/greenfield/pull/51) feat: added proto-gen-swagger for both greenfield and cosmos-sdk
* [\#44](https://github.com/bnb-chain/greenfield/pull/44) feat: add payment to storage module
* [\#47](https://github.com/bnb-chain/greenfield/pull/47) feat: add config for cross chain in env


## v0.0.5
This release includes features, mainly:
1. Implement payment module;
Expand Down
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: build build-linux build-macos build-windows
.PHONY: tools proto-gen proto-format test
.PHONY: tools proto-gen proto-format test e2e_test ci lint

VERSION=$(shell git describe --tags --always)
GIT_COMMIT=$(shell git rev-parse HEAD)
Expand All @@ -12,6 +12,8 @@ ldflags = -X $(REPO)/version.AppVersion=$(VERSION) \
-X $(REPO)/version.GitCommit=$(GIT_COMMIT) \
-X $(REPO)/version.GitCommitDate=$(GIT_COMMIT_DATE)

include .env

format:
bash scripts/format.sh

Expand All @@ -21,15 +23,30 @@ tools:
proto-gen:
cd proto && buf generate && cp -r github.com/bnb-chain/greenfield/x/* ../x && rm -rf github.com

proto-swagger-gen:
sh ./scripts/protoc-swagger-gen.sh

proto-format:
buf format -w

proto-format-check:
buf format --diff --exit-code

build:
CGO_CFLAGS="-O -D__BLST_PORTABLE__" CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" go build -o build/bin/gnfd -ldflags="$(ldflags)" ./cmd/gnfd/main.go
go build -o build/bin/gnfd -ldflags="$(ldflags)" ./cmd/gnfd/main.go

docker-image:
go mod vendor # temporary, should be removed after open source
docker build . -t ${IMAGE_NAME}

test:
go test ./...
go test $$(go list ./... | grep -v e2e | grep -v sdk)

e2e_test:
go test ./e2e/...

lint:
golangci-lint run --fix

ci: proto-format-check build test e2e_test lint
echo "ci passed"
2 changes: 1 addition & 1 deletion app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgSubmitProposalV1(from sd
msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal(
[]sdk.Msg{msgCreate},
sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20))},
sdk.ValAddress(from.Bytes()).String(),
sdk.AccAddress(from.Bytes()).String(),
"test",
)
suite.Require().NoError(err)
Expand Down
56 changes: 34 additions & 22 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 @@ -302,6 +305,16 @@ func New(
tkeys[paramstypes.TStoreKey],
)

app.CrossChainKeeper = crosschainkeeper.NewKeeper(
appCodec,
keys[crosschaintypes.StoreKey],
app.GetSubspace(crosschaintypes.ModuleName),
)
app.ParamsKeeper.SetCrossChainKeeper(app.CrossChainKeeper)
if err := app.ParamsKeeper.RegisterCrossChainSyncParamsApp(); err != nil {
panic(err)
}

// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))

Expand Down Expand Up @@ -355,12 +368,6 @@ func New(
app.GetSubspace(slashingtypes.ModuleName),
)

app.CrossChainKeeper = crosschainkeeper.NewKeeper(
appCodec,
keys[crosschaintypes.StoreKey],
app.GetSubspace(crosschaintypes.ModuleName),
)

app.OracleKeeper = oraclekeeper.NewKeeper(
appCodec,
keys[crosschaintypes.StoreKey],
Expand Down Expand Up @@ -461,7 +468,9 @@ func New(
keys[storagemoduletypes.StoreKey],
keys[storagemoduletypes.MemStoreKey],
app.GetSubspace(storagemoduletypes.ModuleName),
app.AccountKeeper,
app.SpKeeper,
app.PaymentKeeper,
)
storageModule := storagemodule.NewAppModule(appCodec, app.StorageKeeper, app.AccountKeeper, app.BankKeeper, app.SpKeeper)

Expand Down Expand Up @@ -612,9 +621,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 @@ -633,6 +639,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 @@ -641,27 +650,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 @@ -673,6 +679,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 All @@ -697,6 +709,7 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
// init cross chain channel permissions
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestChainId), bridgemoduletypes.TransferOutChannelID, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestChainId), bridgemoduletypes.TransferInChannelID, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestChainId), bridgemoduletypes.SyncParamsChannelID, sdk.ChannelAllow)

return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}
Expand Down Expand Up @@ -788,8 +801,8 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register app's OpenAPI routes.
apiSvr.Router.Handle("/static/openapi.yml", http.FileServer(http.FS(docs.Docs)))
apiSvr.Router.HandleFunc("/", openapiconsole.Handler(Name, "/static/openapi.yml"))
apiSvr.Router.Handle("/static/swagger.yaml", http.FileServer(http.FS(docs.Docs)))
apiSvr.Router.HandleFunc("/", openapiconsole.Handler(Name, "/static/swagger.yaml"))
}

// RegisterTxService implements the Application.RegisterTxService method.
Expand Down Expand Up @@ -834,7 +847,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(paymentmoduletypes.ModuleName)
paramsKeeper.Subspace(storagemoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
}

Expand Down
14 changes: 7 additions & 7 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ import (
type AppConfig struct {
serverconfig.Config

CrossChain CrossChainConfig `mapstructure:"cross_chain"`
CrossChain CrossChainConfig `mapstructure:"cross-chain"`
}

type CrossChainConfig struct {
SrcChainId uint32 `mapstructure:"src_chain_id"`
SrcChainId uint32 `mapstructure:"src-chain-id"`

DestChainId uint32 `mapstructure:"dest_chain_id"`
DestChainId uint32 `mapstructure:"dest-chain-id"`
}

var CustomAppTemplate = serverconfig.DefaultConfigTemplate + `
###############################################################################
### CrossChain Config ###
###############################################################################
[cross_chain]
[cross-chain]
# chain-id for current chain
src_chain_id = {{ .CrossChain.SrcChainId }}
src-chain-id = {{ .CrossChain.SrcChainId }}
# chain-id for destination chain(bsc)
dest_chain_id = {{ .CrossChain.DestChainId }}
dest-chain-id = {{ .CrossChain.DestChainId }}
`

func NewDefaultAppConfig() *AppConfig {
Expand All @@ -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" // 1gei

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
Loading

0 comments on commit 34e4430

Please sign in to comment.