From 65407f4b102ad0d94763c13a927ff4ddafe50f3f Mon Sep 17 00:00:00 2001 From: Lucas Meier Date: Fri, 19 Apr 2024 14:05:03 -0700 Subject: [PATCH] Depcrate epoch_starting_height in BSOD --- crates/bench/benches/swap_claim.rs | 1 - crates/bin/pcli/tests/proof.rs | 1 - .../dex/src/batch_swap_output_data.rs | 11 +++++------ .../src/component/circuit_breaker/value.rs | 1 - .../src/component/router/route_and_fill.rs | 1 - .../core/component/dex/src/component/tests.rs | 1 - .../component/dex/src/swap_claim/proof.rs | 4 ---- .../src/gen/penumbra.core.component.dex.v1.rs | 1 + .../proto/src/gen/proto_descriptor.bin.no_lfs | Bin 398157 -> 398192 bytes .../penumbra/core/component/dex/v1/dex.proto | 2 +- 10 files changed, 7 insertions(+), 16 deletions(-) diff --git a/crates/bench/benches/swap_claim.rs b/crates/bench/benches/swap_claim.rs index bbeb2ea233..cb1e3503ad 100644 --- a/crates/bench/benches/swap_claim.rs +++ b/crates/bench/benches/swap_claim.rs @@ -70,7 +70,6 @@ fn swap_claim_proving_time(c: &mut Criterion) { unfilled_2: Amount::from(50u64), height: height.into(), trading_pair: swap_plaintext.trading_pair, - epoch_starting_height: (epoch_duration * position.epoch()).into(), sct_position_prefix: position, }; let (lambda_1, lambda_2) = output_data.pro_rata_outputs((delta_1_i, delta_2_i)); diff --git a/crates/bin/pcli/tests/proof.rs b/crates/bin/pcli/tests/proof.rs index 61c0dcb53d..e84b1b2a0d 100644 --- a/crates/bin/pcli/tests/proof.rs +++ b/crates/bin/pcli/tests/proof.rs @@ -278,7 +278,6 @@ fn swap_claim_parameters_vs_current_swap_claim_circuit() { unfilled_2: Amount::from(50u64), height: height.into(), trading_pair: swap_plaintext.trading_pair, - epoch_starting_height: (epoch_duration * position.epoch()).into(), sct_position_prefix: position, }; let (lambda_1, lambda_2) = output_data.pro_rata_outputs((delta_1_i, delta_2_i)); diff --git a/crates/core/component/dex/src/batch_swap_output_data.rs b/crates/core/component/dex/src/batch_swap_output_data.rs index 8b29b6b8ac..6751161323 100644 --- a/crates/core/component/dex/src/batch_swap_output_data.rs +++ b/crates/core/component/dex/src/batch_swap_output_data.rs @@ -37,8 +37,6 @@ pub struct BatchSwapOutputData { pub height: u64, /// The trading pair associated with the batch swap. pub trading_pair: TradingPair, - /// The starting block height of the epoch for which the batch swap data is valid. - pub epoch_starting_height: u64, /// The position prefix where this batch swap occurred. The commitment index must be 0. pub sct_position_prefix: Position, } @@ -192,6 +190,7 @@ impl DomainType for BatchSwapOutputData { impl From for pb::BatchSwapOutputData { fn from(s: BatchSwapOutputData) -> Self { + #[allow(deprecated)] pb::BatchSwapOutputData { delta_1: Some(s.delta_1.into()), delta_2: Some(s.delta_2.into()), @@ -200,9 +199,12 @@ impl From for pb::BatchSwapOutputData { unfilled_1: Some(s.unfilled_1.into()), unfilled_2: Some(s.unfilled_2.into()), height: s.height, - epoch_starting_height: s.epoch_starting_height, trading_pair: Some(s.trading_pair.into()), sct_position_prefix: s.sct_position_prefix.into(), + // Deprecated fields we explicitly fill with defaults. + // We could instead use a `..Default::default()` here, but that would silently + // work if we were to add fields to the domain type. + epoch_starting_height: Default::default(), } } } @@ -306,7 +308,6 @@ impl TryFrom for BatchSwapOutputData { .trading_pair .ok_or_else(|| anyhow!("Missing trading_pair"))? .try_into()?, - epoch_starting_height: s.epoch_starting_height, sct_position_prefix, }) } @@ -424,7 +425,6 @@ mod tests { unfilled_2: Amount::from(1u32), height: 0, trading_pair, - epoch_starting_height: 0, sct_position_prefix: 0u64.into(), }, } @@ -446,7 +446,6 @@ mod tests { unfilled_2: Amount::from(50u64), height: 0u64, trading_pair, - epoch_starting_height: 0u64, sct_position_prefix: 0u64.into(), }; diff --git a/crates/core/component/dex/src/component/circuit_breaker/value.rs b/crates/core/component/dex/src/component/circuit_breaker/value.rs index b5545266a2..f911aa8b12 100644 --- a/crates/core/component/dex/src/component/circuit_breaker/value.rs +++ b/crates/core/component/dex/src/component/circuit_breaker/value.rs @@ -161,7 +161,6 @@ mod tests { unfilled_2: 0u64.into(), height: 1, trading_pair: pair_1.into_directed_trading_pair().into(), - epoch_starting_height: 0, sct_position_prefix: Default::default(), }, None, diff --git a/crates/core/component/dex/src/component/router/route_and_fill.rs b/crates/core/component/dex/src/component/router/route_and_fill.rs index f889ae1b8a..c48f99c083 100644 --- a/crates/core/component/dex/src/component/router/route_and_fill.rs +++ b/crates/core/component/dex/src/component/router/route_and_fill.rs @@ -91,7 +91,6 @@ pub trait HandleBatchSwaps: StateWrite + Sized { let epoch = self.get_current_epoch().await.expect("epoch is set"); let output_data = BatchSwapOutputData { height: block_height, - epoch_starting_height: epoch.start_height, trading_pair, delta_1, delta_2, diff --git a/crates/core/component/dex/src/component/tests.rs b/crates/core/component/dex/src/component/tests.rs index 1b77533150..cfebe53716 100644 --- a/crates/core/component/dex/src/component/tests.rs +++ b/crates/core/component/dex/src/component/tests.rs @@ -756,7 +756,6 @@ async fn swap_execution_tests() -> anyhow::Result<()> { unfilled_1: 0u32.into(), unfilled_2: 0u32.into(), height: 0, - epoch_starting_height: 0, trading_pair, sct_position_prefix: Default::default(), } diff --git a/crates/core/component/dex/src/swap_claim/proof.rs b/crates/core/component/dex/src/swap_claim/proof.rs index 7484e1d307..3dd7166512 100644 --- a/crates/core/component/dex/src/swap_claim/proof.rs +++ b/crates/core/component/dex/src/swap_claim/proof.rs @@ -366,7 +366,6 @@ impl DummyWitness for SwapClaimCircuit { unfilled_2: Amount::from(10u64), height: 0, trading_pair: swap_plaintext.trading_pair, - epoch_starting_height: 0, sct_position_prefix: Default::default(), }; let note_blinding_1 = Fq::from(1); @@ -650,7 +649,6 @@ mod tests { unfilled_2: test_bsod.unfilled_2, height: height.into(), trading_pair: swap_plaintext.trading_pair, - epoch_starting_height: (epoch_duration * position.epoch()).into(), sct_position_prefix: Default::default(), }; let (lambda_1, lambda_2) = output_data.pro_rata_outputs((delta_1_i, delta_2_i)); @@ -783,7 +781,6 @@ mod tests { unfilled_2: test_bsod.unfilled_2, height: height.into(), trading_pair: swap_plaintext.trading_pair, - epoch_starting_height: (epoch_duration * position.epoch()).into(), sct_position_prefix: Default::default() }; let (lambda_1, lambda_2) = output_data.pro_rata_outputs((delta_1_i, delta_2_i)); @@ -884,7 +881,6 @@ mod tests { unfilled_2: test_bsod.unfilled_2, height: height.into(), trading_pair: swap_plaintext.trading_pair, - epoch_starting_height: (epoch_duration * dummy_position.epoch()).into(), sct_position_prefix: Default::default() }; let (lambda_1, lambda_2) = output_data.pro_rata_outputs((delta_1_i, delta_2_i)); diff --git a/crates/proto/src/gen/penumbra.core.component.dex.v1.rs b/crates/proto/src/gen/penumbra.core.component.dex.v1.rs index f5b76bf5b9..0f734f0463 100644 --- a/crates/proto/src/gen/penumbra.core.component.dex.v1.rs +++ b/crates/proto/src/gen/penumbra.core.component.dex.v1.rs @@ -473,6 +473,7 @@ pub struct BatchSwapOutputData { #[prost(message, optional, tag = "8")] pub trading_pair: ::core::option::Option, /// The starting block height of the epoch for which the batch swap data is valid. + #[deprecated] #[prost(uint64, tag = "9")] pub epoch_starting_height: u64, /// The prefix (epoch, block) of the position where this batch swap occurred. diff --git a/crates/proto/src/gen/proto_descriptor.bin.no_lfs b/crates/proto/src/gen/proto_descriptor.bin.no_lfs index d585d7cfefda9ef6aad71be75e13c28d9506b9b6..716f2e547decf26bcf5fa145720cffd285ab82f6 100644 GIT binary patch delta 126 zcmX@ROya{bi4AMkvwXSE#5Fz9h(&Yr&GoMZSoX7U2~TExCcOFffy0c9W|QY1l4WsX zl3?7t=g?sdrl}7$H@;?7VKkrK&d=B&$IHda!pFqHA;j{8QQ3@(kBbe=Wd`w8OxxK6 W7=f4xh?#+y1&CRY^U(u085xZx&p#x)`M{yW v8cg5rPnTZ7D!qBZ>sQK*%G0~~85`QQ1Q>ys35c12m<5Pgw`&QoxiJF(mro