Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cherry pick upgrade #365

Merged
merged 70 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3d7d984
Add liquidity provider fee pool
RavenXce Nov 6, 2020
94e24c9
Add deliver tx and before commit hooks
leeyikjiun Jun 8, 2021
be66cc5
Implements Valuer and Scanner interface for Int and Dec
leeyikjiun Jun 14, 2021
0ac2500
Add after committer hook
leeyikjiun Jul 8, 2021
1ee819a
Add liquidity provider fee pool to module account invariant
leeyikjiun Aug 31, 2021
6f894ea
Add liquidity provider fee pool to distribution genesis check
leeyikjiun Nov 22, 2021
f1c7347
Revert "Emit anthandler events even if txn fails or panics"
leeyikjiun Feb 7, 2022
4506e2e
Fix deliverTxer not including ante events on failed txns
leeyikjiun Feb 7, 2022
ec1df3b
Change authz module name from const to var
leeyikjiun Feb 15, 2022
97d28d6
feat: increase DefaultGasLimit for cli tx
holyxiaoxin Oct 3, 2022
45f8f67
Add msg handler middleware
RavenXce Oct 18, 2022
009cb25
add: Hooks for send keeper
GulfOfAlaska Nov 3, 2022
5db05b3
fix: Typos
GulfOfAlaska Nov 3, 2022
e8ff8ab
fix: Type error
GulfOfAlaska Nov 3, 2022
a22bf16
add error handling to hooks
randy75828 Nov 4, 2022
c42647c
add IsModuleAccount function in AccountKeeper to check if a supplied …
randy75828 Nov 11, 2022
91d1a8c
add transfer hooks BeforeMultiSend and AfterMultiSend for multisend…
randy75828 Nov 23, 2022
6e9f2be
fix make install issue
randy75828 Nov 24, 2022
92f71e7
remove unneeded hooks
randy75828 Nov 24, 2022
8852f81
Delete version specifally
RavenXce Dec 1, 2022
6c4cca1
Delete version
RavenXce Dec 1, 2022
a20c6aa
Panic on error
RavenXce Dec 1, 2022
df9ffea
Add logs
RavenXce Dec 1, 2022
3653d50
Hardcode version delete
RavenXce Dec 1, 2022
f619e3b
Force overwrite
RavenXce Dec 1, 2022
eb17944
Update iavl
RavenXce Dec 1, 2022
7292335
Force delete version
RavenXce Dec 1, 2022
c3101bf
Fix ver deletion
RavenXce Dec 1, 2022
0ac7c92
Rollback properly
RavenXce Dec 1, 2022
7f7519d
Fix merge regressions
RavenXce Feb 2, 2023
8e8528f
Fix rollback cmd
RavenXce Feb 2, 2023
4612c16
add evm mapping logic in accountKeeper and bankKeeper
freeelancer Feb 9, 2023
1997d9a
edit getAccount to stay in line with initial cosmos sdk contract, ie …
randy75828 Dec 27, 2022
d0cb72e
revert HasAccount to its original definition in case future libraries…
randy75828 Dec 30, 2022
5f903bb
reverts commit b45c030ce9ec39f6ad125be996dd689f05bb6f55 "revert HasAc…
randy75828 Dec 30, 2022
532ad82
create GetMappedAccountAddressIfExists helper method in accountKeeper
randy75828 Jan 4, 2023
2ed75f2
refactor GetMappedAccountAddressIfExists to GetMergedAccountAddressIf…
randy75828 Jan 10, 2023
6540799
remove getting merged account logic in getAllBalances as it is alread…
randy75828 Jan 11, 2023
c04b51b
code clean up
randy75828 Jan 16, 2023
c237234
move extraction of address from key to be in app logic rather than in…
randy75828 Jan 17, 2023
41d4d08
Revert "move extraction of address from key to be in app logic rather…
randy75828 Jan 17, 2023
d175e4c
add guard for iteration of EthAddressToCosmosAddress and CosmosAddres…
randy75828 Jan 17, 2023
315fc4a
update iavl
randy75828 Apr 17, 2023
e173ed8
Code Refactoring: Refactor telemetry to begin and end block (#316)
chungnicholas Jun 12, 2023
d728619
add GetMappedAddress helper method
randy75828 Jun 12, 2023
31c1df5
ensure that event emitted from transfer of funds is from mapped address
randy75828 Jun 12, 2023
ec3b53b
Add telemetry to GRPC handler (#320)
chungnicholas Jun 19, 2023
2809888
feat/api node for off oracle service [WIP] (#333)
chungnicholas Jul 24, 2023
120ca32
add refund-handler to base-app
yan-soon Jul 31, 2023
fca93df
fix bug with refundHandler msCache
yan-soon Aug 1, 2023
94fe9a0
append refund events to anteEvents
yan-soon Aug 8, 2023
464313d
feat: add before and after ModuleEndBlock
holyxiaoxin Aug 11, 2023
ff36c94
fix: db_backend lookup in config.toml
holyxiaoxin Aug 16, 2023
91d5b91
feat: telemetry monitor-store-size-interval config
holyxiaoxin Sep 6, 2023
3ffd1cb
fix conflicts from cherry-picking
yan-soon Sep 19, 2023
1260d72
add back legacy router to handle legacy sdk.msg routing
yan-soon Sep 19, 2023
8145796
update proto related files
yan-soon Sep 19, 2023
596a5ae
Revert "update proto related files"
yan-soon Sep 21, 2023
e45118e
update distribution proto
yan-soon Sep 21, 2023
8360748
add back value and scanner interface for LegacyDec
yan-soon Oct 2, 2023
dc05d27
update cosmossdk.io/math pseudo ver
yan-soon Oct 2, 2023
a80ee8b
feat: add pruning-start-height flag to prune cmd
holyxiaoxin Aug 15, 2023
1c4479b
update distribution proto and rerun make proto-gen
yan-soon Oct 10, 2023
85e0190
update distribution proto and rerun make proto-gen again
yan-soon Oct 10, 2023
8eb03bc
change begin and end blockers for gov, staking and upgrade modules to…
yan-soon Oct 10, 2023
67e1b1a
remove duplicate pruning cmd flag
yan-soon Oct 10, 2023
9d48dc9
use cosmos iavl instead of our fork
yan-soon Oct 25, 2023
23debf2
remove previous forked rollback code
yan-soon Oct 25, 2023
57a9676
update cometbft to v0.38.0 to fully utilise ABCI++
yan-soon Oct 26, 2023
798fa5a
Revert "update cometbft to v0.38.0 to fully utilise ABCI++"
yan-soon Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ ifeq (secp,$(findstring secp,$(COSMOS_BUILD_OPTIONS)))
build_tags += libsecp256k1_sdk
endif

ifeq (legacy,$(findstring legacy,$(COSMOS_BUILD_OPTIONS)))
build_tags += app_v1
endif

whitespace :=
whitespace += $(whitespace)
comma := ,
Expand Down
550 changes: 394 additions & 156 deletions api/cosmos/distribution/v1beta1/distribution.pulsar.go

Large diffs are not rendered by default.

1,357 changes: 1,164 additions & 193 deletions api/cosmos/distribution/v1beta1/query.pulsar.go

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions api/cosmos/distribution/v1beta1/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv
gInfo := sdk.GasInfo{}
resultStr := "successful"

defer func() {
if app.deliverTxer != nil {
app.deliverTxer(app.deliverState.ctx, req, res)
}
}()

defer func() {
for _, streamingListener := range app.abciListeners {
if err := streamingListener.ListenDeliverTx(app.deliverState.ctx, req, res); err != nil {
Expand Down Expand Up @@ -436,6 +442,9 @@ func (app *BaseApp) Commit() abci.ResponseCommit {
if ok {
rms.SetCommitHeader(header)
}
if app.beforeCommitter != nil {
app.beforeCommitter(app.deliverState.ctx)
}

// Write the DeliverTx state into branched storage and commit the MultiStore.
// The write to the DeliverTx state writes all state transitions to the root
Expand Down Expand Up @@ -463,6 +472,10 @@ func (app *BaseApp) Commit() abci.ResponseCommit {
// Commit. Use the header from this latest block.
app.setState(runTxModeCheck, header)

if app.afterCommitter != nil {
app.afterCommitter(app.deliverState.ctx)
}

// empty/reset the deliver state
app.deliverState = nil

Expand Down Expand Up @@ -686,6 +699,7 @@ func (app *BaseApp) ApplySnapshotChunk(req abci.RequestApplySnapshotChunk) abci.
}

func (app *BaseApp) handleQueryGRPC(handler GRPCQueryHandler, req abci.RequestQuery) abci.ResponseQuery {
defer telemetry.ModuleMeasureSince(req.Path, time.Now(), "GRPC_query")
ctx, err := app.CreateQueryContext(req.Height, req.Prove)
if err != nil {
return sdkerrors.QueryResult(err, app.trace)
Expand Down
84 changes: 76 additions & 8 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)

type (
Expand Down Expand Up @@ -56,13 +57,15 @@ type BaseApp struct { //nolint: maligned
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
router sdk.Router // handle any kind of message
interfaceRegistry codectypes.InterfaceRegistry
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx
txEncoder sdk.TxEncoder // marshal sdk.Tx into []byte

mempool mempool.Mempool // application side mempool
anteHandler sdk.AnteHandler // ante handler for fee and auth
postHandler sdk.PostHandler // post handler, optional, e.g. for tips
refundHandler sdk.AnteHandler // refund handler for failed tx
initChainer sdk.InitChainer // initialize state with validators and state blob
beginBlocker sdk.BeginBlocker // logic to run before any txs
processProposal sdk.ProcessProposalHandler // the handler which runs on ABCI ProcessProposal
Expand All @@ -72,6 +75,8 @@ type BaseApp struct { //nolint: maligned
idPeerFilter sdk.PeerFilter // filter peers by node ID
fauxMerkleMode bool // if true, IAVL MountStores uses MountStoresDB for simulation speed.

customMiddlewares

// manages snapshots, i.e. dumps of app state at certain intervals
snapshotManager *snapshots.Manager

Expand Down Expand Up @@ -146,6 +151,14 @@ type BaseApp struct { //nolint: maligned
chainID string
}

type customMiddlewares struct {
deliverTxer sdk.DeliverTxer // logic to run on any deliver tx
beforeCommitter sdk.BeforeCommitter // logic to run before committing state
afterCommitter sdk.AfterCommitter // logic to run after committing state

msgHandlerMiddleware sdk.MsgHandlerMiddleware // middleware that wraps msg handlers
}

// NewBaseApp returns a reference to an initialized BaseApp. It accepts a
// variadic number of option functions, which act on the BaseApp to set
// configuration choices.
Expand All @@ -160,6 +173,7 @@ func NewBaseApp(
db: db,
cms: store.NewCommitMultiStore(db),
storeLoader: DefaultStoreLoader,
router: NewRouter(),
grpcQueryRouter: NewGRPCQueryRouter(),
msgServiceRouter: NewMsgServiceRouter(),
txDecoder: txDecoder,
Expand Down Expand Up @@ -405,6 +419,17 @@ func (app *BaseApp) setIndexEvents(ie []string) {
}
}

// Router returns the legacy router of the BaseApp.
func (app *BaseApp) Router() sdk.Router {
if app.sealed {
// We cannot return a Router when the app is sealed because we can't have
// any routes modified which would cause unexpected routing behavior.
panic("Router() on sealed BaseApp")
}

return app.router
}

// Seal seals a BaseApp. It prohibits any further modifications to a BaseApp.
func (app *BaseApp) Seal() { app.sealed = true }

Expand Down Expand Up @@ -770,6 +795,23 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
// append the events in the order of occurrence
result.Events = append(anteEvents, result.Events...)
}
} else {
if app.refundHandler != nil {
refundCtx, msCache := app.cacheTxContext(ctx, txBytes)
refundCtx = refundCtx.WithEventManager(sdk.NewEventManager())
newCtx, err := app.refundHandler(refundCtx, tx, mode == runTxModeSimulate)
if err != nil {
return gInfo, result, anteEvents, priority, err
}

if mode == runTxModeDeliver {
msCache.Write()
}

if len(anteEvents) > 0 && (mode == runTxModeDeliver || mode == runTxModeSimulate) {
anteEvents = append(anteEvents, newCtx.EventManager().ABCIEvents()...)
}
}
}

return gInfo, result, anteEvents, priority, err
Expand All @@ -785,21 +827,43 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
events := sdk.EmptyEvents()
var msgResponses []*codectypes.Any

middleware := app.msgHandlerMiddleware
if middleware == nil {
middleware = noopMiddleware
}

// NOTE: GasWanted is determined by the AnteHandler and GasUsed by the GasMeter.
for i, msg := range msgs {
if mode != runTxModeDeliver && mode != runTxModeSimulate {
break
}

handler := app.msgServiceRouter.Handler(msg)
if handler == nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg)
}
var (
msgResult *sdk.Result
err error
)

// ADR 031 request type routing
msgResult, err := handler(ctx, msg)
if err != nil {
return nil, sdkerrors.Wrapf(err, "failed to execute message; message index: %d", i)
if handler := app.msgServiceRouter.Handler(msg); handler != nil {
// ADR 031 request type routing
msgResult, err = middleware(ctx, msg, handler)
if err != nil {
return nil, sdkerrors.Wrapf(err, "failed to execute message; message index: %d", i)
}
} else if legacyMsg, ok := msg.(legacytx.LegacyMsg); ok {
// legacy sdk.Msg routing
// Assuming that the app developer has migrated all their Msgs to
// proto messages and has registered all `Msg services`, then this
// path should never be called, because all those Msgs should be
// registered within the `msgServiceRouter` already.
msgRoute := legacyMsg.Route()
handler := app.router.Route(ctx, msgRoute)
if handler == nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s; message index: %d", msgRoute, i)
}

msgResult, err = middleware(ctx, msg, handler)
} else {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg)
}

// create message events
Expand Down Expand Up @@ -1074,3 +1138,7 @@ func NoOpProcessProposal() sdk.ProcessProposalHandler {
func (app *BaseApp) Close() error {
return nil
}

var noopMiddleware sdk.MsgHandlerMiddleware = func(c sdk.Context, m sdk.Msg, h sdk.Handler) (*sdk.Result, error) {
return h(c, m)
}
8 changes: 8 additions & 0 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ func TestTxDecoder(t *testing.T) {
require.Equal(t, counter, dTxCounter)
}

// Interleave calls to Check and Deliver and ensure
// that there is no cross-talk. Check sees results of the previous Check calls
// and Deliver sees that of the previous Deliver calls, but they don't see eachother.
func TestConcurrentCheckDeliver(t *testing.T) {
// TODO
}

// Test custom panic handling within app.DeliverTx method
func TestCustomRunTxPanicHandler(t *testing.T) {
customPanicMsg := "test panic"
anteErr := sdkerrors.Register("fakeModule", 100500, "fakeError")
Expand Down
40 changes: 40 additions & 0 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,30 @@ func (app *BaseApp) SetEndBlocker(endBlocker sdk.EndBlocker) {
app.endBlocker = endBlocker
}

func (app *BaseApp) SetDeliverTxer(deliverTxer sdk.DeliverTxer) {
if app.sealed {
panic("SetDeliverTxer() on sealed BaseApp")
}

app.deliverTxer = deliverTxer
}

func (app *BaseApp) SetBeforeCommitter(beforeCommitter sdk.BeforeCommitter) {
if app.sealed {
panic("SetBeforeCommitter() on sealed BaseApp")
}

app.beforeCommitter = beforeCommitter
}

func (app *BaseApp) SetAfterCommitter(afterCommitter sdk.AfterCommitter) {
if app.sealed {
panic("SetBeforeCommitter() on sealed BaseApp")
}

app.afterCommitter = afterCommitter
}

func (app *BaseApp) SetAnteHandler(ah sdk.AnteHandler) {
if app.sealed {
panic("SetAnteHandler() on sealed BaseApp")
Expand All @@ -182,6 +206,22 @@ func (app *BaseApp) SetPostHandler(ph sdk.PostHandler) {
app.postHandler = ph
}

func (app *BaseApp) SetRefundHandler(rh sdk.AnteHandler) {
if app.sealed {
panic("SetRefundHandler() on sealed BaseApp")
}

app.refundHandler = rh
}

func (app *BaseApp) SetMsgHandlerMiddleware(msgHandlerMiddleware sdk.MsgHandlerMiddleware) {
if app.sealed {
panic("SetMsgHandlerMiddleware() on sealed BaseApp")
}

app.msgHandlerMiddleware = msgHandlerMiddleware
}

func (app *BaseApp) SetAddrPeerFilter(pf sdk.PeerFilter) {
if app.sealed {
panic("SetAddrPeerFilter() on sealed BaseApp")
Expand Down
Loading