From 715a8f5f95492954ca223000bdba8e2d7c8460db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:24:32 +0900 Subject: [PATCH 1/4] chore(deps): Bump github.com/spf13/cobra from 1.6.0 to 1.6.1 (#750) Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](https://github.com/spf13/cobra/compare/v1.6.0...v1.6.1) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 134340af6c..fa4e4d4597 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/regen-network/cosmos-proto v0.3.1 github.com/rs/zerolog v1.28.0 github.com/spf13/cast v1.5.0 - github.com/spf13/cobra v1.6.0 + github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.13.0 github.com/stretchr/testify v1.8.1 diff --git a/go.sum b/go.sum index b127b64c22..e0fd68b946 100644 --- a/go.sum +++ b/go.sum @@ -1110,8 +1110,8 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= -github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= -github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= +github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= From d0bc22b9db7bc7f0168ca87ec2d4dd38b9fc74e1 Mon Sep 17 00:00:00 2001 From: Sujong Lee Date: Wed, 26 Oct 2022 11:58:25 +0900 Subject: [PATCH 2/4] docs: add govmint to x/foundation specification (#748) * docs: add govmint to x/foundation specification * docs: apply pr review --- CHANGELOG.md | 1 + x/foundation/README.md | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df0ba6f6b5..3b50bb8381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,3 +145,4 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (docs) [\#490](https://github.com/line/lbm-sdk/pull/490) update documents on x/consortium * (docs) [\#602](https://github.com/line/lbm-sdk/pull/602) update outdated events in specs * (docs) [\#721](https://github.com/line/lbm-sdk/pull/721) update x/foundation specification +* (docs) [\#748](https://github.com/line/lbm-sdk/pull/748) add `GovMint` to x/foundation specification diff --git a/x/foundation/README.md b/x/foundation/README.md index 16c17b437d..1f5c69a1a1 100644 --- a/x/foundation/README.md +++ b/x/foundation/README.md @@ -31,6 +31,7 @@ back these foundation-specific functionalities. * [Msg/Revoke](#msgrevoke) * [Msg/FundTreasury](#msgfundtreasury) * [Msg/WithdrawFromTreasury](#msgwithdrawfromtreasury) + * [Msg/GovMint](#msggovmint) * [Events](#events) * [EventUpdateFoundationParams](#eventupdatefoundationparams) * [EventUpdateDecisionPolicy](#eventupdatedecisionpolicy) @@ -44,6 +45,7 @@ back these foundation-specific functionalities. * [EventRevoke](#eventrevoke) * [EventFundTreasury](#eventfundedtreasury) * [EventWithdrawFromTreasury](#eventwithdrawedfromtreasury) + * [EventGovMint](#eventgovmint) * [Client](#client) * [CLI](#cli) * [gRPC](#grpc) @@ -262,6 +264,12 @@ sending the message `Msg/WithdrawFromTreasury`. value again (irreversible), which means you must set it to a non-zero value in the genesis to make it work. +## GovMint + +When the chain is first started, it may be necessary to mint a large amount of +coins at most once for initial validators or for specific purposes. Newly minted +coins are transferred to the treasury pool. + # State ## Params @@ -476,7 +484,7 @@ Anyone can fund treasury with `MsgFundTreasury`. +++ https://github.com/line/lbm-sdk/blob/392277a33519d289154e8da27f05f9a6788ab076/proto/lbm/foundation/v1/tx.proto#L76-L81 -## Msg/WithdrawFromTresury +## Msg/WithdrawFromTreasury The foundation can withdraw coins from the treasury with `MsgWithdrawFromTreasury`. @@ -489,6 +497,17 @@ The message handling should fail if: * the address which receives the coins has no authorization of `ReceiveFromTreasuryAuthorization`. +## Msg/GovMint + +Massive minting is possible through 'MsgGovMint' up to 1 time after the chain is started. + ++++ https://github.com/line/lbm-sdk/blob/66988a235a0e01f7a1ee76d719d585ff35f0d176/proto/lbm/foundation/v1/tx.proto#L221-L225 + +The message handling should fail if: + +* the authority is not the module's authority. +* The remaining left count is 0. + # Events ## EventUpdateFoundationParams @@ -598,6 +617,14 @@ the treasury. | to | {toAddress} | | amount | {amount} | +## EventGovMint + +`EventGovMint` is an event emitted when coins are minted. + +| Attribute Key | Attribute Value | +|---------------|-----------------| +| amount | {amount} | + # Client ## CLI From ea17c5a2e543dd294c18a922cc78a25f6783917c Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Wed, 26 Oct 2022 03:35:47 +0000 Subject: [PATCH 3/4] fix: add x/distribution's module account into blockedAddr (#752) * Fix the whitelist * Revert the divergence in the tests * Update CHANGELOG.md --- CHANGELOG.md | 1 + simapp/app.go | 2 +- x/bank/keeper/genesis_test.go | 2 +- x/bank/simulation/operations_test.go | 12 ++++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b50bb8381..a68230d594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/foundation) [\#730](https://github.com/line/lbm-sdk/pull/730) prune stale x/foundation proposals at voting period end * (cli) [\#734](https://github.com/line/lbm-sdk/pull/734) add restrictions on the number of args in the CLIs * (client) [\#737](https://github.com/line/lbm-sdk/pull/737) check multisig key list to prevent unexpected key deletion +* (simapp) [\#752](https://github.com/line/lbm-sdk/pull/752) add x/distribution's module account into blockedAddr ### Breaking Changes * (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path diff --git a/simapp/app.go b/simapp/app.go index 4b6346141f..feacad8440 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -191,7 +191,7 @@ var ( // module accounts that are allowed to receive tokens allowedReceivingModAcc = map[string]bool{ - distrtypes.ModuleName: true, + // govtypes.ModuleName: true, // TODO: uncomment it when authority is ready } ) diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 9d35e6cb5d..797b93d88d 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -39,7 +39,7 @@ func (suite *IntegrationTestSuite) TestExportGenesis() { func (suite *IntegrationTestSuite) getTestBalancesAndSupply() ([]types.Balance, sdk.Coins) { addr2, _ := sdk.AccAddressFromBech32("link1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0p662v8") - addr1, _ := sdk.AccAddressFromBech32("link1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8j3y7jh") // distribution module address + addr1, _ := sdk.AccAddressFromBech32("link1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehndz0n9") addr1Balance := sdk.Coins{sdk.NewInt64Coin("testcoin3", 10)} addr2Balance := sdk.Coins{sdk.NewInt64Coin("testcoin1", 32), sdk.NewInt64Coin("testcoin2", 34)} diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index bba4a6d862..1f03d5b447 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -143,13 +143,13 @@ func (suite *SimTestSuite) TestSimulateModuleAccountMsgSend() { r = rand.New(s) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") - suite.Require().NoError(err) + suite.Require().Error(err) var msg types.MsgSend types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) - suite.Require().True(operationMsg.OK) - suite.Require().Empty(operationMsg.Comment) + suite.Require().False(operationMsg.OK) + suite.Require().Equal(operationMsg.Comment, "invalid transfers") suite.Require().Equal(types.TypeMsgSend, msg.Type()) suite.Require().Equal(types.ModuleName, msg.Route()) suite.Require().Len(futureOperations, 0) @@ -173,13 +173,13 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSendToModuleAccount() { op := simulation.SimulateMsgMultiSendToModuleAccount(suite.app.AccountKeeper, suite.app.BankKeeper, mAccCount) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") - suite.Require().NoError(err) + suite.Require().Error(err) var msg types.MsgMultiSend types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) - suite.Require().True(operationMsg.OK) // sending tokens to a module account should fail - suite.Require().Empty(operationMsg.Comment) + suite.Require().False(operationMsg.OK) // sending tokens to a module account should fail + suite.Require().Equal(operationMsg.Comment, "invalid transfers") suite.Require().Equal(types.TypeMsgMultiSend, msg.Type()) suite.Require().Equal(types.ModuleName, msg.Route()) suite.Require().Len(futureOperations, 0) From eb1b5e2f9d7dc873aa30e7266d07118312a43a20 Mon Sep 17 00:00:00 2001 From: zemyblue Date: Wed, 26 Oct 2022 14:09:53 +0900 Subject: [PATCH 4/4] feat: change to create `chCheckTx` with the value set in app config. (#756) * feat: add `chCheckTxSize` configuration of Baseapp Signed-off-by: zemyblue * chore: add unittest Signed-off-by: zemyblue * chore: update changelog Signed-off-by: zemyblue * chore: fix typo and add more description Signed-off-by: zemyblue * chore: correct ambiguous sentences Signed-off-by: zemyblue Signed-off-by: zemyblue --- CHANGELOG.md | 1 + baseapp/baseapp.go | 9 ++++++++- baseapp/baseapp_test.go | 17 +++++++++++++++++ baseapp/options.go | 14 ++++++++++++-- server/config/config.go | 8 ++++++++ server/config/toml.go | 4 ++++ server/start.go | 3 +++ simapp/simd/cmd/root.go | 1 + 8 files changed, 54 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a68230d594..76ebfb1fbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (config) [\#665](https://github.com/line/lbm-sdk/pull/665) remove bech32-cache-size * (x/foundation) [\#709](https://github.com/line/lbm-sdk/pull/709) add `gov mint` for x/foundation proposal * (iavl) [\#738](https://github.com/line/lbm-sdk/pull/738) bump github.com/cosmos/iavl from v0.17.3 to v0.19.3 +* (baseapp) [\#756](https://github.com/line/lbm-sdk/pull/756) Change to create chCheckTx with the value set in app config ### Improvements diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 0e2ccbe649..356c586f24 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -16,6 +16,7 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/line/lbm-sdk/codec/types" + "github.com/line/lbm-sdk/server/config" "github.com/line/lbm-sdk/snapshots" "github.com/line/lbm-sdk/store" "github.com/line/lbm-sdk/store/rootmulti" @@ -75,6 +76,7 @@ type BaseApp struct { // nolint: maligned checkAccountWGs *AccountWGs chCheckTx chan *RequestCheckTxAsync + chCheckTxSize uint // chCheckTxSize is the initial size for chCheckTx // an inter-block write-through cache provided to the context during deliverState interBlockCache sdk.MultiStorePersistentCache @@ -153,13 +155,18 @@ func NewBaseApp( txDecoder: txDecoder, fauxMerkleMode: false, checkAccountWGs: NewAccountWGs(), - chCheckTx: make(chan *RequestCheckTxAsync, 10000), // TODO config channel buffer size. It might be good to set it tendermint mempool.size } for _, option := range options { option(app) } + chCheckTxSize := app.chCheckTxSize + if chCheckTxSize == 0 { + chCheckTxSize = config.DefaultChanCheckTxSize + } + app.chCheckTx = make(chan *RequestCheckTxAsync, chCheckTxSize) + if app.interBlockCache != nil { app.cms.SetInterBlockCache(app.interBlockCache) } diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index cec1cc826e..8e3d6587c3 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -22,6 +22,7 @@ import ( "github.com/line/lbm-sdk/codec" "github.com/line/lbm-sdk/codec/legacy" + "github.com/line/lbm-sdk/server/config" "github.com/line/lbm-sdk/snapshots" snapshottypes "github.com/line/lbm-sdk/snapshots/types" "github.com/line/lbm-sdk/store/rootmulti" @@ -542,6 +543,9 @@ func TestBaseAppOptionSeal(t *testing.T) { require.Panics(t, func() { app.SetRouter(NewRouter()) }) + require.Panics(t, func() { + app.SetChanCheckTxSize(10) + }) } func TestSetMinGasPrices(t *testing.T) { @@ -2069,3 +2073,16 @@ func TestSnapshotManager(t *testing.T) { app.SetSnapshotStore(snapshotStore) require.NotNil(t, app.SnapshotManager()) } + +func TestSetChanCheckTxSize(t *testing.T) { + logger := defaultLogger() + db := dbm.NewMemDB() + + var size = uint(100) + + app := NewBaseApp(t.Name(), logger, db, nil, SetChanCheckTxSize(size)) + require.Equal(t, int(size), cap(app.chCheckTx)) + + app = NewBaseApp(t.Name(), logger, db, nil) + require.Equal(t, config.DefaultChanCheckTxSize, cap(app.chCheckTx)) +} diff --git a/baseapp/options.go b/baseapp/options.go index 14b3301ae8..ecc3e7643a 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -6,11 +6,10 @@ import ( dbm "github.com/tendermint/tm-db" - "github.com/line/lbm-sdk/store/cache" - "github.com/line/lbm-sdk/codec/types" "github.com/line/lbm-sdk/snapshots" "github.com/line/lbm-sdk/store" + "github.com/line/lbm-sdk/store/cache" sdk "github.com/line/lbm-sdk/types" ) @@ -90,6 +89,10 @@ func SetSnapshotStore(snapshotStore *snapshots.Store) func(*BaseApp) { return func(app *BaseApp) { app.SetSnapshotStore(snapshotStore) } } +func SetChanCheckTxSize(size uint) func(*BaseApp) { + return func(app *BaseApp) { app.SetChanCheckTxSize(size) } +} + func (app *BaseApp) SetName(name string) { if app.sealed { panic("SetName() on sealed BaseApp") @@ -250,6 +253,13 @@ func (app *BaseApp) SetInterfaceRegistry(registry types.InterfaceRegistry) { app.msgServiceRouter.SetInterfaceRegistry(registry) } +func (app *BaseApp) SetChanCheckTxSize(chanCheckTxSize uint) { + if app.sealed { + panic("SetChanCheckTxSize() on sealed BaseApp") + } + app.chCheckTxSize = chanCheckTxSize +} + func MetricsProvider(prometheus bool) cache.MetricsProvider { namespace := "app" if prometheus { diff --git a/server/config/config.go b/server/config/config.go index 810c46cfaf..c37d1a3641 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -23,6 +23,9 @@ const ( // DefaultGRPCWebAddress defines the default address to bind the gRPC-web server to. DefaultGRPCWebAddress = "0.0.0.0:9091" + + // DefaultChanCheckTxSize defines the default size of channel check tx in Baseapp + DefaultChanCheckTxSize = 10000 ) // BaseConfig defines the server's basic configuration @@ -85,6 +88,9 @@ type BaseConfig struct { // When true, Prometheus metrics are served under /metrics on prometheus_listen_addr in config.toml. // It works when tendermint's prometheus option (config.toml) is set to true. Prometheus bool `mapstructure:"prometheus"` + + // ChanCheckTxSize is the size of RequestCheckTxAsync of BaseApp + ChanCheckTxSize uint `mapstructure:"chan-check-tx-size"` } // APIConfig defines the API listener configuration. @@ -231,6 +237,7 @@ func DefaultConfig() *Config { PruningInterval: "0", MinRetainBlocks: 0, IndexEvents: make([]string, 0), + ChanCheckTxSize: DefaultChanCheckTxSize, }, Telemetry: telemetry.Config{ Enabled: false, @@ -294,6 +301,7 @@ func GetConfig(v *viper.Viper) Config { MinRetainBlocks: v.GetUint64("min-retain-blocks"), IAVLDisableFastNode: v.GetBool("iavl-disable-fastnode"), IAVLCacheSize: v.GetUint64("iavl-cache-size"), + ChanCheckTxSize: v.GetUint("chan-check-tx-size"), }, Telemetry: telemetry.Config{ ServiceName: v.GetString("telemetry.service-name"), diff --git a/server/config/toml.go b/server/config/toml.go index d6a4d23946..8598dbf608 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -86,6 +86,10 @@ index-events = {{ .BaseConfig.IndexEvents }} # It works when tendermint's prometheus option (config.toml) is set to true. prometheus = {{ .BaseConfig.Prometheus }} +# ChanCheckTxSize is the size of RequestCheckTxAsync of BaseApp. +# ChanCheckTxSize should be equals to or greater than the mempool size set in config.toml of Ostracon. +chan-check-tx-size = {{ .BaseConfig.ChanCheckTxSize }} + ############################################################################### ### Telemetry Configuration ### ############################################################################### diff --git a/server/start.go b/server/start.go index bb18d72408..763c9507ba 100644 --- a/server/start.go +++ b/server/start.go @@ -52,6 +52,7 @@ const ( FlagTrace = "trace" FlagInvCheckPeriod = "inv-check-period" FlagPrometheus = "prometheus" + FlagChanCheckTxSize = "chan-check-tx-size" FlagPruning = "pruning" FlagPruningKeepRecent = "pruning-keep-recent" @@ -175,6 +176,8 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. cmd.Flags().Bool(FlagPrometheus, false, "Enable prometheus metric for app") + cmd.Flags().Uint(FlagChanCheckTxSize, config.DefaultChanCheckTxSize, "The size of the channel check tx") + // add support for all Ostracon-specific command line options ostcmd.AddNodeFlags(cmd) return cmd diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 7797f70f56..3bfacbdfe5 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -287,6 +287,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a baseapp.SetSnapshotStore(snapshotStore), baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))), baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))), + baseapp.SetChanCheckTxSize(cast.ToUint(appOpts.Get(server.FlagChanCheckTxSize))), ) }