From 3acf558199147f1e24dbe138e2ead6ead9e49ece 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 380506 -> 380541 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 ead865959e..089cf4d2f9 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 04feb0f6a1..f46426b93d 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 5e5c8d43dc..de2a7af4ae 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 86e9a47b7c..6663c478c0 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 8f030d1fee28902f54fcb7b0fbca3040b720a132..c4d718328d624e1dbaa1d38ff7efd32e9776f525 100644 GIT binary patch delta 119 zcmcaLNBr*`@eRLLv3$D9#5H~66K2Wj0j8`1o7Gpp7GT`JS$NM)Mn<#AZ}-ZwI59~u zZsyw8r@?q)^UP;#DvajS7jQ8)$nkQqvhXo+a0szHVN^Eb;^SfibD2SW71MTkZbl$x Q0%B$$X4x*!&1!uZ00?6u#{d8T delta 90 zcmex6NBq_t@eRLLv7Eok#5G;;Ka=G2J5|gAo7Gpp7GT-U!X-TU;|bx-ntKj2G8#>O tyH|EI-@ZN##+94rK4Vj1RGz+si?N~InVS)anShuXh*`EfbF*3<1_0YmB0c~B diff --git a/proto/penumbra/penumbra/core/component/dex/v1/dex.proto b/proto/penumbra/penumbra/core/component/dex/v1/dex.proto index 1076e03ecf..af0baaf886 100644 --- a/proto/penumbra/penumbra/core/component/dex/v1/dex.proto +++ b/proto/penumbra/penumbra/core/component/dex/v1/dex.proto @@ -226,7 +226,7 @@ message BatchSwapOutputData { // The trading pair associated with the batch swap. TradingPair trading_pair = 8; // The starting block height of the epoch for which the batch swap data is valid. - uint64 epoch_starting_height = 9; + uint64 epoch_starting_height = 9 [deprecated = true]; // The prefix (epoch, block) of the position where this batch swap occurred. uint64 sct_position_prefix = 10; }