-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(statesync): extract app version from snapshot (#3871)
Closes #3818 ~~Blocked on celestiaorg/celestia-core#1477 I had to bump the celestia-core depedency to get a feature that I wanted. That implied upgrading Go and cosmos-sdk versions. ## Testing I verified that logs added in this PR show up when state syncing on Mocha. The logs show that the app version provided in the `OfferSnapshot` ABCI method was plumbed through correctly. ``` ./scripts/mocha.sh ... 2:44PM INF Offering snapshot to ABCI app format=2 hash="$�ڢ�\x1b� �zΊ\x15���`��왹\b^G:\x03+ߢޯ" height=2782000 module=statesync 2:44PM INF offering snapshot app_version=2 height=2782000 2:44PM INF mounting keys for snapshot app_version=2 ``` (cherry picked from commit 73793b9) # Conflicts: # .github/workflows/lint.yml # Makefile # docker/txsim/Dockerfile # go.mod # go.sum
- Loading branch information
1 parent
9f0ba4e
commit a357db5
Showing
15 changed files
with
454 additions
and
77 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 |
---|---|---|
|
@@ -22,10 +22,13 @@ jobs: | |
go.sum | ||
- uses: golangci/[email protected] | ||
with: | ||
<<<<<<< HEAD | ||
version: v1.59.1 | ||
======= | ||
version: v1.61.0 | ||
>>>>>>> 73793b96 (feat(statesync): extract app version from snapshot (#3871)) | ||
args: --timeout 10m | ||
github-token: ${{ secrets.github_token }} | ||
skip-pkg-cache: true | ||
if: env.GIT_DIFF | ||
|
||
# hadolint lints the Dockerfile | ||
|
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
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
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
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
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
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,66 @@ | ||
package app_test | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/celestiaorg/celestia-app/v2/app" | ||
"github.com/celestiaorg/celestia-app/v2/app/encoding" | ||
"github.com/celestiaorg/celestia-app/v2/test/util" | ||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/snapshots" | ||
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
abcitypes "github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
dbm "github.com/tendermint/tm-db" | ||
) | ||
|
||
func TestOfferSnapshot(t *testing.T) { | ||
t.Run("v1", func(t *testing.T) { | ||
testApp := createTestApp(t) | ||
request := createRequest() | ||
request.AppVersion = 1 | ||
resp := testApp.OfferSnapshot(request) | ||
assert.Equal(t, abcitypes.ResponseOfferSnapshot{Result: abcitypes.ResponseOfferSnapshot_ACCEPT}, resp) | ||
}) | ||
t.Run("v2", func(t *testing.T) { | ||
testApp := createTestApp(t) | ||
request := createRequest() | ||
request.AppVersion = 2 | ||
resp := testApp.OfferSnapshot(request) | ||
assert.Equal(t, abcitypes.ResponseOfferSnapshot{Result: abcitypes.ResponseOfferSnapshot_ACCEPT}, resp) | ||
}) | ||
} | ||
|
||
func createTestApp(t *testing.T) *app.App { | ||
db := dbm.NewMemDB() | ||
config := encoding.MakeConfig(app.ModuleEncodingRegisters...) | ||
upgradeHeight := int64(3) | ||
snapshotDir := filepath.Join(t.TempDir(), "data", "snapshots") | ||
snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir) | ||
require.NoError(t, err) | ||
snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) | ||
require.NoError(t, err) | ||
baseAppOption := baseapp.SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(10, 10)) | ||
testApp := app.New(log.NewNopLogger(), db, nil, 0, config, upgradeHeight, util.EmptyAppOptions{}, baseAppOption) | ||
require.NoError(t, err) | ||
response := testApp.Info(abcitypes.RequestInfo{}) | ||
require.Equal(t, uint64(0), response.AppVersion) | ||
return testApp | ||
} | ||
|
||
func createRequest() abcitypes.RequestOfferSnapshot { | ||
return abcitypes.RequestOfferSnapshot{ | ||
Snapshot: &abcitypes.Snapshot{ | ||
Height: 0x290400, | ||
Format: 0x2, | ||
Chunks: 0x15, | ||
Hash: []uint8{0xdd, 0x39, 0x7a, 0xb, 0xf7, 0x48, 0xb1, 0xb2, 0x40, 0x9a, 0x5f, 0x9, 0xd3, 0x59, 0x6f, 0x26, 0x85, 0x1f, 0x39, 0xb4, 0x69, 0x4e, 0x30, 0x45, 0x45, 0xc, 0x61, 0x65, 0x58, 0x19, 0xbd, 0x13}, | ||
Metadata: []uint8{0xa, 0x20, 0xe5, 0xd2, 0x9f, 0xa6, 0xad, 0xa9, 0xf5, 0x19, 0xb3, 0xd1, 0x60, 0xe4, 0x9d, 0x36, 0xfa, 0x85, 0x7c, 0x5, 0x1d, 0x63, 0xa6, 0x92, 0x12, 0xb5, 0xf8, 0x1e, 0x0, 0x78, 0x57, 0xef, 0xc9, 0xdb, 0xa, 0x20, 0x35, 0xcb, 0x42, 0xaa, 0x7e, 0x18, 0x1e, 0x2d, 0xb3, 0xf2, 0x60, 0xca, 0x42, 0xf8, 0xa9, 0x56, 0x17, 0x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0x20, 0xf0, 0x96, 0x1d, 0x71, 0x7f, 0xa1, 0xc0, 0xab, 0xbf, 0xb8, 0x90, 0xf0, 0xe1, 0x64, 0x1f, 0x6e, 0xdd, 0xbd, 0xe9, 0xb8, 0xc2, 0xf6, 0xf0, 0x2e, 0x8c, 0x76, 0xf3, 0x1a, 0xfe, 0x40, 0x93, 0x70, 0xa, 0x20, 0x1c, 0x51, 0xe9, 0xdf, 0x1d, 0x6, 0x28, 0xdf, 0x17, 0xda, 0x75, 0xf7, 0x83, 0x4e, 0xe6, 0x6e, 0xf1, 0x73, 0xcf, 0x3a, 0x55, 0x90, 0xb4, 0x28, 0x15, 0x13, 0x9e, 0x79, 0x5d, 0xd1, 0xd0, 0x33, 0xa, 0x20, 0xf2, 0xd2, 0x2f, 0x94, 0x1a, 0xf9, 0x61, 0x25, 0xb5, 0xb0, 0x82, 0xf9, 0x80, 0x11, 0x29, 0xf0, 0x38, 0xda, 0xb9, 0xb9, 0xe2, 0x6, 0x7b, 0x6a, 0x15, 0x87, 0xc4, 0x1d, 0x54, 0x2e, 0xca, 0x27}, | ||
}, | ||
AppHash: []byte("apphash"), | ||
AppVersion: 0, // unit tests will override this | ||
} | ||
} |
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
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
Oops, something went wrong.