-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: sequencer check #22
fix: sequencer check #22
Conversation
Co-autored-by: Harry Law <[email protected]> (cherry picked from commit 1d27fde)
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
if !proto.Equal(&res.Validators[i], &req.Validators[i]) { | ||
return nil, fmt.Errorf("genesisValidators[%d] != req.Validators[%d] ", i, i) | ||
// Get the public key bytes for request and response validators at index i. | ||
// NB: The *capacity* of tye PubKey.Sum uint8 byte slice is inconsistent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// NB: The *capacity* of tye PubKey.Sum uint8 byte slice is inconsistent | |
// NB: The *capacity* of the PubKey.Sum uint8 byte slice is inconsistent |
Closing as this turned out to be a false alarm. The issue resulted from a misunderstanding in the application of the So long as the "power" is hard-coded in the Here's an updated version of the relevant section of # copy centralized sequencer address into genesis.json
# Note: validator and sequencer are used interchangeably here
ADDRESS=$(jq -r '.address' ~/.gm/config/priv_validator_key.json)
PUB_KEY=$(jq -r '.pub_key' ~/.gm/config/priv_validator_key.json)
# NB: Currently the stake => power calculation is constant; however, cosmos-sdk
# intends to make this parameterizable in the future.
POWER=$(yq ".validators[0].bonded" ./config.yml | sed 's,000000upokt,,')
NAME=$(yq ".validators[0].name" ./config.yml)
jq --argjson pubKey "$PUB_KEY" '.consensus["validators"]=[{"address": "'$ADDRESS'", "pub_key": $pubKey, "power": "'$POWER'", "name": "'$NAME'"}]' ~/.gm/config/genesis.json > temp.json && mv temp.json ~/.gm/config/genesis.json |
Description
Background
While attempting to migrate Pocket Network's rollkit-cosmos-sdk-based rollup, poktroll from rollkit/cosmos-sdk
v0.47.3-rollkit-v0.10.6-no-fraud-proofs
tov0.50.1-rollkit-v0.11.9-no-fraud-proofs
, we encountered an issue that seems to be related to importing the genesis.json during chain initialization.Since our appchain doesn't yet have any live networks running it, our simplified migration strategy (as opposed to applying the migration guide directly) is to re-scaffold substantial portions of the appchain (using ignite-cli), particularly with respect to app wiring and dependency injection. We plan to re-scaffold our modules next and then subsequently transplant our existing types, business logic, and tests into this fresh scaffold. However, before we even got to the module re-scaffolding step, we encountered this genesis import issue.
Initially, we encountered a slightly different issue that was coming from a
github.com/rollkit/rollkit
package and seems to be related to changes that were introduced between version:rollkit/types.NewFromGenesisDoc():64
The solution to this issue was to apply the same modification to the post-
ignite chain build
genesis.json (derived from our config.yml) as the rollkitinit-local.sh
script does (as per the rollkit docs):This inserts a
validators
property into the top-levelconsensus
property (not to be confused with that in thestaking
top-level property nor a top-levelvalidators
property):After making this modification to the genesis.json we were able to progress to the next issue (below), which we confirmed is downstream (in terms of execution / chain initialization) and seems to be rooted in an incompatibility between this modified genesis.json structure and how cosmos-sdk is trying to import and validate it.
Symptoms
Because the genesis now has a
consensus.validators
array, theif len(req.Validators) > 0
inbaseapp/abci.go:111
is evaluating to true, which causes the!proto.Equal(...)
assertion to be evaluated. This assertion is subsequently failing, seemingly for two distinct reasons.In the context above
req
is an object that represents the parsed genesis.json (which importantly includesgenutils
"gentx"s).res
represents an object that is the result of attempting to import the genesis (via a quite convoluted execution path) and ultimately apply validator updates to the validator set in the staking module. This mechanism provides an opportunity, apparently by design, to modifyres.Validators[0]
such that it may no longer matchreq.Validators[0]
, necessitating the need for this check and causing this issue.This process can be extended by providing a custom
module.InitChainer
function inapp.go
:1. Validator power mismatch:
Part of the
x/staking/keeper.Keeper#ApplyAndReturnValidatorSetUpdates()
method involves calculating the validator "power", as opposed to the number of staked tokens. It seems that the reduction of this number (viax/staking/types.Validator#ConsensusPower
) is causing a mismatch between the values of theres
andreq
validator slices:2. Validator pubkey slice capacity mismatch:
Even after correcting for the power mismatch, we still see the same error. The only remaining difference between the
req
andres
validator slices seems to be the capacity of the "internal"uint8
slices containing their public key bytes:Versions:
How to reproduce
Assuming go version
1.21.6
is the only go version in the$PATH
:After the repo finishes building, tilt will start, at which point you can press "space" to open the web UI.
The selecting the "sequencer" service will present the relevant logs which should contain the error as outlined above.
NOTE: If you see errors regarding go binaries and/or packages being compiled with a different version of go than 1.21.6, consider wiping the module cache with
go clean -modcache
.Not sure if ...
Based on the nature of the error, assuming we haven't overlooked some detail, I would expect that any rollkit-cosmos-sdk based project attempting a similar migration will also experience this same issue. This makes me question whether we did indeed overlook something as the only alternative I can imagine is that we may just be the first to try this migration using freshly scaffolded wiring and/or to get this far in the migration in general.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change