Skip to content

Commit

Permalink
feat: enable plain store for full node (#415)
Browse files Browse the repository at this point in the history
* feat: enable plain store for full node

* update dependency

* track begin/end block r/w used
  • Loading branch information
forcodedancing authored Aug 16, 2023
1 parent 02b1db7 commit 5a5336b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
33 changes: 20 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,17 +701,19 @@ 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")
if app.IsIavlStore() {
//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()
}
paymentIavl.EnableDiff()

app.initModules(ctx)

Expand Down Expand Up @@ -765,9 +767,14 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
ctx = ctx.WithValue(spmodule.LastBlockTimeKey, lastBlockTime)

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)
if app.IsIavlStore() {
bankIavl, _ := app.CommitMultiStore().GetCommitStore(sdk.NewKVStoreKey(banktypes.StoreKey)).(*iavl.Store)
paymentIavl, _ := app.CommitMultiStore().GetCommitStore(sdk.NewKVStoreKey(paymentmoduletypes.StoreKey)).(*iavl.Store)

reconCtx, _ := ctx.CacheContext()
reconCtx = reconCtx.WithGasMeter(sdk.NewInfiniteGasMeter())
app.reconcile(reconCtx, bankIavl, paymentIavl)
}
return resp
}

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 @@ -370,6 +370,7 @@ func (a appCreator) newApp(
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
baseapp.SetChainID(chainID),
baseapp.SetEnableUnsafeQuery(cast.ToBool(appOpts.Get(server.FlagEnableUnsafeQuery))),
baseapp.SetEnablePlainStore(cast.ToBool(appOpts.Get(server.FlagEnablePlainStore))),
)
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ replace (
cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9
cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.0-20230810120916-f5f3421ab490
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.0-20230815065708-123390673ba9
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230815013301-39bab6660f57
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230815071933-833c0d4721b4
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsy
github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/greenfield-cometbft v0.0.0-20230810120916-f5f3421ab490 h1:sztr3uiKE/iI8O6ccIb6Bc9b9K0GVJryPXMhWx6Xk/U=
github.com/bnb-chain/greenfield-cometbft v0.0.0-20230810120916-f5f3421ab490/go.mod h1:3nGT4Z9fHwgRlBY/rofn0rSarnIcNbuhz/eq0XlLlkg=
github.com/bnb-chain/greenfield-cometbft v0.0.0-20230815065708-123390673ba9 h1:cNBk5OONdlqg9tt1H/XTNIhz97v0DVBINFNi+wk/sfY=
github.com/bnb-chain/greenfield-cometbft v0.0.0-20230815065708-123390673ba9/go.mod h1:3nGT4Z9fHwgRlBY/rofn0rSarnIcNbuhz/eq0XlLlkg=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230815013301-39bab6660f57 h1:6N1CoLkGEOdldHchP/I7DsvRTiuoNFuy02ysyU5ZP3g=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230815013301-39bab6660f57/go.mod h1:C4iDO5NuIlmlyFsIqhItF1A6ouAwsZmn20LQ0YhE0Mg=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230815071933-833c0d4721b4 h1:iE5yATUWWXLElEK9vhYFfpPRBl0DQFg4elMz2YN5ZSQ=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.3.0.20230815071933-833c0d4721b4/go.mod h1:IGSt+LL/UIUEBzpy3AOdrs3wDsSKYeqUZDH0shyOFkg=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s=
Expand Down
12 changes: 12 additions & 0 deletions swagger/static/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29251,6 +29251,10 @@ paths:
min_gas_price:
type: string
description: MinGasPrice are the min gas price.
rw_used:
type: string
format: uint64
description: RWUsed is the amount of r/w actually consumed.
result:
description: result is the result of the simulation.
type: object
Expand Down Expand Up @@ -51990,6 +51994,10 @@ definitions:
min_gas_price:
type: string
description: MinGasPrice are the min gas price.
rw_used:
type: string
format: uint64
description: RWUsed is the amount of r/w actually consumed.
description: GasInfo defines tx execution gas context.
cosmos.base.abci.v1beta1.Result:
type: object
Expand Down Expand Up @@ -54816,6 +54824,10 @@ definitions:
min_gas_price:
type: string
description: MinGasPrice are the min gas price.
rw_used:
type: string
format: uint64
description: RWUsed is the amount of r/w actually consumed.
result:
description: result is the result of the simulation.
type: object
Expand Down

0 comments on commit 5a5336b

Please sign in to comment.