Skip to content

Commit

Permalink
feat: add abci wrapper with locks
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios committed Jan 3, 2025
1 parent 03ea5e4 commit 1d61e19
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
77 changes: 77 additions & 0 deletions server/cmt_abci_non_block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package server

import (
"context"

"sync"

abci "github.com/cometbft/cometbft/abci/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
)

type cometABCIWrapperNonBlock struct {
app servertypes.ABCI

mtx sync.RWMutex
}

func NewCometABCIWrapperNonBlock(app servertypes.ABCI) abci.Application {
return cometABCIWrapperNonBlock{app: app, mtx: sync.RWMutex{}}
}

func (w cometABCIWrapperNonBlock) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) {
return w.app.Info(req)
}

func (w cometABCIWrapperNonBlock) Query(ctx context.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error) {
return w.app.Query(ctx, req)
}

func (w cometABCIWrapperNonBlock) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
return w.app.CheckTx(req)
}

func (w cometABCIWrapperNonBlock) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
return w.app.InitChain(req)
}

func (w cometABCIWrapperNonBlock) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) {
return w.app.PrepareProposal(req)
}

func (w cometABCIWrapperNonBlock) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
return w.app.ProcessProposal(req)
}

func (w cometABCIWrapperNonBlock) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
return w.app.FinalizeBlock(req)
}

func (w cometABCIWrapperNonBlock) ExtendVote(ctx context.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) {
return w.app.ExtendVote(ctx, req)
}

func (w cometABCIWrapperNonBlock) VerifyVoteExtension(_ context.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) {
return w.app.VerifyVoteExtension(req)
}

func (w cometABCIWrapperNonBlock) Commit(_ context.Context, _ *abci.RequestCommit) (*abci.ResponseCommit, error) {
return w.app.Commit()
}

func (w cometABCIWrapperNonBlock) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) {
return w.app.ListSnapshots(req)
}

func (w cometABCIWrapperNonBlock) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) {
return w.app.OfferSnapshot(req)
}

func (w cometABCIWrapperNonBlock) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) {
return w.app.LoadSnapshotChunk(req)
}

func (w cometABCIWrapperNonBlock) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) {
return w.app.ApplySnapshotChunk(req)
}
2 changes: 2 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
FlagIAVLCacheSize = "iavl-cache-size"
FlagDisableIAVLFastNode = "iavl-disable-fastnode"
FlagShutdownGrace = "shutdown-grace"
FlagAbciClientType = "abci-client-type" // [AGORIC]

// state sync-related flags
FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval"
Expand Down Expand Up @@ -983,6 +984,7 @@ func addStartNodeFlags(cmd *cobra.Command, opts StartCmdOptions) {
cmd.Flags().Uint64(FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval")
cmd.Flags().Uint32(FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep")
cmd.Flags().Bool(FlagDisableIAVLFastNode, false, "Disable fast node for IAVL tree")
cmd.Flags().String(FlagAbciClientType, serverconfig.DefaultABCIClientType, fmt.Sprintf(`Type of ABCI client ("%s" or "%s")`, serverconfig.AbciClientTypeCommitting, serverconfig.AbciClientTypeLocal)) // [AGORIC]
cmd.Flags().Int(FlagMempoolMaxTxs, mempool.DefaultMaxTx, "Sets MaxTx value for the app-side mempool")
cmd.Flags().Duration(FlagShutdownGrace, 0*time.Second, "On Shutdown, duration to wait for resource clean up")

Expand Down

0 comments on commit 1d61e19

Please sign in to comment.