-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(store/v2): simplify genesis flow (#22435)
Co-authored-by: Marko <marko@baricevic.me> (cherry picked from commit 43e28b4) # Conflicts: # core/CHANGELOG.md # core/store/changeset.go # runtime/v2/go.mod # runtime/v2/go.sum # server/v2/cometbft/go.mod # server/v2/cometbft/go.sum # server/v2/go.mod # server/v2/go.sum # server/v2/store/server.go # simapp/v2/go.mod # simapp/v2/go.sum # store/v2/commitment/iavl/tree.go # store/v2/commitment/mem/tree.go # store/v2/commitment/store.go # store/v2/commitment/store_bench_test.go # store/v2/commitment/store_test_suite.go # store/v2/commitment/tree.go # store/v2/database.go # store/v2/go.mod # store/v2/go.sum # store/v2/internal/encoding/changeset_test.go # store/v2/migration/manager.go # store/v2/migration/manager_test.go # store/v2/mock/db_mock.go # store/v2/pruning/manager.go # store/v2/pruning/manager_test.go # store/v2/root/builder.go # store/v2/root/migrate_test.go # store/v2/root/store.go # store/v2/root/store_mock_test.go # store/v2/root/store_test.go # store/v2/root/upgrade_test.go # store/v2/storage/storage_bench_test.go # store/v2/storage/storage_test_suite.go # store/v2/storage/store.go # store/v2/store.go # tests/go.mod # tests/go.sum # tests/integration/v2/app.go
- Loading branch information
1 parent
a045812
commit fe87e5c
Showing
44 changed files
with
8,464 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
<!-- | ||
Guiding Principles: | ||
Changelogs are for humans, not machines. | ||
There should be an entry for every single version. | ||
The same types of changes should be grouped. | ||
Versions and sections should be linkable. | ||
The latest version comes first. | ||
The release date of each version is displayed. | ||
Mention whether you follow Semantic Versioning. | ||
Usage: | ||
Change log entries are to be added to the Unreleased section under the | ||
appropriate stanza (see below). Each entry should ideally include a tag and | ||
the Github issue reference in the following format: | ||
* (<tag>) \#<issue-number> message | ||
The issue numbers will later be link-ified during the release process so you do | ||
not have to worry about including a link manually, but you can if you wish. | ||
Types of changes (Stanzas): | ||
"Features" for new features. | ||
"Improvements" for changes in existing functionality. | ||
"Deprecated" for soon-to-be removed features. | ||
"Bug Fixes" for any bug fixes. | ||
"Client Breaking" for breaking Protobuf, gRPC and REST routes used by end-users. | ||
"CLI Breaking" for breaking CLI commands. | ||
"API Breaking" for breaking exported APIs used by developers building on SDK. | ||
Ref: https://keepachangelog.com/en/1.0.0/ | ||
--> | ||
|
||
# Changelog | ||
|
||
## [Unreleased] | ||
|
||
### API Breaking | ||
|
||
* [#22435](https://github.com/cosmos/cosmos-sdk/pull/22435) Add `Version uint64` field to `store.Changeset` and update `Changeset` constructors to accept a `version uint64` as their first argument. | ||
|
||
### Features | ||
|
||
* [#22326](https://github.com/cosmos/cosmos-sdk/pull/22326) Introduce codec package in order to facilitate removal of Cosmos SDK dependency in modules. | ||
* [*22267](https://github.com/cosmos/cosmos-sdk/pull/22267) Add `server.ConfigMap` and `server.ModuleConfigMap` to replace `server.DynamicConfig` in module configuration. | ||
|
||
## [v1.0.0-alpha.3](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv1.0.0-alpha.3) | ||
|
||
### Features | ||
|
||
* [#21719](https://github.com/cosmos/cosmos-sdk/pull/21719) Make `core/event` as a type alias of `schema/appdata`. | ||
|
||
## [v1.0.0-alpha.2](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv1.0.0-alpha.2) | ||
|
||
### Features | ||
|
||
* [#21635](https://github.com/cosmos/cosmos-sdk/pull/21635) Add `server.DynamicConfig` to abstract config providers (f.e Viper) | ||
|
||
## [v1.0.0-alpha.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv1.0.0-alpha.1) | ||
|
||
### Features | ||
|
||
* [#21531](https://github.com/cosmos/cosmos-sdk/pull/21531) Add `registry.AminoRegistrar` to register types on the amino codec from modules. | ||
* [#21222](https://github.com/cosmos/cosmos-sdk/pull/21222) Make `Iterator` a type alias so that `KVStore` is structurally typed. | ||
* [#21166](https://github.com/cosmos/cosmos-sdk/pull/21166) Comment out `appmodule.HasServices` to simplify dependencies. This interface is however still supported. | ||
* [#19953](https://github.com/cosmos/cosmos-sdk/pull/19953) Add transaction service. | ||
* [#18379](https://github.com/cosmos/cosmos-sdk/pull/18379) Add branch service. | ||
* [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit. | ||
* [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) Add `appmodule.Environment` interface to fetch different services | ||
* [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Add `appmodule.Migrations` interface to handle migrations | ||
* [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Add `router.Service` and add it in `appmodule.Environment` | ||
* [#19617](https://github.com/cosmos/cosmos-sdk/pull/19617) Server/v2 compatible interface: | ||
* Add DataBaseService to store non-consensus data in a database | ||
* Create V2 appmodule with v2 api for runtime/v2 | ||
* Introduce `Transaction.Tx` for use in runtime/v2 | ||
* Introduce `HasUpdateValidators` interface and `ValidatorUpdate` struct for validator updates | ||
* Introduce `HasTxValidation` interface for modules to register tx validation handlers | ||
* `HasGenesis` interface for modules to register import, export, validation and default genesis handlers. The new api works with `proto.Message` | ||
* Add `PreMsghandler`and `PostMsgHandler` for pre and post message hooks | ||
* Add `MsgHandler` as an alternative to grpc handlers | ||
* Provide separate `MigrationRegistrar` instead of grouping with `RegisterServices` | ||
* [#19758](https://github.com/cosmos/cosmos-sdk/pull/19758) Add `registry.InterfaceRegistrar` to interact with the interface registry in modules. | ||
|
||
### API Breaking Changes | ||
|
||
* [#19672](https://github.com/cosmos/cosmos-sdk/pull/19672) `PreBlock` now returns only an error for consistency with server/v2. The SDK has upgraded x/upgrade accordingly. | ||
* [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` to `x/tx`. | ||
* [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`. | ||
* [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`) | ||
* [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) `HasEventListeners` was removed from appmodule due to the fact that it was not used anywhere in the SDK nor implemented | ||
* [#17689](https://github.com/cosmos/cosmos-sdk/pull/17689) Move Comet service to return structs instead of interfaces. | ||
* `BlockInfo` was renamed to `Info` and `BlockInfoService` was renamed to `CometInfoService` | ||
* [#17693](https://github.com/cosmos/cosmos-sdk/pull/17693) Remove `appmodule.UpgradeModule` interface in favor of preblock | ||
|
||
## [v0.11.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.1) | ||
|
||
* [#21022](https://github.com/cosmos/cosmos-sdk/pull/21022) Upgrade depinject to v1.0.0. | ||
|
||
## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0) | ||
|
||
* [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface. | ||
|
||
## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0) | ||
|
||
* [#17383](https://github.com/cosmos/cosmos-sdk/pull/17383) Add `appmodule.UpgradeModule` interface. | ||
|
||
## [v0.9.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.9.0) | ||
|
||
* [#16739](https://github.com/cosmos/cosmos-sdk/pull/16739) Add `AppHash` to header.Info. | ||
|
||
## [v0.8.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.8.0) | ||
|
||
* [#15519](https://github.com/cosmos/cosmos-sdk/pull/15519) Update `comet.VoteInfo` for CometBFT v0.38. | ||
* [#16310](https://github.com/cosmos/cosmos-sdk/pull/16310) Add `gas.Service` and `gas.GasMeter` interfaces. | ||
|
||
## [v0.7.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.7.0) | ||
|
||
* [#15850](https://github.com/cosmos/cosmos-sdk/pull/15850) Add `comet` and `header` packages. | ||
* [#15923](https://github.com/cosmos/cosmos-sdk/pull/15923) Add `appmodule.HasPrepareCheckState` `appmodule.HasPrecommit` extension interfaces. | ||
* [#15434](https://github.com/cosmos/cosmos-sdk/pull/15434) Add `coin.ParseCoin` for parsing a coin from a string. | ||
* [#15999](https://github.com/cosmos/cosmos-sdk/pull/15999) Add `genesis.GenesisTxHandler` interface. | ||
|
||
## [v0.6.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.6.1) | ||
|
||
* [#15364](https://github.com/cosmos/cosmos-sdk/pull/15364) Add address codec to core. | ||
|
||
## [v0.6.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.6.0) | ||
|
||
* [#15045](https://github.com/cosmos/cosmos-sdk/pull/15045) Add error return parameter to `RegisterServices` method from `appmodule.HasServices` interface. | ||
* [#14859](https://github.com/cosmos/cosmos-sdk/pull/14859) Simplify event service interface. | ||
|
||
## [v0.5.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.5.1) | ||
|
||
* [#14686](https://github.com/cosmos/cosmos-sdk/pull/14686) Add event service. | ||
* [#14735](https://github.com/cosmos/cosmos-sdk/pull/14735) Specify event listener API. | ||
|
||
## [v0.5.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.5.0) | ||
|
||
* [#14604](https://github.com/cosmos/cosmos-sdk/pull/14604) Add begin/end block extension interfaces. | ||
* [#14605](https://github.com/cosmos/cosmos-sdk/pull/14605) Add register services extension interface. | ||
|
||
## [v0.4.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.4.1) | ||
|
||
* [#14329](https://github.com/cosmos/cosmos-sdk/pull/14329) Implement basic core API genesis source and target. | ||
|
||
## [v0.4.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.4.0) | ||
|
||
* [#14416](https://github.com/cosmos/cosmos-sdk/pull/14416) Update core to use cosmos-db instead of tm-db. | ||
* [#14326](https://github.com/cosmos/cosmos-sdk/pull/14326) Remove `appmodule.Service` from core. | ||
|
||
## [v0.3.4](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.3.4) | ||
|
||
* [#14223](https://github.com/cosmos/cosmos-sdk/pull/14223) Add genesis API. | ||
|
||
## [v0.3.3](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.3.3) | ||
|
||
* [#14227](https://github.com/cosmos/cosmos-sdk/pull/14227) Add store API. | ||
* [#13696](https://github.com/cosmos/cosmos-sdk/pull/13696) Update `FormatCoins` where empty coins are rendered as "zero". | ||
|
||
## [v0.3.2](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.3.2) | ||
|
||
* [#13631](https://github.com/cosmos/cosmos-sdk/pull/13631) Add ADR 033 (inter-module communication) Client interface. | ||
|
||
## [v0.3.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.3.1) | ||
|
||
* [#13306](https://github.com/cosmos/cosmos-sdk/pull/13306) Move `FormatCoins` to core. | ||
* [#13607](https://github.com/cosmos/cosmos-sdk/pull/13115) Add `AppModule` tag interface. | ||
|
||
## [v0.3.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.3.0) | ||
|
||
* [#13115](https://github.com/cosmos/cosmos-sdk/pull/13115) Update core module to depinject changes. | ||
|
||
## [v0.2.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.2.0) | ||
|
||
* [#12020](https://github.com/cosmos/cosmos-sdk/pull/12020) Use cosmossdk.io/depinject instead of container. | ||
* [#12367](https://github.com/cosmos/cosmos-sdk/pull/12367) Add support for golang_bindings in app.yaml. | ||
|
||
## [v0.1.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.1.0) | ||
|
||
* [#11914](https://github.com/cosmos/cosmos-sdk/pull/11914) Add core module with app config support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package store | ||
|
||
import ( | ||
"bytes" | ||
) | ||
|
||
// Changeset is a list of changes to be written to disk | ||
type Changeset struct { | ||
Version uint64 | ||
Changes []StateChanges | ||
} | ||
|
||
// StateChanges represents a set of changes to the state of an actor in storage. | ||
type StateChanges = struct { | ||
Actor []byte // actor represents the space in storage where state is stored, previously this was called a "storekey" | ||
StateChanges KVPairs // StateChanges is a list of key-value pairs representing the changes to the state. | ||
} | ||
|
||
// KVPairs represents a set of key-value pairs. | ||
type KVPairs = []KVPair | ||
|
||
// KVPair represents a change in a key and value of state. | ||
// Remove being true signals the key must be removed from state. | ||
type KVPair = struct { | ||
// Key defines the key being updated. | ||
Key []byte | ||
// Value defines the value associated with the updated key. | ||
Value []byte | ||
// Remove is true when the key must be removed from state. | ||
Remove bool | ||
} | ||
|
||
func NewChangeset(version uint64) *Changeset { | ||
return &Changeset{Version: version} | ||
} | ||
|
||
func NewChangesetWithPairs(version uint64, pairs map[string]KVPairs) *Changeset { | ||
changes := make([]StateChanges, len(pairs)) | ||
i := 0 | ||
for storeKey, kvPairs := range pairs { | ||
changes[i] = StateChanges{ | ||
Actor: []byte(storeKey), | ||
StateChanges: kvPairs, | ||
} | ||
i++ | ||
} | ||
return &Changeset{ | ||
Version: version, | ||
Changes: changes, | ||
} | ||
} | ||
|
||
// Size returns the number of key-value pairs in the batch. | ||
func (cs *Changeset) Size() int { | ||
cnt := 0 | ||
for _, pairs := range cs.Changes { | ||
cnt += len(pairs.StateChanges) | ||
} | ||
|
||
return cnt | ||
} | ||
|
||
// Add adds a key-value pair to the ChangeSet. | ||
func (cs *Changeset) Add(storeKey, key, value []byte, remove bool) { | ||
found := false | ||
for i, pairs := range cs.Changes { | ||
if bytes.Equal(storeKey, pairs.Actor) { | ||
pairs.StateChanges = append(pairs.StateChanges, KVPair{ | ||
Key: key, | ||
Value: value, | ||
Remove: remove, | ||
}) | ||
cs.Changes[i] = pairs | ||
found = true | ||
break | ||
} | ||
} | ||
|
||
if !found { | ||
cs.Changes = append(cs.Changes, StateChanges{ | ||
Actor: storeKey, | ||
StateChanges: []KVPair{{Key: key, Value: value, Remove: remove}}, | ||
}) | ||
} | ||
} | ||
|
||
// AddKVPair adds a KVPair to the ChangeSet. | ||
func (cs *Changeset) AddKVPair(storeKey []byte, pair KVPair) { | ||
found := false | ||
for i, pairs := range cs.Changes { | ||
if bytes.Equal(storeKey, pairs.Actor) { | ||
pairs.StateChanges = append(pairs.StateChanges, pair) | ||
cs.Changes[i] = pairs | ||
found = true | ||
break | ||
} | ||
} | ||
|
||
if !found { | ||
cs.Changes = append(cs.Changes, StateChanges{ | ||
Actor: storeKey, | ||
StateChanges: []KVPair{pair}, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
module cosmossdk.io/runtime/v2 | ||
|
||
go 1.23 | ||
|
||
// server v2 integration | ||
replace ( | ||
cosmossdk.io/api => ../../api | ||
cosmossdk.io/core => ../../core | ||
cosmossdk.io/core/testing => ../../core/testing | ||
cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager | ||
cosmossdk.io/server/v2/stf => ../../server/v2/stf | ||
cosmossdk.io/store/v2 => ../../store/v2 | ||
cosmossdk.io/x/tx => ../../x/tx | ||
) | ||
|
||
require ( | ||
cosmossdk.io/api v0.7.6 | ||
cosmossdk.io/core v1.0.0-alpha.5 | ||
cosmossdk.io/depinject v1.1.0 | ||
cosmossdk.io/log v1.4.1 | ||
cosmossdk.io/schema v0.3.0 | ||
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 | ||
cosmossdk.io/server/v2/stf v0.0.0-00010101000000-000000000000 | ||
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 | ||
cosmossdk.io/x/tx v1.0.0-alpha.1 | ||
github.com/cosmos/gogoproto v1.7.0 | ||
github.com/stretchr/testify v1.9.0 | ||
google.golang.org/grpc v1.68.0 | ||
google.golang.org/protobuf v1.35.1 | ||
) | ||
|
||
require ( | ||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect | ||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect | ||
cosmossdk.io/core/testing v0.0.0 // indirect | ||
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect | ||
github.com/DataDog/zstd v1.5.5 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
github.com/cockroachdb/errors v1.11.1 // indirect | ||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect | ||
github.com/cockroachdb/pebble v1.1.0 // indirect | ||
github.com/cockroachdb/redact v1.1.5 // indirect | ||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect | ||
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect | ||
github.com/cosmos/iavl v1.3.1 // indirect | ||
github.com/cosmos/ics23/go v0.11.0 // indirect | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/emicklei/dot v1.6.2 // indirect | ||
github.com/getsentry/sentry-go v0.27.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/btree v1.1.2 // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect | ||
github.com/hashicorp/go-metrics v0.5.3 // indirect | ||
github.com/hashicorp/golang-lru v1.0.2 // indirect | ||
github.com/klauspost/compress v1.17.9 // indirect | ||
github.com/kr/pretty v0.3.1 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/linxGnu/grocksdb v1.9.3 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mattn/go-sqlite3 v1.14.22 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/onsi/gomega v1.28.1 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/prometheus/client_golang v1.20.5 // indirect | ||
github.com/prometheus/client_model v0.6.1 // indirect | ||
github.com/prometheus/common v0.60.1 // indirect | ||
github.com/prometheus/procfs v0.15.1 // indirect | ||
github.com/rogpeppe/go-internal v1.12.0 // indirect | ||
github.com/rs/zerolog v1.33.0 // indirect | ||
github.com/spf13/cast v1.7.0 // indirect | ||
github.com/stretchr/objx v0.5.2 // indirect | ||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect | ||
github.com/tendermint/go-amino v0.16.0 // indirect | ||
github.com/tidwall/btree v1.7.0 // indirect | ||
golang.org/x/crypto v0.28.0 // indirect | ||
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect | ||
golang.org/x/net v0.30.0 // indirect | ||
golang.org/x/sync v0.9.0 // indirect | ||
golang.org/x/sys v0.27.0 // indirect | ||
golang.org/x/text v0.20.0 // indirect | ||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
sigs.k8s.io/yaml v1.4.0 // indirect | ||
) |
Oops, something went wrong.