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

fix: prevent panic on chain replay #1197

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

fix: prevent panic on chain replay #1197

wants to merge 5 commits into from

Conversation

karlem
Copy link
Contributor

@karlem karlem commented Nov 6, 2024

Close #1196

Removing the dependency on the CometBFT client in favor of caching. When CometBFT is catching up—replaying from the beginning of the chain to synchronize with the ABCI app—it does not start the RPC API. Unfortunately, our ABCI app relied on the API during consensus events, which made it impossible to replay the chain.

THIS PR is a hot fix and it is not ready to be merged!

@karlem karlem requested a review from a team as a code owner November 6, 2024 20:28
fendermint/app/src/app.rs Outdated Show resolved Hide resolved
fendermint/app/src/app.rs Outdated Show resolved Hide resolved
fendermint/app/src/validators.rs Outdated Show resolved Hide resolved
@karlem
Copy link
Contributor Author

karlem commented Nov 14, 2024

@LePremierHomme could you have another look please?

Copy link
Contributor

@cryptoAtwill cryptoAtwill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlem A quick question, how will the cache be recovered after crashes? Seems not queried when booting?

let keys = self.public_keys.read().unwrap();
keys.get(id).copied()
}
fn fendermint_pub_key_from_tendermint_pub_key(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might have a function like this somewhere in the codebase.

if *id == validator.address {
pubkey = Some(key);
for (id, key) in public_keys {
if let Ok(fendermint_key) = fendermint_pub_key_from_tendermint_pub_key(&key) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth warn or error for the else, it should always be Ok, but if not, then something is generally wrong.

Some(consensus_params)
// Updates the validator cache with the new validator set.
let validators_ids_with_keys: Vec<(TendermintAccountId, TendermintPublicKey)> =
validator_updates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i rmb correctly, validator_updates is the power change, so it's about changes, not setting validators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. In that case where would be a good place to get the validator changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we just need to check if the power is 0, that means the validator is removed, we should purge instead. See:

let delete = Validator {
. Else it's just an upsert.

@karlem
Copy link
Contributor Author

karlem commented Nov 14, 2024

@karlem A quick question, how will the cache be recovered after crashes? Seems not queried when booting?

Yeah good point. We would loose it after the crash. Do you think maybe saving it to the app state might be a way to go?

@cryptoAtwill
Copy link
Contributor

@karlem The rabbit hole gets deeper. But I think it's possible to read the state during boot up. The validators and gas limits are all stored in the contract or actor, so technically we can call the getters from the store directly.

@raulk
Copy link
Contributor

raulk commented Nov 15, 2024

@cryptoAtwill that's a good point; it would also take us one tiny step closer to our desired end state of having as much logic as possible in on-chain actors.

@karlem
Copy link
Contributor Author

karlem commented Nov 15, 2024

@cryptoAtwill Yeah, I think working with the contract makes more sense than this. I would ditch this in favor of using the contracts, as they are part of the app state—much more solid than this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
4 participants