Skip to content

Commit

Permalink
Remove more unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-shashank committed Nov 1, 2023
1 parent 98e8c75 commit a009c45
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 72 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 0 additions & 31 deletions fil_actors_shared/src/v12/runtime/randomness.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_shared4::clock::ChainEpoch;
use fvm_shared4::randomness::RANDOMNESS_LENGTH;
use num_derive::FromPrimitive;
use serde_repr::*;

Expand All @@ -21,32 +19,3 @@ pub enum DomainSeparationTag {
PoStChainCommit = 9,
EvmPrevRandao = 10,
}

#[allow(unused)]
pub fn draw_randomness(
hasher: impl FnOnce(&[u8]) -> [u8; 32],
rbase: &[u8; RANDOMNESS_LENGTH],
pers: DomainSeparationTag,
round: ChainEpoch,
entropy: &[u8],
) -> [u8; RANDOMNESS_LENGTH] {
let mut data = Vec::with_capacity(RANDOMNESS_LENGTH + 8 + 8 + entropy.len());

// Append the personalization value
let i64_bytes = (pers as i64).to_be_bytes();
data.extend_from_slice(&i64_bytes);

// Append the randomness
data.extend_from_slice(rbase);

// Append the round
let i64_bytes = round.to_be_bytes();
data.extend_from_slice(&i64_bytes);

// Append the entropy
data.extend_from_slice(entropy);

hasher(&data)
//
// fvm::crypto::hash_blake2b(&data)
}
39 changes: 0 additions & 39 deletions fil_actors_shared/src/v12/util/batch_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,42 +98,3 @@ impl fmt::Display for BatchReturn {
f.write_str(&ret)
}
}

pub struct BatchReturnGen {
success_count: usize,
fail_codes: Vec<FailCode>,

// gen will only work if it has processed all of the expected batch
expect_count: usize,
}

impl BatchReturnGen {
pub fn new(expect_count: usize) -> Self {
BatchReturnGen {
success_count: 0,
fail_codes: Vec::new(),
expect_count,
}
}

pub fn add_success(&mut self) -> &mut Self {
self.success_count += 1;
self
}

pub fn add_fail(&mut self, code: ExitCode) -> &mut Self {
self.fail_codes.push(FailCode {
idx: (self.success_count + self.fail_codes.len()) as u32,
code,
});
self
}

pub fn gen(&self) -> BatchReturn {
assert_eq!(self.expect_count, self.success_count + self.fail_codes.len(), "programmer error, mismatched batch size {} and processed count {} batch return must include success/fail for all inputs", self.expect_count, self.success_count + self.fail_codes.len());
BatchReturn {
success_count: self.success_count as u32,
fail_codes: self.fail_codes.clone(),
}
}
}
2 changes: 0 additions & 2 deletions fil_actors_shared/src/v12/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0, MIT

pub use self::batch_return::BatchReturn;
pub use self::batch_return::BatchReturnGen;
pub use self::batch_return::FailCode;
pub use self::downcast::*;
pub use self::map::*;
Expand All @@ -12,7 +11,6 @@ pub use self::set::Set;
pub use self::set_multimap::SetMultimap;

mod batch_return;
pub mod cbor;
mod downcast;
mod map;
mod mapmap;
Expand Down

0 comments on commit a009c45

Please sign in to comment.