Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
79 changes: 48 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ifeq ($(findstring -,$(VERSION)),) # No "-" means it's just a hash
VERSION := 0.0.0-$(VERSION_RAW)
endif
export VERSION
export CMTVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
export CMTVERSION := $(shell go list -m github.com/cometbft/cometbft/v2 | sed 's:.* ::')
export COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
Expand Down Expand Up @@ -67,7 +67,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sim \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(CMTVERSION)
-X github.com/cometbft/cometbft/v2/version.TMCoreSemVer=$(CMTVERSION)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
Expand Down Expand Up @@ -134,11 +134,15 @@ cosmovisor:
confix:
$(MAKE) -C tools/confix confix

hubl:
$(MAKE) -C tools/hubl hubl

.PHONY: build build-linux-amd64 build-linux-arm64 cosmovisor confix


#? mocks: Generate mock file
mocks: $(MOCKS_DIR)
@go install go.uber.org/mock/mockgen@v0.6.0
@go install go.uber.org/mock/mockgen@v0.5.0
sh ./scripts/mockgen.sh
.PHONY: mocks

Expand Down Expand Up @@ -379,20 +383,21 @@ benchmark:
### Linting ###
###############################################################################

golangci_version=v2.5.0
golangci_version=v2.3.1

lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(golangci_version)

lint:
@echo "--> Running linter on all files"
@$(MAKE) lint-install
$(MAKE) lint-install
@./scripts/go-lint-all.bash --timeout=15m


lint-fix:
@echo "--> Running linter"
@$(MAKE) lint-install
$(MAKE) lint-install
@./scripts/go-lint-all.bash --fix

.PHONY: lint lint-fix
Expand Down Expand Up @@ -426,44 +431,52 @@ proto-lint:
proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

CMT_URL = https://raw.githubusercontent.com/cometbft/cometbft/v0.38.0/proto/tendermint
CMT_VERSION_DIR = v1.0.1
CMT_PROTO = v1
CMT_URL = https://raw.githubusercontent.com/cometbft/cometbft/$(CMT_VERSION_DIR)/proto/cometbft
CMT_CRYPTO_TYPES = proto/cometbft/crypto/$(CMT_PROTO)
CMT_ABCI_TYPES = proto/cometbft/abci/$(CMT_PROTO)
CMT_TYPES = proto/cometbft/types/$(CMT_PROTO)
CMT_VERSION = proto/cometbft/version/$(CMT_PROTO)
CMT_LIBS = proto/cometbft/libs/bits/$(CMT_PROTO)
CMT_P2P = proto/cometbft/p2p/$(CMT_PROTO)

CMT_CRYPTO_TYPES = proto/tendermint/crypto
CMT_ABCI_TYPES = proto/tendermint/abci
CMT_TYPES = proto/tendermint/types
CMT_VERSION = proto/tendermint/version
CMT_LIBS = proto/tendermint/libs/bits
CMT_P2P = proto/tendermint/p2p

proto-update-deps:
@echo "Updating Protobuf dependencies"
proto-update-comet:
@echo "Updating Protobuf dependency: downloading cometbft.$(CMT_PROTO) files from CometBFT $(CMT_VERSION_DIR)"

@mkdir -p $(CMT_ABCI_TYPES)
@curl -sSL $(CMT_URL)/abci/types.proto > $(CMT_ABCI_TYPES)/types.proto
@curl -fsSL $(CMT_URL)/abci/$(CMT_PROTO)/service.proto > $(CMT_ABCI_TYPES)/service.proto
@curl -fsSL $(CMT_URL)/abci/$(CMT_PROTO)/types.proto > $(CMT_ABCI_TYPES)/types.proto

@mkdir -p $(CMT_VERSION)
@curl -sSL $(CMT_URL)/version/types.proto > $(CMT_VERSION)/types.proto
@curl -fsSL $(CMT_URL)/version/$(CMT_PROTO)/types.proto > $(CMT_VERSION)/types.proto

@mkdir -p $(CMT_TYPES)
@curl -sSL $(CMT_URL)/types/types.proto > $(CMT_TYPES)/types.proto
@curl -sSL $(CMT_URL)/types/evidence.proto > $(CMT_TYPES)/evidence.proto
@curl -sSL $(CMT_URL)/types/params.proto > $(CMT_TYPES)/params.proto
@curl -sSL $(CMT_URL)/types/validator.proto > $(CMT_TYPES)/validator.proto
@curl -sSL $(CMT_URL)/types/block.proto > $(CMT_TYPES)/block.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/block.proto > $(CMT_TYPES)/block.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/canonical.proto > $(CMT_TYPES)/canonical.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/events.proto > $(CMT_TYPES)/events.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/evidence.proto > $(CMT_TYPES)/evidence.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/params.proto > $(CMT_TYPES)/params.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/types.proto > $(CMT_TYPES)/types.proto
@curl -fsSL $(CMT_URL)/types/$(CMT_PROTO)/validator.proto > $(CMT_TYPES)/validator.proto

@mkdir -p $(CMT_CRYPTO_TYPES)
@curl -sSL $(CMT_URL)/crypto/proof.proto > $(CMT_CRYPTO_TYPES)/proof.proto
@curl -sSL $(CMT_URL)/crypto/keys.proto > $(CMT_CRYPTO_TYPES)/keys.proto
@curl -fsSL $(CMT_URL)/crypto/$(CMT_PROTO)/keys.proto > $(CMT_CRYPTO_TYPES)/keys.proto
@curl -fsSL $(CMT_URL)/crypto/$(CMT_PROTO)/proof.proto > $(CMT_CRYPTO_TYPES)/proof.proto

@mkdir -p $(CMT_LIBS)
@curl -sSL $(CMT_URL)/libs/bits/types.proto > $(CMT_LIBS)/types.proto
@curl -fsSL $(CMT_URL)/libs/bits/$(CMT_PROTO)/types.proto > $(CMT_LIBS)/types.proto

@mkdir -p $(CMT_P2P)
@curl -sSL $(CMT_URL)/p2p/types.proto > $(CMT_P2P)/types.proto
@curl -fsSL $(CMT_URL)/p2p/$(CMT_PROTO)/conn.proto > $(CMT_P2P)/conn.proto
@curl -fsSL $(CMT_URL)/p2p/$(CMT_PROTO)/pex.proto > $(CMT_P2P)/pex.proto
@curl -fsSL $(CMT_URL)/p2p/$(CMT_PROTO)/types.proto > $(CMT_P2P)/types.proto

$(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf mod update
proto-update-deps:
@echo "Updating Protobuf dependencies: running 'buf dep update'"
$(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf dep update

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps proto-update-comet

###############################################################################
### Localnet ###
Expand Down Expand Up @@ -492,13 +505,17 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes

.PHONY: localnet-start localnet-stop localnet-debug localnet-build-env localnet-build-dlv localnet-build-nodes

test-system: build-v53 build
build-system-test-current: build
mkdir -p ./tests/systemtests/binaries/
cp $(BUILDDIR)/simd ./tests/systemtests/binaries/

test-system: build-v53 build-system-test-current
mkdir -p ./tests/systemtests/binaries/
cp $(BUILDDIR)/simd ./tests/systemtests/binaries/
mkdir -p ./tests/systemtests/binaries/v0.53
mv $(BUILDDIR)/simdv53 ./tests/systemtests/binaries/v0.53/simd
$(MAKE) -C tests/systemtests test
.PHONY: test-system
.PHONY: test-system build-system-test-current

# build-v53 checks out the v0.53.x branch, builds the binary, and renames it to simdv53.
build-v53:
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
cosmossdk.io/store v1.1.2
cosmossdk.io/x/tx v0.14.0
github.com/99designs/keyring v1.2.1
github.com/alitto/pond/v2 v2.5.0
github.com/bgentry/speakeasy v0.2.0
github.com/bits-and-blooms/bitset v1.24.1
github.com/chzyer/readline v1.5.1
Expand All @@ -25,8 +26,10 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogogateway v1.2.0
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/iavl v1.2.6
github.com/cosmos/ledger-cosmos-go v0.16.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
github.com/edsrzf/mmap-go v1.0.0
github.com/golang/protobuf v1.5.4
github.com/google/go-cmp v0.7.0
github.com/google/gofuzz v1.2.0
Expand Down Expand Up @@ -55,8 +58,10 @@ require (
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/tendermint/go-amino v0.16.0
github.com/tidwall/btree v1.8.1
go.uber.org/mock v0.6.0
golang.org/x/crypto v0.43.0
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6
golang.org/x/sync v0.17.0
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c
google.golang.org/grpc v1.76.0
Expand Down Expand Up @@ -116,7 +121,6 @@ require (
github.com/cockroachdb/redact v1.1.6 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
github.com/cometbft/cometbft-db v0.14.1 // indirect
github.com/cosmos/iavl v1.2.6 // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down Expand Up @@ -195,7 +199,6 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.16 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tidwall/btree v1.8.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
github.com/zeebo/errs v1.4.0 // indirect
Expand All @@ -217,7 +220,6 @@ require (
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.21.0 // indirect
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
golang.org/x/net v0.46.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
golang.org/x/sys v0.37.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alitto/pond/v2 v2.5.0 h1:vPzS5GnvSDRhWQidmj2djHllOmjFExVFbDGCw1jdqDw=
github.com/alitto/pond/v2 v2.5.0/go.mod h1:xkjYEgQ05RSpWdfSd1nM3OVv7TBhLdy7rMp3+2Nq+yE=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
Expand Down Expand Up @@ -270,6 +272,7 @@ github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/emicklei/dot v1.8.0 h1:HnD60yAKFAevNeT+TPYr9pb8VB9bqdeSo0nzwIW6IOI=
github.com/emicklei/dot v1.8.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
Expand Down
16 changes: 16 additions & 0 deletions iavl/changeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,19 @@ func (cr *Changeset) TotalBytes() int {
func (cr *Changeset) HasOrphans() bool {
return cr.info.LeafOrphans > 0 || cr.info.BranchOrphans > 0
}

func (cr *Changeset) ResolveRoot(version uint32) (*NodePointer, error) {
startVersion := cr.info.StartVersion
endVersion := startVersion + uint32(cr.versionsData.Count()) - 1
if version < startVersion || version > endVersion {
return nil, fmt.Errorf("version %d out of range for changeset (have %d..%d)", version, startVersion, endVersion)
}
vi, err := cr.getVersionInfo(version)
if err != nil {
return nil, err
}
return &NodePointer{
id: vi.RootID,
store: cr,
}, nil
}
Loading
Loading