Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the app version when state syncing #3818

Closed
evan-forbes opened this issue Aug 25, 2024 · 5 comments · Fixed by #3936
Closed

Handle the app version when state syncing #3818

evan-forbes opened this issue Aug 25, 2024 · 5 comments · Fixed by #3936
Assignees
Labels
statesync WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc

Comments

@evan-forbes
Copy link
Member

In:

we hacked around the issues of properly passing the app version to the kv store while mounting it for state sync

celestia-app/app/app.go

Lines 789 to 813 in ad250dd

// OfferSnapshot is a wrapper around the baseapp's OfferSnapshot method. It is
// needed to mount stores for the appropriate app version.
func (app *App) OfferSnapshot(req abci.RequestOfferSnapshot) abci.ResponseOfferSnapshot {
if app.IsSealed() {
// If the app is sealed, keys have already been mounted so this can
// delegate to the baseapp's OfferSnapshot.
return app.BaseApp.OfferSnapshot(req)
}
if app.upgradeHeightV2 == 0 {
app.Logger().Debug("v2 upgrade height not set, assuming app version 2")
app.mountKeysAndInit(v2)
return app.BaseApp.OfferSnapshot(req)
}
if req.Snapshot.Height >= uint64(app.upgradeHeightV2) {
app.Logger().Debug("snapshot height is greater than or equal to upgrade height, assuming app version 2")
app.mountKeysAndInit(v2)
return app.BaseApp.OfferSnapshot(req)
}
app.Logger().Debug("snapshot height is less than upgrade height, assuming app version 1")
app.mountKeysAndInit(v1)
return app.BaseApp.OfferSnapshot(req)
}

To close this issue, we should come up with a long term solution that works for all future app versions.

related to:

@evan-forbes evan-forbes added WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc statesync labels Aug 25, 2024
@rootulp
Copy link
Collaborator

rootulp commented Aug 26, 2024

Notes from meeting:

  1. Try to implement this in a way that isn't breaking for v2.x.
  2. Consider adding this field:
type RequestOfferSnapshot struct {
	Snapshot *Snapshot `protobuf:"bytes,1,opt,name=snapshot,proto3" json:"snapshot,omitempty"`
	AppHash  []byte    `protobuf:"bytes,2,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"`
+	AppVersion uint64
}
  1. If a node gets a snapshot that doesn't include AppVersion, fall back to the existing approach where we infer it based on --v2-upgrade-height
  2. [optional] since we're modifying ABCI types, consider adding AppVersion to RequestInfo

@cmwaters
Copy link
Contributor

If a node gets a snapshot that doesn't include AppVersion, fall back to the existing approach where we infer it based on --v2-upgrade-height

It can also potentially reject that snapshot and tendermint will search for another one but I think it's probably better that we fallback

I'm not sure if we should add it to the request like you've shown or to the Snapshot struct. I had a feeling when I looked at the plumbing that having it in the actual snapshot would be easier but would need to double check.

  1. Doesn't have to be coupled with this but it would be nice to have it with the multiapp and v3 as I believe this would clean up the initialisation a lot. (Remember we will still be doing this off the v0.34.x branch so regardless v2 will probably end up having the AppVersion in the request regardless of whether we use it or not

@rootulp
Copy link
Collaborator

rootulp commented Sep 5, 2024

Let's de-couple 4 from this issue: #3844

@rootulp rootulp self-assigned this Sep 9, 2024
@rootulp
Copy link
Collaborator

rootulp commented Sep 12, 2024

Notes from investigation:

@rootulp
Copy link
Collaborator

rootulp commented Sep 26, 2024

After #3871 merges to v2.x, we need to forward-port it to main.

rootulp added a commit to celestiaorg/celestia-core that referenced this issue Sep 30, 2024
rootulp added a commit that referenced this issue Oct 2, 2024
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
```
mergify bot pushed a commit that referenced this issue Oct 2, 2024
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
@rootulp rootulp closed this as completed in c7f26d6 Oct 4, 2024
rach-id pushed a commit to celestiaorg/celestia-core that referenced this issue Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
statesync WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants