Skip to content

Commit

Permalink
chore: update to latest SDK commit
Browse files Browse the repository at this point in the history
There were some API-breaking changes in this update, and we needed a new
patch to handle root store closing correctly. We are presumably calling
Close on the root store more than once, so that newest patch should be
removable with some care.
  • Loading branch information
mark-rushakoff committed Nov 8, 2024
1 parent 83814dc commit 40b18d3
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 20 deletions.
2 changes: 1 addition & 1 deletion _cosmosvendor/COSMOS_SDK.commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file may contain any number of comments (lines containing a # symbol)
# and must otherwise contain exactly ONE line with a cosmos-sdk commit to check out
# when the user calls the scripts/sync_sdk.bash script.
bf8c0da179c692935996695005160d8f2d701ab4
78b5cd4dbd08ae9adddf926dbdbf54129423445d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 6c19c8bd34f5b742aa2207f2b4e52867ff745a4a Mon Sep 17 00:00:00 2001
From 7b41d5b9894c41f90be0709a774595fa7a77ebbc Mon Sep 17 00:00:00 2001
From: Mark Rushakoff <[email protected]>
Date: Fri, 25 Oct 2024 15:35:39 -0400
Subject: [PATCH 1/4] chore: use replaces for cosmossdk.io/log/slog
Subject: [PATCH 1/5] chore: use replaces for cosmossdk.io/log/slog

We will have to try removing these in the future, but they shouldn't
hurt for now.
Expand All @@ -11,7 +11,7 @@ hurt for now.
2 files changed, 2 insertions(+)

diff --git a/server/v2/go.mod b/server/v2/go.mod
index 1e2e763424..ad92f6dd06 100644
index 94631d1bc3..ed2b129a6e 100644
--- a/server/v2/go.mod
+++ b/server/v2/go.mod
@@ -4,6 +4,7 @@ go 1.23
Expand All @@ -23,7 +23,7 @@ index 1e2e763424..ad92f6dd06 100644
cosmossdk.io/server/v2/stf => ./stf
cosmossdk.io/store/v2 => ../../store/v2
diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod
index 0e803ed0f8..49a516519b 100644
index 7c9beaf117..f3320f7dfe 100644
--- a/simapp/v2/go.mod
+++ b/simapp/v2/go.mod
@@ -250,6 +250,7 @@ require (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5b87319ad4b16cedc122e4f84da7de903806f594 Mon Sep 17 00:00:00 2001
From f7ccdda96cbe6d7c6879c81b7319c0edee853ad9 Mon Sep 17 00:00:00 2001
From: Andrew Gouin <[email protected]>
Date: Fri, 25 Oct 2024 16:25:31 -0600
Subject: [PATCH 2/4] fix: allow customizing query and tx flags
Subject: [PATCH 2/5] fix: allow customizing query and tx flags

---
client/flags/flags.go | 90 ++++++++++++++++++++++++++++++++++++++++---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 377b560898e5c2a536187b20207dec08f7526187 Mon Sep 17 00:00:00 2001
From c838e8410df8e110491a3ae3dd9fd84f7094392b Mon Sep 17 00:00:00 2001
From: Andrew Gouin <[email protected]>
Date: Sat, 26 Oct 2024 11:18:57 -0600
Subject: [PATCH 3/4] hack to fix height not passing through sdk client context
Subject: [PATCH 3/5] hack to fix height not passing through sdk client context

---
x/auth/types/account_retriever.go | 8 +++++++-
Expand Down
12 changes: 6 additions & 6 deletions _cosmosvendor/patches/0004-hack-force-respecting-home-flag.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5524d63cfd1bb4e0aa2c48c75a6be9723fa31aa1 Mon Sep 17 00:00:00 2001
From 3628bbde49acdb13b28a7e7f60c0d485f77bf5be Mon Sep 17 00:00:00 2001
From: Mark Rushakoff <[email protected]>
Date: Wed, 30 Oct 2024 11:24:17 -0400
Subject: [PATCH 4/4] hack: force respecting home flag
Subject: [PATCH 4/5] hack: force respecting home flag

For some unclear reason, the wiring with gcosmos is not allowing the
flags to be respected in at least these three commands, and they try to
Expand All @@ -20,7 +20,7 @@ index 10d9db0cdc..9e8b3a0672 100644
@@ -24,6 +24,14 @@ func CollectGenTxsCmd(validator func([]transaction.Msg) error) *cobra.Command {
RunE: func(cmd *cobra.Command, _ []string) error {
config := client.GetConfigFromCmd(cmd)

+ if config.RootDir == "" {
+ var err error
+ config.RootDir, err = cmd.Flags().GetString("home")
Expand All @@ -31,15 +31,15 @@ index 10d9db0cdc..9e8b3a0672 100644
+
clientCtx := client.GetClientContextFromCmd(cmd)
cdc := clientCtx.Codec

diff --git a/x/genutil/client/cli/genaccount.go b/x/genutil/client/cli/genaccount.go
index 938e711b3a..300ba9e207 100644
--- a/x/genutil/client/cli/genaccount.go
+++ b/x/genutil/client/cli/genaccount.go
@@ -39,6 +39,14 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
clientCtx := client.GetClientContextFromCmd(cmd)
config := client.GetConfigFromCmd(cmd)

+ if config.RootDir == "" {
+ var err error
+ config.RootDir, err = cmd.Flags().GetString("home")
Expand Down Expand Up @@ -71,6 +71,6 @@ index c56c772afc..8958c74d48 100644
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
--
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 2e9d9df5993e2f4b48815b9e5af67fb7964080b8 Mon Sep 17 00:00:00 2001
From: Mark Rushakoff <[email protected]>
Date: Fri, 8 Nov 2024 11:29:19 -0500
Subject: [PATCH 5/5] chore: make root store Close idempotent

We will see about removing this later, but currently is it necessary to
get gcosmos to shut down properly.
---
store/v2/root/store.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/store/v2/root/store.go b/store/v2/root/store.go
index 59363e2fb3..bc7139a8d7 100644
--- a/store/v2/root/store.go
+++ b/store/v2/root/store.go
@@ -88,8 +88,13 @@ func New(
// Close closes the store and resets all internal fields. Note, Close() is NOT
// idempotent and should only be called once.
func (s *Store) Close() (err error) {
- err = errors.Join(err, s.stateStorage.Close())
- err = errors.Join(err, s.stateCommitment.Close())
+ if s.stateStorage != nil {
+ err = errors.Join(err, s.stateStorage.Close())
+ }
+ if s.stateCommitment != nil {
+ err = errors.Join(err, s.stateCommitment.Close())
+ }
+
err = errors.Join(err, s.dbCloser.Close())

s.stateStorage = nil
--
2.47.0

6 changes: 6 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cel.dev/expr v0.15.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg=
cel.dev/expr v0.16.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg=
cel.dev/expr v0.16.1/go.mod h1:AsGA5zb3WruAEQeQng1RZdGEXmBj0jvMWh6l5SnNuC8=
cloud.google.com/go v0.0.0-20170206221025-ce650573d812/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.112.2/go.mod h1:iEqjp//KquGIJV/m+Pk3xecgKNhV+ry+vVTsy4TbDms=
cloud.google.com/go v0.113.0/go.mod h1:glEqlogERKYeePz6ZdkcLJ28Q2I6aERgDDErBg9GzO8=
Expand Down Expand Up @@ -470,6 +471,7 @@ github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XP
github.com/cncf/xds/go v0.0.0-20240318125728-8a4994d93e50/go.mod h1:5e1+Vvlzido69INQaVO6d87Qn543Xr6nooe9Kz7oBFM=
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
Expand Down Expand Up @@ -1103,6 +1105,7 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
Expand All @@ -1122,6 +1125,7 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -1189,6 +1193,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v0.0.0-20170208002647-2a6bf6142e96/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
Expand Down
14 changes: 9 additions & 5 deletions gserver/internal/gsi/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ func (d *Driver) handleInitialization(
return false
}

// SetInitialVersion followed by WorkingHash,
// SetInitialVersion(initialHeight - 1) followed by Commit,
// and passing that hash as the initial app state hash,
// is what the comet server code does.
if err := s.SetInitialVersion(req.Genesis.InitialHeight); err != nil {
if err := s.SetInitialVersion(req.Genesis.InitialHeight - 1); err != nil {
d.log.Warn("Failed to set initial version", "err", err)
return false
}
Expand All @@ -252,7 +252,8 @@ func (d *Driver) handleInitialization(
d.log.Warn("Failed to set get state changes from genesis state", "err", err)
return false
}
stateRoot, err := s.WorkingHash(&store.Changeset{
stateRoot, err := s.Commit(&store.Changeset{
Version: req.Genesis.InitialHeight - 1,
Changes: stateChanges,
})
if err != nil {
Expand Down Expand Up @@ -345,7 +346,7 @@ func (d *Driver) handleFinalization(ctx context.Context, req tmdriver.FinalizeBl
// TODO: don't hardcode the initial height.
const initialHeight = 1
if req.Header.Height == initialHeight {
appHash, err := d.sdkStore.Commit(store.NewChangeset())
appHash, err := d.sdkStore.Commit(store.NewChangeset(initialHeight))
if err != nil {
d.log.Warn("Failed to commit new changeset for initial height", "err", err)
return false
Expand Down Expand Up @@ -588,7 +589,10 @@ func (d *Driver) handleFinalization(ctx context.Context, req tmdriver.FinalizeBl
d.log.Warn("Failed to get state changes", "err", err)
return false
}
appHash, err := d.sdkStore.Commit(&store.Changeset{Changes: stateChanges})
appHash, err := d.sdkStore.Commit(&store.Changeset{
Version: req.Header.Height,
Changes: stateChanges,
})
if err != nil {
d.log.Warn("Failed to commit state changes", "err", err)
return false
Expand Down

0 comments on commit 40b18d3

Please sign in to comment.