Skip to content

Commit 529c69c

Browse files
authored
chore: Revert feat!: ABCI 1.0 Integration 48fe175… (#483)
* Revert feat!: ABCI 1.0 Integration 48fe175 * Revert "chore(backport): Simulation is not deterministic due to GenTx (backport cosmos#12374) (cosmos#12437) (#356)" This reverts commit d738efc. * updates
1 parent b94f9e6 commit 529c69c

File tree

321 files changed

+14173
-7909
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+14173
-7909
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ build, in which case we can fall back on `go mod tidy -v`.
173173

174174
## Protobuf
175175

176-
We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/cosmos/gogoproto) to generate code for use in Cosmos SDK.
176+
We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos SDK.
177177

178178
For determinstic behavior around Protobuf tooling, everything is containerized using Docker. Make sure to have Docker installed on your machine, or head to [Docker's website](https://docs.docker.com/get-docker/) to install it.
179179

Makefile

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ mocks: $(MOCKS_DIR)
152152
$(mockgen_cmd) -source=types/module/module.go -package mocks -destination tests/mocks/types_module_module.go
153153
$(mockgen_cmd) -source=types/invariant.go -package mocks -destination tests/mocks/types_invariant.go
154154
$(mockgen_cmd) -source=types/router.go -package mocks -destination tests/mocks/types_router.go
155-
$(mockgen_cmd) -package mocks -destination tests/mocks/grpc_server.go github.com/cosmos/gogoproto/grpc Server
155+
$(mockgen_cmd) -package mocks -destination tests/mocks/grpc_server.go github.com/gogo/protobuf/grpc Server
156156
$(mockgen_cmd) -package mocks -destination tests/mocks/tendermint_tendermint_libs_log_DB.go github.com/tendermint/tendermint/libs/log Logger
157157
.PHONY: mocks
158158

@@ -382,41 +382,69 @@ devdoc-update:
382382
### Protobuf ###
383383
###############################################################################
384384

385-
protoVer=0.11.2
386-
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
387-
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
385+
containerProtoVer=v0.2
386+
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
387+
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
388+
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
389+
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
388390

389391
proto-all: proto-format proto-lint proto-gen
390392

391393
proto-gen:
392394
@echo "Generating Protobuf files"
393-
@$(protoImage) sh ./scripts/protocgen.sh
395+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
396+
sh ./scripts/protocgen.sh; fi
397+
398+
# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
399+
proto-gen-any:
400+
@echo "Generating Protobuf Any"
401+
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) sh ./scripts/protocgen-any.sh
394402

395403
proto-swagger-gen:
396404
@echo "Generating Protobuf Swagger"
397-
@$(protoImage) sh ./scripts/protoc-swagger-gen.sh
405+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
406+
sh ./scripts/protoc-swagger-gen.sh; fi
398407

399408
proto-format:
400-
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
409+
@echo "Formatting Protobuf files"
410+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
411+
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
412+
401413

402414
proto-lint:
403-
@$(protoImage) buf lint --error-format=json
415+
@$(DOCKER_BUF) lint --error-format=json
404416

405417
proto-check-breaking:
406-
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=osmosis-main
418+
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=v0.44.3x-osmo-v5
419+
407420

408-
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.37.0-rc1/proto/tendermint
421+
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint
422+
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
423+
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
424+
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.3
409425

410-
TM_CRYPTO_TYPES = proto/tendermint/crypto
411-
TM_ABCI_TYPES = proto/tendermint/abci
412-
TM_TYPES = proto/tendermint/types
413-
TM_VERSION = proto/tendermint/version
414-
TM_LIBS = proto/tendermint/libs/bits
415-
TM_P2P = proto/tendermint/p2p
426+
TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
427+
TM_ABCI_TYPES = third_party/proto/tendermint/abci
428+
TM_TYPES = third_party/proto/tendermint/types
429+
TM_VERSION = third_party/proto/tendermint/version
430+
TM_LIBS = third_party/proto/tendermint/libs/bits
431+
TM_P2P = third_party/proto/tendermint/p2p
432+
433+
GOGO_PROTO_TYPES = third_party/proto/gogoproto
434+
COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
435+
CONFIO_TYPES = third_party/proto/confio
416436

417437
proto-update-deps:
418-
@echo "Updating Protobuf dependencies"
438+
@mkdir -p $(GOGO_PROTO_TYPES)
439+
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto
440+
441+
@mkdir -p $(COSMOS_PROTO_TYPES)
442+
@curl -sSL $(COSMOS_PROTO_URL)/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto
419443

444+
## Importing of tendermint protobuf definitions currently requires the
445+
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
446+
## (which is the standard Buf.build FILE_LAYOUT)
447+
## Issue link: https://github.com/tendermint/tendermint/issues/5021
420448
@mkdir -p $(TM_ABCI_TYPES)
421449
@curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto
422450

