From 32055fd474845b688b3eb49b946f7985119797fd Mon Sep 17 00:00:00 2001 From: Chris Czub Date: Tue, 7 May 2024 15:48:08 -0400 Subject: [PATCH 1/2] Add migration for dex/ab/ values to store as proto-encoded --- crates/bin/pd/src/migrate/testnet74.rs | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/crates/bin/pd/src/migrate/testnet74.rs b/crates/bin/pd/src/migrate/testnet74.rs index 893387c9e4..014df0fcd1 100644 --- a/crates/bin/pd/src/migrate/testnet74.rs +++ b/crates/bin/pd/src/migrate/testnet74.rs @@ -37,11 +37,40 @@ async fn fix_arb_execution_outputs(delta: &mut StateDelta) -> anyhow:: Ok(()) } +/// Update base liquidity index values to be proto-encoded. Previously they were stored as big-endian +/// encoded amounts, but in https://github.com/penumbra-zone/penumbra/pull/4188 they were changed +/// to be proto-encoded. +/// +/// This will rewrite all values under the `dex/ab/` prefix to be proto-encoded. +async fn rewrite_base_liquidity_indices(delta: &mut StateDelta) -> anyhow::Result<()> { + let prefix_key = "dex/ab/".as_bytes(); + tracing::trace!(prefix_key = ?EscapedByteSlice(&prefix_key), "updating base liquidity index values"); + let mut liquidity_stream = delta.nonverifiable_prefix_raw(&prefix_key).boxed(); + + while let Some(r) = liquidity_stream.next().await { + let (key, raw_amount): (Vec, Vec) = r?; + tracing::info!(?key, raw_amount = ?EscapedByteSlice(&raw_amount), "migrating base liquidity index entry"); + + let amount = Amount::from_be_bytes(raw_amount.as_slice().try_into()?); + + // Store the correctly formatted new value: + delta.nonverifiable_put(key.clone(), amount); + tracing::info!( + key = ?EscapedByteSlice(&key), + raw_amount = ?EscapedByteSlice(&raw_amount), + ?amount, + "updated base liquidity index" + ); + } + + Ok(()) +} + /// Update the ordering of liquidity position indices to return in descending order (see #4189) /// /// Lookups for liquidity positions based on starting asset were ordered backwards /// and returning the positions with the least liquidity first. This migration -/// needs to modify the keys stored under the JMT `dex/ra/` prefix key to reverse +/// needs to modify the keys stored under the nonverifiable `dex/ra/` prefix key to reverse /// the ordering of the existing data. async fn update_lp_index_order(delta: &mut StateDelta) -> anyhow::Result<()> { let prefix_key = "dex/ra/".as_bytes(); @@ -81,11 +110,13 @@ async fn update_lp_index_order(delta: &mut StateDelta) -> anyhow::Resu /// This migration script is responsible for: /// /// - Updating the ordering of liquidity position indices to return in descending order (see #4189) -/// * JMT: `dex/ra/` +/// * nonverifiable: `dex/ra/` /// - Updating arb execution output amounts to include the input amount instead of reporting only profit (see #3790) /// * JMT: `dex/arb_execution/` /// - Add `AuctionParameters` to the chain state /// * JMT: `dex/auction_parameters` +/// - Update the base liquidity index values to be proto-encoded (see #4188) +/// * nonverifiable: `dex/ab/` pub async fn migrate( path_to_export: PathBuf, genesis_start: Option, @@ -117,6 +148,9 @@ pub async fn migrate( // Write auction parameters write_auction_parameters(&mut delta).await?; + // Rewrite base liquidity indices as proto-encoded + rewrite_base_liquidity_indices(&mut delta).await?; + delta.put_block_height(0u64); let post_upgrade_root_hash = storage.commit_in_place(delta).await?; tracing::info!(?post_upgrade_root_hash, "post-upgrade root hash"); From 7524efd4e327126cb71f21e0004399f7ac692024 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Tue, 7 May 2024 13:57:10 -0700 Subject: [PATCH 2/2] ci: fix lfs=true on check-all-crates I've seen several lfs-related CI failures today. We're landing PRs pretty rapidly, so I'm just adjusting the CI jobs and not debugging further right now. --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 09f9982ffc..ab70d3489a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -62,6 +62,8 @@ jobs: runs-on: buildjet-8vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 + with: + lfs: true - name: Load rust cache uses: astriaorg/buildjet-rust-cache@v2.5.1 - name: install cargo-hack