Skip to content

Commit

Permalink
Merge pull request #345 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare release for v0.2.3-alpha.5
  • Loading branch information
unclezoro committed Jul 13, 2023
2 parents fd31a4e + 30cf369 commit d3bebb2
Show file tree
Hide file tree
Showing 244 changed files with 36,869 additions and 6,413 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## v0.2.3-alpha.5
This release adds 6 new features and 2 bugfixes.

Features
* [#315](https://github.com/bnb-chain/greenfield/pull/315) feat: add api for querying lock fee
* [#290](https://github.com/bnb-chain/greenfield/pull/290) feat: replace rlp with abi.encode in cross-chain transfer
* [#323](https://github.com/bnb-chain/greenfield/pull/323) feat: enable asset reconciliation
* [#326](https://github.com/bnb-chain/greenfield/pull/326) feat: add bls verification
* [#336](https://github.com/bnb-chain/greenfield/pull/336) feat: add tendermint to sdk
* [#341](https://github.com/bnb-chain/greenfield/pull/341) feat: support cross chain for multiple blockchains
* [#328](https://github.com/bnb-chain/greenfield/pull/328) feat: refactor for sp exit and bucket migrate

Bugfixes
* [#307](https://github.com/bnb-chain/greenfield/pull/307) fix DefaultMaxPayloadSize from 2GB to 64GB
* [#312](https://github.com/bnb-chain/greenfield/pull/312) fix: add chainid to sign bytes to prevent replay attack

Documentation
* [#316](https://github.com/bnb-chain/greenfield/pull/316) Update readme.md
* [#282](https://github.com/bnb-chain/greenfield/pull/282) update readme for helm deployment

Chores
* [#324](https://github.com/bnb-chain/greenfield/pull/324) chore: update greenfield-cometbft-db version

## v0.2.3-alpha.2
This release enables 2 new features:

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ proto-format-check:
build:
go build -o build/bin/gnfd -ldflags="$(ldflags)" ./cmd/gnfd/main.go

mock-gen:
sh ./scripts/mockgen.sh

docker-image:
go mod vendor # temporary, should be removed after open source
docker build . -t ${IMAGE_NAME}
Expand Down
18 changes: 10 additions & 8 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/prysmaticlabs/prysm/crypto/bls"
"github.com/stretchr/testify/suite"

"github.com/bnb-chain/greenfield/app"
Expand All @@ -44,6 +43,7 @@ import (
"github.com/bnb-chain/greenfield/e2e/core"
"github.com/bnb-chain/greenfield/sdk/client/test"
"github.com/bnb-chain/greenfield/sdk/keys"
"github.com/bnb-chain/greenfield/testutil/sample"
)

type AnteTestSuite struct {
Expand Down Expand Up @@ -96,8 +96,7 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgDelegate(from sdk.AccAdd

func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder {
privEd := ed25519.GenPrivKey()
blsSecretKey, _ := bls.RandKey()
blsPubkey := hex.EncodeToString(blsSecretKey.PublicKey().Marshal())
blsPubKey, blsProof := sample.RandBlsPubKeyAndBlsProof()
msgCreate, err := stakingtypes.NewMsgCreateValidator(
from,
privEd.PubKey(),
Expand All @@ -109,7 +108,8 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator(from sdk.AccAddre
from,
from,
from,
blsPubkey,
blsPubKey,
blsProof,
)
suite.Require().NoError(err)
return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgCreate)
Expand Down Expand Up @@ -140,16 +140,16 @@ func (suite *AnteTestSuite) CreateTestEIP712GrantAllowance(from sdk.AccAddress,
func (suite *AnteTestSuite) CreateTestEIP712MsgEditValidator(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder {
newRelayerAddr := core.GenRandomAddr()
newChallengerAddr := core.GenRandomAddr()
blsSecretKey, _ := bls.RandKey()
blsPk := hex.EncodeToString(blsSecretKey.PublicKey().Marshal())
blsPubKey, blsProof := sample.RandBlsPubKeyAndBlsProof()
msgEdit := stakingtypes.NewMsgEditValidator(
from,
stakingtypes.NewDescription("moniker", "identity", "website", "security_contract", "details"),
nil,
nil,
newRelayerAddr,
newChallengerAddr,
blsPk,
blsPubKey,
blsProof,
)
return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgEdit)
}
Expand All @@ -169,6 +169,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgSubmitEvidence(from sdk.AccAddres

func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgSubmitProposalV1(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder {
privEd := ed25519.GenPrivKey()
blsPubKey, blsProof := sample.RandBlsPubKeyAndBlsProof()
msgCreate, err := stakingtypes.NewMsgCreateValidator(
from,
privEd.PubKey(),
Expand All @@ -180,7 +181,8 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgSubmitProposalV1(from sd
from,
from,
from,
"test",
blsPubKey,
blsProof,
)
suite.Require().NoError(err)
msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal(
Expand Down
78 changes: 60 additions & 18 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/store/iavl"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -106,6 +107,9 @@ import (
storagemodule "github.com/bnb-chain/greenfield/x/storage"
storagemodulekeeper "github.com/bnb-chain/greenfield/x/storage/keeper"
storagemoduletypes "github.com/bnb-chain/greenfield/x/storage/types"
virtualgroupmodule "github.com/bnb-chain/greenfield/x/virtualgroup"
virtualgroupmodulekeeper "github.com/bnb-chain/greenfield/x/virtualgroup/keeper"
virtualgroupmoduletypes "github.com/bnb-chain/greenfield/x/virtualgroup/types"
)

const (
Expand Down Expand Up @@ -157,22 +161,24 @@ var (
spmodule.AppModuleBasic{},
paymentmodule.AppModuleBasic{},
permissionmodule.AppModuleBasic{},
virtualgroupmodule.AppModuleBasic{},
storagemodule.AppModuleBasic{},
challengemodule.AppModuleBasic{},
)

// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
paymentmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
crosschaintypes.ModuleName: {authtypes.Minter},
permissionmoduletypes.ModuleName: nil,
bridgemoduletypes.ModuleName: nil,
spmoduletypes.ModuleName: {authtypes.Staking},
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
paymentmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
crosschaintypes.ModuleName: {authtypes.Minter},
permissionmoduletypes.ModuleName: nil,
bridgemoduletypes.ModuleName: nil,
spmoduletypes.ModuleName: {authtypes.Staking},
virtualgroupmoduletypes.ModuleName: nil,
}
)

Expand Down Expand Up @@ -229,6 +235,7 @@ type App struct {
PaymentKeeper paymentmodulekeeper.Keeper
ChallengeKeeper challengemodulekeeper.Keeper
PermissionmoduleKeeper permissionmodulekeeper.Keeper
VirtualgroupKeeper virtualgroupmodulekeeper.Keeper
StorageKeeper storagemodulekeeper.Keeper

// mm is the module manager
Expand Down Expand Up @@ -283,10 +290,12 @@ func New(
bridgemoduletypes.StoreKey,
gashubtypes.StoreKey,
spmoduletypes.StoreKey,
virtualgroupmoduletypes.StoreKey,
paymentmoduletypes.StoreKey,
permissionmoduletypes.StoreKey,
storagemoduletypes.StoreKey,
challengemoduletypes.StoreKey,
reconStoreKey,
)
tKeys := sdk.NewTransientStoreKeys(challengemoduletypes.TStoreKey, storagemoduletypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(challengemoduletypes.MemStoreKey)
Expand Down Expand Up @@ -455,6 +464,18 @@ func New(
)
paymentModule := paymentmodule.NewAppModule(appCodec, app.PaymentKeeper, app.AccountKeeper, app.BankKeeper)

app.VirtualgroupKeeper = *virtualgroupmodulekeeper.NewKeeper(
appCodec,
keys[virtualgroupmoduletypes.StoreKey],
tKeys[virtualgroupmoduletypes.TStoreKey],
authtypes.NewModuleAddress(virtualgroupmoduletypes.ModuleName).String(),
app.SpKeeper,
app.AccountKeeper,
app.BankKeeper,
app.PaymentKeeper,
)
virtualgroupModule := virtualgroupmodule.NewAppModule(appCodec, app.VirtualgroupKeeper, app.SpKeeper)

app.PermissionmoduleKeeper = *permissionmodulekeeper.NewKeeper(
appCodec,
keys[permissionmoduletypes.StoreKey],
Expand All @@ -472,6 +493,7 @@ func New(
app.PaymentKeeper,
app.PermissionmoduleKeeper,
app.CrossChainKeeper,
app.VirtualgroupKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
storageModule := storagemodule.NewAppModule(appCodec, app.StorageKeeper, app.AccountKeeper, app.BankKeeper, app.SpKeeper)
Expand Down Expand Up @@ -519,6 +541,7 @@ func New(
bridgeModule,
gashubModule,
spModule,
virtualgroupModule,
paymentModule,
permissionModule,
storageModule,
Expand Down Expand Up @@ -547,6 +570,7 @@ func New(
bridgemoduletypes.ModuleName,
gashubtypes.ModuleName,
spmoduletypes.ModuleName,
virtualgroupmoduletypes.ModuleName,
paymentmoduletypes.ModuleName,
permissionmoduletypes.ModuleName,
storagemoduletypes.ModuleName,
Expand All @@ -571,6 +595,7 @@ func New(
bridgemoduletypes.ModuleName,
gashubtypes.ModuleName,
spmoduletypes.ModuleName,
virtualgroupmoduletypes.ModuleName,
paymentmoduletypes.ModuleName,
permissionmoduletypes.ModuleName,
storagemoduletypes.ModuleName,
Expand Down Expand Up @@ -600,6 +625,7 @@ func New(
oracletypes.ModuleName,
bridgemoduletypes.ModuleName,
spmoduletypes.ModuleName,
virtualgroupmoduletypes.ModuleName,
paymentmoduletypes.ModuleName,
permissionmoduletypes.ModuleName,
storagemoduletypes.ModuleName,
Expand Down Expand Up @@ -676,6 +702,18 @@ func New(
}
}

// enable diff for reconciliation
bankIavl, ok := ms.GetCommitStore(keys[banktypes.StoreKey]).(*iavl.Store)
if !ok {
tmos.Exit("cannot convert bank store to ival store")
}
bankIavl.EnableDiff()
paymentIavl, ok := ms.GetCommitStore(keys[paymentmoduletypes.StoreKey]).(*iavl.Store)
if !ok {
tmos.Exit("cannot convert payment store to ival store")
}
paymentIavl.EnableDiff()

app.initModules(ctx)

// add eth query router
Expand All @@ -695,7 +733,7 @@ func (app *App) initModules(ctx sdk.Context) {

func (app *App) initCrossChain() {
app.CrossChainKeeper.SetSrcChainID(sdk.ChainID(app.appConfig.CrossChain.SrcChainId))
app.CrossChainKeeper.SetDestChainID(sdk.ChainID(app.appConfig.CrossChain.DestChainId))
app.CrossChainKeeper.SetDestChainID(sdk.ChainID(app.appConfig.CrossChain.DestBscChainId))
}

func (app *App) initBridge() {
Expand All @@ -716,7 +754,11 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R

// EndBlocker application updates every end block
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
return app.mm.EndBlock(ctx, req)
resp := app.mm.EndBlock(ctx, req)
bankIavl, _ := app.CommitMultiStore().GetCommitStore(sdk.NewKVStoreKey(banktypes.StoreKey)).(*iavl.Store)
paymentIavl, _ := app.CommitMultiStore().GetCommitStore(sdk.NewKVStoreKey(paymentmoduletypes.StoreKey)).(*iavl.Store)
app.reconcile(ctx, bankIavl, paymentIavl)
return resp
}

// InitChainer application update at chain initialization
Expand All @@ -728,12 +770,12 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())

// 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)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestChainId), storagemoduletypes.BucketChannelId, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestChainId), storagemoduletypes.ObjectChannelId, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestChainId), storagemoduletypes.GroupChannelId, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestBscChainId), bridgemoduletypes.TransferOutChannelID, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestBscChainId), bridgemoduletypes.TransferInChannelID, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestBscChainId), bridgemoduletypes.SyncParamsChannelID, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestBscChainId), storagemoduletypes.BucketChannelId, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestBscChainId), storagemoduletypes.ObjectChannelId, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestBscChainId), storagemoduletypes.GroupChannelId, sdk.ChannelAllow)

return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}
Expand Down
10 changes: 5 additions & 5 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type AppConfig struct {
type CrossChainConfig struct {
SrcChainId uint32 `mapstructure:"src-chain-id"`

DestChainId uint32 `mapstructure:"dest-chain-id"`
DestBscChainId uint32 `mapstructure:"dest-bsc-chain-id"`
}

var CustomAppTemplate = serverconfig.DefaultConfigTemplate + `
Expand All @@ -23,8 +23,8 @@ var CustomAppTemplate = serverconfig.DefaultConfigTemplate + `
[cross-chain]
# chain-id for current chain
src-chain-id = {{ .CrossChain.SrcChainId }}
# chain-id for destination chain(bsc)
dest-chain-id = {{ .CrossChain.DestChainId }}
# chain-id for bsc destination chain
dest-bsc-chain-id = {{ .CrossChain.DestBscChainId }}
`

func NewDefaultAppConfig() *AppConfig {
Expand All @@ -46,8 +46,8 @@ func NewDefaultAppConfig() *AppConfig {
return &AppConfig{
Config: *srvCfg,
CrossChain: CrossChainConfig{
SrcChainId: 1,
DestChainId: 2,
SrcChainId: 1,
DestBscChainId: 2,
},
}
}
Loading

0 comments on commit d3bebb2

Please sign in to comment.