@@ -440,9 +468,13 @@ proto-update-deps:
440468
@mkdir -p $(TM_P2P)
441469
@curl -sSL $(TM_URL)/p2p/types.proto > $(TM_P2P)/types.proto
442470

443-
$(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf mod update
471+
@mkdir -p $(CONFIO_TYPES)
472+
@curl -sSL $(CONFIO_URL)/proofs.proto > $(CONFIO_TYPES)/proofs.proto
473+
## insert go package option into proofs.proto file
474+
## Issue link: https://github.com/confio/ics23/issues/32
475+
@sed -i '4ioption go_package = "github.com/confio/ics23/go";' $(CONFIO_TYPES)/proofs.proto
444476

445-
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
477+
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
446478

447479
###############################################################################
448480
### Localnet ###

baseapp/abci.go

Lines changed: 20 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"syscall"
1212
"time"
1313

14-
"github.com/cosmos/gogoproto/proto"
14+
"github.com/gogo/protobuf/proto"
1515
abci "github.com/tendermint/tendermint/abci/types"
1616
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1717
"google.golang.org/grpc/codes"
@@ -44,8 +44,6 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
4444
// req.InitialHeight is 1 by default.
4545
initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time}
4646

47-
app.logger.Info("InitChain", "initialHeight", req.InitialHeight, "chainID", req.ChainId)
48-
4947
// If req.InitialHeight is > 1, then we set the initial version in the
5048
// stores.
5149
if req.InitialHeight > 1 {
@@ -57,11 +55,9 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
5755
}
5856
}
5957

60-
// initialize states with a correct header
58+
// initialize the deliver state and check state with a correct header
6159
app.setDeliverState(initHeader)
6260
app.setCheckState(initHeader)
63-
app.setPrepareProposalState(initHeader)
64-
app.setProcessProposalState(initHeader)
6561

