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

Update core dependencies to v0.70.3 #839

Merged
merged 29 commits into from
Mar 28, 2024
Merged

Update core dependencies to v0.70.3 #839

merged 29 commits into from
Mar 28, 2024

Conversation

jessepinho
Copy link
Contributor

@jessepinho jessepinho commented Mar 26, 2024

In this PR

  • Update Cargo and NPM dependencies on core packages.
  • Fix various places where we were previously using epochs, but are now using block heights.
    • This includes unbonding tokens. Unbonding tokens used to be named like uunbonding_epoch_N_penumbravalid1abc123. Now, unbonding tokens refer to a start block height, rather than a start epoch, so they're of the form unbonding_start_at_N_penumbravalidabc123. Also, they now have multiple denom units, so the display denom just starts with unbonding_ rather than uunbonding.
  • Fix a bug with how we stored epochs.
    • Previously, we stored new epochs only at epoch transitions. However, this meant that the first epoch (index 0) was missing! So, I updated the block processor to create an initial epoch if we're starting sync at block height 0.

@jessepinho jessepinho force-pushed the jessepinho/update-core branch from 39754b8 to 1d7d38e Compare March 27, 2024 00:21
This was referenced Mar 27, 2024
@TalDerei
Copy link
Contributor

unblocked by v0.70.1 point release

@jessepinho jessepinho force-pushed the jessepinho/update-core branch from 1907382 to d3eb48e Compare March 27, 2024 18:14
@@ -1,6 +1,6 @@

PRAX=lkpmkhpnhknhmibgnmmhdhgdilepfghe
IDB_VERSION=30
IDB_VERSION=31
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed for the update to unbonding tokens, which now have a different symbol

penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.3", package = "penumbra-stake", default-features = false }
penumbra-tct = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.3", package = "penumbra-tct" }
penumbra-transaction = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.3", package = "penumbra-transaction", default-features = false }
penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.70.2", package = "penumbra-asset" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just updating v0.68.3 to v0.70.2 on all of these

