Skip to content

Commit b6c9635

Browse files
committed
apply alex's idea of not re-quantizing at all.
1 parent faa4873 commit b6c9635

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

actors/miner/src/deadline_state.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,12 @@ impl Deadlines {
108108
store: &BS,
109109
orig_deadline: &mut Deadline,
110110
dest_deadline: &mut Deadline,
111-
dest_quant: QuantSpec,
112111
partitions: &BitField,
113112
) -> anyhow::Result<()> {
114113
let mut orig_partitions = orig_deadline.partitions_amt(store)?;
115114
let mut dest_partitions = dest_deadline.partitions_amt(store)?;
116115

117-
// even though we're moving partitions intact, we still need to update from/to `Deadline` accordingly.
116+
// even though we're moving partitions intact, we still need to update orig/dest `Deadline` accordingly.
118117

119118
let first_dest_partition_idx = dest_partitions.count();
120119
for (i, orig_partition_idx) in partitions.iter().enumerate() {
@@ -128,13 +127,13 @@ impl Deadlines {
128127

129128
let dest_partition_idx = first_dest_partition_idx + i as u64;
130129

131-
moving_partition.adjust_for_move(store, &dest_quant)?;
130+
moving_partition.adjust_for_move(store)?;
132131

133132
let all_sectors = moving_partition.sectors.len();
134133
let live_sectors = moving_partition.live_sectors().len();
135134
let early_terminations = orig_deadline.early_terminations.get(orig_partition_idx);
136135

137-
// start updating from/to `Deadline` here
136+
// start updating orig/dest `Deadline` here
138137

139138
orig_deadline.total_sectors -= all_sectors;
140139
orig_deadline.live_sectors -= live_sectors;
@@ -162,16 +161,16 @@ impl Deadlines {
162161
let mut dest_expirations_epochs: Array<BitField, _> =
163162
Array::load(&dest_deadline.expirations_epochs, store)?;
164163
orig_expirations_epochs.for_each_mut(|orig_epoch, orig_bitfield| {
165-
let dest_epoch = dest_quant.quantize_up(orig_epoch as ChainEpoch);
164+
let dest_epoch = orig_epoch;
166165
let mut to_bitfield =
167-
dest_expirations_epochs.get(dest_epoch as u64)?.cloned().unwrap_or_default();
166+
dest_expirations_epochs.get(dest_epoch)?.cloned().unwrap_or_default();
168167
for (i, partition_id) in partitions.iter().enumerate() {
169168
if orig_bitfield.get(partition_id) {
170169
orig_bitfield.unset(partition_id);
171170
to_bitfield.set(first_dest_partition_idx + i as u64);
172171
}
173172
}
174-
dest_expirations_epochs.set(dest_epoch as u64, to_bitfield)?;
173+
dest_expirations_epochs.set(dest_epoch, to_bitfield)?;
175174

176175
if orig_bitfield.is_empty() {
177176
epochs_to_remove.push(orig_epoch);

actors/miner/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2841,8 +2841,6 @@ impl Actor {
28412841
.context_code(ExitCode::USR_ILLEGAL_STATE, "while removing partitions")?;
28422842
}
28432843

2844-
let dest_quant = state.quant_spec_for_deadline(policy, params.dest_deadline);
2845-
28462844
let mut dest_deadline =
28472845
deadlines.load_deadline(store, params.dest_deadline).context_code(
28482846
ExitCode::USR_ILLEGAL_STATE,
@@ -2853,7 +2851,6 @@ impl Actor {
28532851
store,
28542852
&mut orig_deadline,
28552853
&mut dest_deadline,
2856-
dest_quant,
28572854
&params.partitions,
28582855
)
28592856
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to move partitions")?;

actors/miner/src/partition_state.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,7 @@ impl Partition {
824824
}
825825

826826
// ajust epoch info of expirations_epochs and early_terminated within `Partition`
827-
pub fn adjust_for_move<BS: Blockstore>(
828-
&mut self,
829-
store: &BS,
830-
dest_quant: &QuantSpec,
831-
) -> anyhow::Result<()> {
827+
pub fn adjust_for_move<BS: Blockstore>(&mut self, store: &BS) -> anyhow::Result<()> {
832828
let orig_expirations_epochs: Array<ExpirationSet, _> =
833829
Array::load(&self.expirations_epochs, store)?;
834830

@@ -845,13 +841,11 @@ impl Partition {
845841
);
846842

847843
orig_expirations_epochs.for_each(|from_epoch, expire_set| {
848-
dest_expirations_epochs
849-
.set(dest_quant.quantize_up(from_epoch as ChainEpoch) as u64, expire_set.clone())?;
844+
dest_expirations_epochs.set(from_epoch, expire_set.clone())?;
850845
Ok(())
851846
})?;
852847
orig_early_terminations.for_each(|from_epoch, bitfield| {
853-
dest_early_terminations
854-
.set(dest_quant.quantize_up(from_epoch as ChainEpoch) as u64, bitfield.clone())?;
848+
dest_early_terminations.set(from_epoch, bitfield.clone())?;
855849
Ok(())
856850
})?;
857851
self.expirations_epochs = dest_expirations_epochs.flush()?;

actors/miner/src/testing.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,7 @@ impl ExpirationQueueStateSummary {
629629
let ret = expiration_queue.amt.for_each(|epoch, expiration_set| {
630630
let epoch = epoch as i64;
631631
let acc = acc.with_prefix(format!("expiration epoch {epoch}: "));
632-
let quant_up = quant.quantize_up(epoch);
633-
acc.require(quant_up == epoch, format!("expiration queue key {epoch} is not quantized, expected {quant_up}"));
634-
632+
635633
expiration_epochs.push(epoch);
636634

637635
let mut on_time_sectors_pledge = TokenAmount::zero();
@@ -643,8 +641,7 @@ impl ExpirationQueueStateSummary {
643641

644642
// check expiring sectors are still alive
645643
if let Some(sector) = live_sectors.get(&sector_number) {
646-
let target = quant.quantize_up(sector.expiration);
647-
acc.require(epoch >= target && (epoch-target)%quant.unit ==0 , format!("invalid expiration {epoch} for sector {sector_number}, expected {target}"));
644+
acc.require(epoch >= sector.expiration , format!("invalid expiration {epoch} for sector {sector_number}"));
648645
on_time_sectors_pledge += sector.initial_pledge.clone();
649646
} else {
650647
acc.add(format!("on time expiration sector {sector_number} isn't live"));

0 commit comments

Comments
 (0)