Skip to content

Commit

Permalink
Depcrate epoch_starting_height in BSOD
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Apr 22, 2024
1 parent 4941307 commit 65407f4
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion crates/bench/benches/swap_claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion crates/bin/pcli/tests/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
11 changes: 5 additions & 6 deletions crates/core/component/dex/src/batch_swap_output_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -192,6 +190,7 @@ impl DomainType for BatchSwapOutputData {

impl From<BatchSwapOutputData> 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()),
Expand All @@ -200,9 +199,12 @@ impl From<BatchSwapOutputData> 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(),
}
}
}
Expand Down Expand Up @@ -306,7 +308,6 @@ impl TryFrom<pb::BatchSwapOutputData> for BatchSwapOutputData {
.trading_pair
.ok_or_else(|| anyhow!("Missing trading_pair"))?
.try_into()?,
epoch_starting_height: s.epoch_starting_height,
sct_position_prefix,
})
}
Expand Down Expand Up @@ -424,7 +425,6 @@ mod tests {
unfilled_2: Amount::from(1u32),
height: 0,
trading_pair,
epoch_starting_height: 0,
sct_position_prefix: 0u64.into(),
},
}
Expand All @@ -446,7 +446,6 @@ mod tests {
unfilled_2: Amount::from(50u64),
height: 0u64,
trading_pair,
epoch_starting_height: 0u64,
sct_position_prefix: 0u64.into(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion crates/core/component/dex/src/component/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
4 changes: 0 additions & 4 deletions crates/core/component/dex/src/swap_claim/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions crates/proto/src/gen/penumbra.core.component.dex.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ pub struct BatchSwapOutputData {
#[prost(message, optional, tag = "8")]
pub trading_pair: ::core::option::Option<TradingPair>,
/// 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.
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
2 changes: 1 addition & 1 deletion proto/penumbra/penumbra/core/component/dex/v1/dex.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 65407f4

Please sign in to comment.