6662
if err := app.SetAppVersion(initialAppVersion); err != nil {
6763
panic(err)
@@ -71,10 +67,10 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
7167
// done after the deliver state and context have been set as it's persisted
7268
// to state.
7369
if req.ConsensusParams != nil {
74-
// When InitChain is called, the app version should either be absent and
75-
// determined by the application or set to 0. Panic if it's not.
76-
if req.ConsensusParams.Version != nil && req.ConsensusParams.Version.App != initialAppVersion {
77-
panic(AppVersionError{Actual: req.ConsensusParams.Version.App, Initial: initialAppVersion})
70+
// When InitChain is called, the app version should either be absent and determined by the application
71+
// or set to 0. Panic if it's not.
72+
if req.ConsensusParams.Version != nil && req.ConsensusParams.Version.AppVersion != initialAppVersion {
73+
panic(AppVersionError{Actual: req.ConsensusParams.Version.AppVersion, Initial: initialAppVersion})
7874
}
7975

8076
app.StoreConsensusParams(app.deliverState.ctx, req.ConsensusParams)
@@ -152,6 +148,12 @@ func (app *BaseApp) Info(req abci.RequestInfo) abci.ResponseInfo {
152148
}
153149
}
154150

151+
// SetOption implements the ABCI interface.
152+
func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOption) {
153+
// TODO: Implement!
154+
return
155+
}
156+
155157
// FilterPeerByAddrPort filters peers by address/port.
156158
func (app *BaseApp) FilterPeerByAddrPort(info string) abci.ResponseQuery {
157159
if app.addrPeerFilter != nil {
@@ -199,20 +201,21 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
199201

200202
// add block gas meter
201203
var gasMeter sdk.GasMeter
202-
if maxGas := app.GetMaximumBlockGas(app.deliverState.ctx); maxGas > 0 {
204+
if maxGas := app.getMaximumBlockGas(app.deliverState.ctx); maxGas > 0 {
203205
gasMeter = sdk.NewGasMeter(maxGas)
204206
} else {
205207
gasMeter = sdk.NewInfiniteGasMeter()
206208
}
207209

208210
// NOTE: header hash is not set in NewContext, so we manually set it here
211+
209212
app.deliverState.ctx = app.deliverState.ctx.
210213
WithBlockGasMeter(gasMeter).
211214
WithHeaderHash(req.Hash).
212215
WithConsensusParams(app.GetConsensusParams(app.deliverState.ctx))
213216

214-
// We also set block gas meter to checkState in case the application needs to
215-
// verify gas consumption during (Re)CheckTx.
217+
// we also set block gas meter to checkState in case the application needs to
218+
// verify gas consumption during (Re)CheckTx
216219
if app.checkState != nil {
217220
app.checkState.ctx = app.checkState.ctx.
218221
WithBlockGasMeter(gasMeter).
@@ -248,59 +251,6 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
248251
return res
249252
}
250253

251-
// PrepareProposal implements the PrepareProposal ABCI method and returns a
252-
// ResponsePrepareProposal object to the client. The PrepareProposal method is
253-
// responsible for allowing the block proposer to perform application-dependent
254-
// work in a block before proposing it.
255-
//
256-
// Transactions can be modified, removed, or added by the application. Since the
257-
// application maintains its own local mempool, it will ignore the transactions
258-
// provided to it in RequestPrepareProposal. Instead, it will determine which
259-
// transactions to return based on the mempool's semantics and the MaxTxBytes
260-
// provided by the client's request.
261-
//
262-
// Note, there is no need to execute the transactions for validity as they have
263-
// already passed CheckTx.
264-
//
265-
// Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
266-
// Ref: https://github.com/tendermint/tendermint/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
267-
func (app *BaseApp) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
268-
ctx := app.getContextForTx(runTxPrepareProposal, []byte{})
269-
if app.prepareProposal == nil {
270-
panic("PrepareProposal method not set")
271-
}
272-
273-
return app.prepareProposal(ctx, req)
274-
}
275-
276-
// ProcessProposal implements the ProcessProposal ABCI method and returns a
277-
// ResponseProcessProposal object to the client. The ProcessProposal method is
278-
// responsible for allowing execution of application-dependent work in a proposed
279-
// block. Note, the application defines the exact implementation details of
280-
// ProcessProposal. In general, the application must at the very least ensure
281-
// that all transactions are valid. If all transactions are valid, then we inform
282-
// Tendermint that the Status is ACCEPT. However, the application is also able
283-
// to implement optimizations such as executing the entire proposed block
284-
// immediately. It may even execute the block in parallel.
285-
//
286-
// Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
287-
// Ref: https://github.com/tendermint/tendermint/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
288-
func (app *BaseApp) ProcessProposal(req abci.RequestProcessProposal) abci.ResponseProcessProposal {
289-
if app.processProposal == nil {
290-
panic("app.ProcessProposal is not set")
291-
}
292-
293-
ctx := app.processProposalState.ctx.
294-
WithVoteInfos(app.voteInfos).
295-
WithBlockHeight(req.Height).
296-
WithBlockTime(req.Time).
297-
WithHeaderHash(req.Hash).
298-
WithProposer(req.ProposerAddress).
299-
WithConsensusParams(app.GetConsensusParams(app.processProposalState.ctx))
300-
301-
return app.processProposal(ctx, req)
302-
}
303-
304254
// CheckTx implements the ABCI interface and executes a tx in CheckTx mode. In
305255
// CheckTx mode, messages are not executed. This means messages are only validated
306256
// and only the AnteHandler is executed. State is persisted to the BaseApp's
@@ -394,8 +344,6 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {
394344
// NOTE: This is safe because Tendermint holds a lock on the mempool for
395345
// Commit. Use the header from this latest block.
396346
app.setCheckState(header)
397-
app.setPrepareProposalState(header)
398-
app.setProcessProposalState(header)
399347

400348
// empty/reset the deliver state
401349
app.deliverState = nil
@@ -638,7 +586,7 @@ func queryListContainsReq(req abci.RequestQuery) bool {
638586
}
639587

640588
func (app *BaseApp) handleQueryGRPC(handler GRPCQueryHandler, req abci.RequestQuery) abci.ResponseQuery {
641-
ctx, err := app.CreateQueryContext(req.Height, req.Prove)
589+
ctx, err := app.createQueryContext(req.Height, req.Prove)
642590
if err != nil {
643591
return sdkerrors.QueryResultWithDebug(err, app.trace)
644592
}
@@ -689,9 +637,9 @@ func checkNegativeHeight(height int64) error {
689637
return nil
690638
}
691639

692-
// CreateQueryContext creates a new sdk.Context for a query, taking as args
640+
// createQueryContext creates a new sdk.Context for a query, taking as args
693641
// the block height and whether the query needs a proof or not.
694-
func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, error) {
642+
func (app *BaseApp) createQueryContext(height int64, prove bool) (sdk.Context, error) {
695643
if err := checkNegativeHeight(height); err != nil {
696644
return sdk.Context{}, err
697645
}
@@ -988,7 +936,7 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) abci.
988936
return sdkerrors.QueryResultWithDebug(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "no custom querier found for route %s", path[1]), app.trace)
989937
}
990938

991-
ctx, err := app.CreateQueryContext(req.Height, req.Prove)
939+
ctx, err := app.createQueryContext(req.Height, req.Prove)
992940
if err != nil {
993941
return sdkerrors.QueryResultWithDebug(err, app.trace)
994942
}

0 commit comments

Comments
 (0)