Skip to content

Commit

Permalink
chore(committing_client): Update for ABCI changes
Browse files Browse the repository at this point in the history
https://github.com/cometbft/cometbft/blob/v0.37.4/UPGRADING.md#abci-changes
> Added new ABCI methods `PrepareProposal` and `ProcessProposal`. For details,
> please see the [spec](spec/abci/README.md). Applications upgrading to
> v0.37.0 must implement these methods, at the very minimum, as described
> [here](./spec/abci/abci%2B%2B_comet_expected_behavior.md#adapting-existing-applications-that-use-abci)

https://github.com/cometbft/cometbft/blob/v0.37.4/CHANGELOG.md#breaking-changes-2
> `[abci]` Removes unused Response/Request `SetOption` from ABCI
> ([\#9145](tendermint/tendermint#9145))
  • Loading branch information
gibson042 committed Mar 26, 2024
1 parent bc3396b commit 389431a
Showing 1 changed file with 48 additions and 24 deletions.
72 changes: 48 additions & 24 deletions abci/client/committing_client.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package abcicli

import (
types "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/service"
cmtsync "github.com/tendermint/tendermint/libs/sync"
types "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/service"
cmtsync "github.com/cometbft/cometbft/libs/sync"
)

var _ Client = (*committingClient)(nil)

// committingClient is a clone of localClient (./local_client.go) with better
// locking behavior for inbound read requests.
//
// NOTE: use defer to unlock mutex because Application might panic (e.g., in
// case of malicious tx or query). It only makes sense for publicly exposed
// methods like CheckTx (/broadcast_tx_* RPC endpoint) or Query (/abci_query
Expand Down Expand Up @@ -87,18 +90,6 @@ func (app *committingClient) InfoAsync(req types.RequestInfo) *ReqRes {
)
}

func (app *committingClient) SetOptionAsync(req types.RequestSetOption) *ReqRes {
// Need to block all readers
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.SetOption(req)
return app.callback(
types.ToRequestSetOption(req),
types.ToResponseSetOption(res),
)
}

func (app *committingClient) DeliverTxAsync(params types.RequestDeliverTx) *ReqRes {
// Blocked until state is initialized, then by state writers
app.mtx.RInitLock()
Expand Down Expand Up @@ -240,6 +231,30 @@ func (app *committingClient) ApplySnapshotChunkAsync(req types.RequestApplySnaps
)
}

func (app *committingClient) PrepareProposalAsync(req types.RequestPrepareProposal) *ReqRes {
// TODO: Verify appropriate lock level.
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.PrepareProposal(req)
return app.callback(
types.ToRequestPrepareProposal(req),
types.ToResponsePrepareProposal(res),
)
}

func (app *committingClient) ProcessProposalAsync(req types.RequestProcessProposal) *ReqRes {
// TODO: Verify appropriate lock level.
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.ProcessProposal(req)
return app.callback(
types.ToRequestProcessProposal(req),
types.ToResponseProcessProposal(res),
)
}

//-------------------------------------------------------

func (app *committingClient) FlushSync() error {
Expand All @@ -261,15 +276,6 @@ func (app *committingClient) InfoSync(req types.RequestInfo) (*types.ResponseInf
return &res, nil
}

func (app *committingClient) SetOptionSync(req types.RequestSetOption) (*types.ResponseSetOption, error) {
// Need to block all readers
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.SetOption(req)
return &res, nil
}

func (app *committingClient) DeliverTxSync(req types.RequestDeliverTx) (*types.ResponseDeliverTx, error) {
// Blocked until state is initialized, then by state writers
app.mtx.RInitLock()
Expand Down Expand Up @@ -380,6 +386,24 @@ func (app *committingClient) ApplySnapshotChunkSync(
return &res, nil
}

func (app *committingClient) PrepareProposalSync(req types.RequestPrepareProposal) (*types.ResponsePrepareProposal, error) {
// TODO: Verify appropriate lock level.
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.PrepareProposal(req)
return &res, nil
}

func (app *committingClient) ProcessProposalSync(req types.RequestProcessProposal) (*types.ResponseProcessProposal, error) {
// TODO: Verify appropriate lock level.
app.mtx.Lock()
defer app.mtx.Unlock()

res := app.Application.ProcessProposal(req)
return &res, nil
}

//-------------------------------------------------------

func (app *committingClient) callback(req *types.Request, res *types.Response) *ReqRes {
Expand Down

0 comments on commit 389431a

Please sign in to comment.