@@ -273,7 +278,7 @@ export class BlockProcessor implements BlockProcessorInterface {

const isLastBlockOfEpoch = !!compactBlock.epochRoot;
if (isLastBlockOfEpoch) {
void this.handleEpochTransition(compactBlock.height, latestKnownBlockHeight);
await this.handleEpochTransition(compactBlock.height, latestKnownBlockHeight);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to await due to an unlikely, but possible, race condition. When we save a new epoch to the database during an epoch transition, we look in the database for the previous latest known epoch. We grab its epoch index, increment it by 1, then use that index for the new epoch we're saving to the database.

If that took a long time, for some reason, and in the meantime the block processor had already gotten to the next epoch, we could have two epochs with the same epoch index.

This change makes sure that epoch indexes increment in the correct order.

@@ -75,10 +75,11 @@ describe('AssetMetadataById request handler', () => {
expect(metadataByIdResponse.denomMetadata?.equals(metadataFromNode)).toBeTruthy();
});

test('should fail to get metadata when metadata not found in idb and node', async () => {
test('should return an empty response when metadata not found in idb and node', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's really no need to throw, since it's acceptable to return an empty response from this RPC method. So I changed the behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Response on other comment

@@ -458,12 +458,14 @@ export class IndexedDb implements IndexedDbInterface {
});
}

async addEpoch(startHeight: bigint, index?: bigint): Promise<void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're never actually using the index argument anywhere, so I just got rid of it.

Comment on lines -16 to -18
<ActionDetails.Row label='Epoch index'>
{value.startEpochIndex.toString()}
</ActionDetails.Row>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a little strange to me: the startEpochIndex property is deprecated, so we should no longer show it. Ideally, we'd show the unbonding start height instead – but that property doesn't exist on the Undelegate proto! So for now, we'll just hide this, and revisit this if/when core adds that property to the Undelegate action.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you leave the code here and just style it hidden or comment it out?

@@ -33,7 +33,7 @@ export const ValueViewComponent = ({
const value = view.valueView.value;
const metadata = view.valueView.value.metadata;
const amount = value.amount ?? new Amount();
const exponent = getDisplayDenomExponent(metadata);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reviewers: I could use some help here.

When a user clicks the Undelegate button, the transaction approval dialog opens. We try to fetch the metadata for the undelegation tokens they'll be getting, but that will always come back empty, since the unbonding token type is now specific to the block height at which unbonding starts. That is, the unbonding token name is unbonding_start_at_N_penumbravalid1..., where N is the block height that unbonding started at.

There will never be token metadata for an unbonding token until after the transaction has been committed to the chain, since the token type is created when the transaction is committed.

But that means that the undelegation tokens are shown as "Unknown asset" in the transaction approval dialog:
image

Perhaps we should generate the unbonding token metadata on the fly here? If so, could someone point me in the right direction for how to do that? (That said, I'd love to get this PR merged before handling that, since all delegation is blocked until this PR is merged.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another wrinkle to all this: this issue, where the metadata request always returns an empty response for an undelegation token that doesn't exist yet, wasn't happening before when undelegation tokens were tied to epochs rather than block heights.

I don't know how that's possible. We should have had the same problem back then, right? That is:

  1. We transition to a new epoch.
  2. Someone goes to undelegate tokens from a validator.
  3. Since no one else has undelegated tokens from that validator in this epoch yet, the metadata for uunbonding_epoch_N_... doesn't exist yet, so the metadata response is empty.
  4. getDisplayDenomExponent throws, because it's being passed undefined metadata.

And yet, this wasn't happening before — no error was being thrown. It only started with this change, where unbonding tokens are tied to block height rather than epoch index.

I'm investigating this, but it's a bit concerning since I don't understand why it worked before!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps we should generate the unbonding token metadata on the fly here?

The assetMetadataById rpc method feels like a good place to generate metadata for this edge case so web apps have meaningful display data here.

And yet, this wasn't happening before

Umm, no idea! 😅

let amount = amount
.ok_or_else(|| anyhow!("missing amount in delegation"))?
.try_into()?;
let rate_data: RateData = rate_data
.ok_or_else(|| anyhow!("missing rate data in delegation"))?
.try_into()?;
actions.push(rate_data.build_delegate(amount).into());
actions.push(rate_data.build_delegate(epoch.into(), amount).into());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The epoch in the rate data has been deprecated, so we have to pass it in now.

// it's done.
await this.updateValidatorInfos(0n);

await this.indexedDb.addEpoch(0n);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, we were skipping saving the first epoch to the database. This fixes that bug.

@jessepinho jessepinho changed the title WIP: Update core dependencies Update core dependencies Mar 27, 2024
@jessepinho jessepinho marked this pull request as ready for review March 27, 2024 23:03
Copy link
Collaborator

@grod220 grod220 left a comment

Choose a reason for hiding this comment

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

Wow, some really domain specific knowledge here 😅 . Good job! Left some comments.

packages/router/src/grpc/view-protocol-server/helpers.ts Outdated Show resolved Hide resolved
@@ -75,10 +75,11 @@ describe('AssetMetadataById request handler', () => {
expect(metadataByIdResponse.denomMetadata?.equals(metadataFromNode)).toBeTruthy();
});

test('should fail to get metadata when metadata not found in idb and node', async () => {
test('should return an empty response when metadata not found in idb and node', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Response on other comment

packages/storage/src/indexed-db/index.ts Show resolved Hide resolved
@@ -33,7 +33,7 @@ export const ValueViewComponent = ({
const value = view.valueView.value;
const metadata = view.valueView.value.metadata;
const amount = value.amount ?? new Amount();
const exponent = getDisplayDenomExponent(metadata);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps we should generate the unbonding token metadata on the fly here?

The assetMetadataById rpc method feels like a good place to generate metadata for this edge case so web apps have meaningful display data here.

And yet, this wasn't happening before

Umm, no idea! 😅

packages/wasm/crate/src/storage.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@grod220 grod220 left a comment

Choose a reason for hiding this comment

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

Ah, please also update the proving keys:

const VERSION_TAG = 'v0.68.0';

@conorsch conorsch changed the title Update core dependencies Update core dependencies to v0.70.3 Mar 28, 2024
@TalDerei
Copy link
Contributor

Are we waiting for the 0.71.0 point release later today?

@jessepinho jessepinho force-pushed the jessepinho/update-core branch from efb1341 to f596006 Compare March 28, 2024 18:24
@jessepinho jessepinho force-pushed the jessepinho/update-core branch from 06d4390 to d581b4f Compare March 28, 2024 18:52
@jessepinho jessepinho merged commit 8933117 into main Mar 28, 2024
6 checks passed
@jessepinho jessepinho deleted the jessepinho/update-core branch March 28, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants