Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Feat/lazy load deployment" #2578

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

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

13 changes: 0 additions & 13 deletions console/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,6 @@ pub trait Network:

/// The maximum number of certificates in a batch.
const MAX_CERTIFICATES: u16;
/// The maximum number of transmissions per batch.
/// Note: This limit is set to 50 as part of safety measures to prevent DoS attacks.
/// This limit can be increased in the future as performance improves. Alternatively,
/// the rate of block production can be sped up to compensate for the limit set here.
const MAX_TRANSMISSIONS_PER_BATCH: u16 = 50;

/// The maximum number of stacks in the process
/// Allows for fast processing for blocks made from 4 maximally full rounds.
#[cfg(not(feature = "test"))]
const MAX_STACKS: usize = Self::MAX_TRANSMISSIONS_PER_BATCH as usize * Self::MAX_CERTIFICATES as usize * 4;
/// The maximum number of stacks in the process.
#[cfg(feature = "test")]
const MAX_STACKS: usize = 64;

/// The maximum number of bytes in a transaction.
// Note: This value must **not** be decreased as it would invalidate existing transactions.
Expand Down
2 changes: 1 addition & 1 deletion ledger/block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ pub mod test_helpers {
let inputs = [address.to_string(), format!("{amount}_u64")];

// Initialize the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Authorize the function.
let authorization =
process.authorize::<CurrentAleo, _>(&private_key, locator.0, locator.1, inputs.iter(), rng).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion ledger/block/src/transaction/deployment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function compute:
assert!(string.is_empty(), "Parser did not consume all of the string: '{string}'");

// Construct the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Compute the deployment.
let deployment = process.deploy::<CurrentAleo, _>(&program, rng).unwrap();
// Return the deployment.
Expand Down
4 changes: 2 additions & 2 deletions ledger/block/src/transaction/fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub mod test_helpers {
let priority_fee_in_microcredits = 1_000;

// Initialize the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Authorize the fee.
let authorization = process
.authorize_fee_private::<CurrentAleo, _>(
Expand Down Expand Up @@ -298,7 +298,7 @@ pub mod test_helpers {
let priority_fee = 1_000;

// Initialize the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Authorize the fee.
let authorization = process
.authorize_fee_public::<CurrentAleo, _>(
Expand Down
5 changes: 4 additions & 1 deletion ledger/narwhal/batch-header/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ impl<N: Network> BatchHeader<N> {
/// The maximum number of rounds to store before garbage collecting.
pub const MAX_GC_ROUNDS: usize = 100;
/// The maximum number of transmissions in a batch.
pub const MAX_TRANSMISSIONS_PER_BATCH: usize = N::MAX_TRANSMISSIONS_PER_BATCH as usize;
/// Note: This limit is set to 50 as part of safety measures to prevent DoS attacks.
/// This limit can be increased in the future as performance improves. Alternatively,
/// the rate of block production can be sped up to compensate for the limit set here.
pub const MAX_TRANSMISSIONS_PER_BATCH: usize = 50;
}

impl<N: Network> BatchHeader<N> {
Expand Down
2 changes: 1 addition & 1 deletion ledger/puzzle/epoch/src/synthesis/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function synthesize:
let program = Program::from_str(&program_string)?;

// Initialize a new process.
let process = Process::<N>::load_no_storage()?;
let process = Process::<N>::load()?;
// Initialize the stack with the synthesis challenge program.
let stack = Stack::new(&process, &program)?;

Expand Down
10 changes: 5 additions & 5 deletions ledger/test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function compute:
assert!(string.is_empty(), "Parser did not consume all of the string: '{string}'");

// Construct the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Compute the deployment.
let deployment = process.deploy::<CurrentAleo, _>(&program, rng).unwrap();
// Return the deployment.
Expand Down Expand Up @@ -230,7 +230,7 @@ pub fn sample_fee_private(deployment_or_execution_id: Field<CurrentNetwork>, rng
let priority_fee_in_microcredits = 1_000;

// Initialize the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Authorize the fee.
let authorization = process
.authorize_fee_private::<CurrentAleo, _>(
Expand Down Expand Up @@ -284,7 +284,7 @@ pub fn sample_fee_public(deployment_or_execution_id: Field<CurrentNetwork>, rng:
let priority_fee_in_microcredits = 1_000;

// Initialize the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Authorize the fee.
let authorization = process
.authorize_fee_public::<CurrentAleo, _>(
Expand Down Expand Up @@ -399,7 +399,7 @@ pub fn sample_large_execution_transaction(rng: &mut TestRng) -> Transaction<Curr
let program = large_transaction_program();

// Construct the process.
let mut process = synthesizer_process::Process::load_testing_only().unwrap();
let mut process = synthesizer_process::Process::load().unwrap();
// Add the program.
process.add_program(&program).unwrap();

Expand Down Expand Up @@ -510,7 +510,7 @@ fn sample_genesis_block_and_components_raw(
let inputs = [address.to_string(), format!("{amount}_u64")];

// Initialize the process.
let process = Process::load_testing_only().unwrap();
let process = Process::load().unwrap();
// Authorize the function.
let authorization =
process.authorize::<CurrentAleo, _>(&private_key, locator.0, locator.1, inputs.iter(), rng).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ aleo-cli = [ ]
async = [ "ledger-query/async", "synthesizer-process/async" ]
cuda = [ "algorithms/cuda" ]
history = [ "serde" ]
rocks = ["ledger-store/rocks", "synthesizer-process/rocks"]
rocks = [ "ledger-store/rocks" ]
serial = [
"console/serial",
"ledger-block/serial",
Expand Down
8 changes: 1 addition & 7 deletions synthesizer/process/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ version = "=1.0.0"

[dependencies.aleo-std]
version = "0.1.24"
features = ["storage"]
default-features = false

[dependencies.colored]
version = "2"
Expand All @@ -104,9 +104,6 @@ version = "2"
version = "2.0"
features = [ "serde" ]

[dependencies.lru]
version = "0.12"

[dependencies.once_cell]
version = "1.18"

Expand All @@ -127,9 +124,6 @@ optional = true
version = "1.0"
features = [ "preserve_order" ]

[dependencies.tracing]
version = "0.1"

[dev-dependencies.bincode]
version = "1.3"

Expand Down
4 changes: 2 additions & 2 deletions synthesizer/process/benches/stack_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn bench_stack_new(c: &mut Criterion) {
let mut rng = TestRng::default();

// Initialize a process.
let mut process = Process::load_testing_only().unwrap();
let mut process = Process::load().unwrap();

// Benchmark the base case.
c.bench_function("Depth 0 | Stack::new", |b| {
Expand Down Expand Up @@ -98,7 +98,7 @@ fn bench_stack_get_number_of_calls(c: &mut Criterion) {
const DEPTHS: [usize; 6] = [1, 2, 4, 8, 16, 30];

// Initialize a process.
let mut process = Process::load_testing_only().unwrap();
let mut process = Process::load().unwrap();

// Add the 0th program to the process.
add_program_at_depth(&mut process, 0);
Expand Down
4 changes: 2 additions & 2 deletions synthesizer/process/src/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn execution_cost_v1<N: Network>(process: &Process<N>, execution: &Execution

// Get the finalize cost for the root transition.
let stack = process.get_stack(transition.program_id())?;
let finalize_cost = cost_in_microcredits_v1(&stack, transition.function_name())?;
let finalize_cost = cost_in_microcredits_v1(stack, transition.function_name())?;

// Compute the total cost in microcredits.
let total_cost = storage_cost
Expand Down Expand Up @@ -522,7 +522,7 @@ function over_five_thousand:
let threshold = MainnetV0::EXECUTION_STORAGE_PENALTY_THRESHOLD;

// Test the cost of an execution.
let mut process = Process::load_testing_only().unwrap();
let mut process = Process::load().unwrap();

// Get the program.
let program = Program::from_str(SIZE_BOUNDARY_PROGRAM).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions synthesizer/process/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl<N: Network> Process<N> {
/// Adds the newly-deployed program.
/// This method assumes the given deployment **is valid**.
#[inline]
pub fn load_deployment(&self, deployment: &Deployment<N>) -> Result<()> {
let timer = timer!("Process::load_testing_only_deployment");
pub fn load_deployment(&mut self, deployment: &Deployment<N>) -> Result<()> {
let timer = timer!("Process::load_deployment");

// Compute the program stack.
let stack = Stack::new(self, deployment.program())?;
Expand Down
4 changes: 2 additions & 2 deletions synthesizer/process/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod tests {
let rng = &mut TestRng::default();

// Initialize the process.
let process = Process::<CurrentNetwork>::load_testing_only().unwrap();
let process = Process::<CurrentNetwork>::load().unwrap();

// Sample a private key.
let private_key = PrivateKey::<CurrentNetwork>::new(rng).unwrap();
Expand Down Expand Up @@ -124,7 +124,7 @@ mod tests {
let rng = &mut TestRng::default();

// Initialize the process.
let process = Process::<CurrentNetwork>::load_testing_only().unwrap();
let process = Process::<CurrentNetwork>::load().unwrap();

// Sample a private key.
let private_key = PrivateKey::new(rng).unwrap();
Expand Down
10 changes: 5 additions & 5 deletions synthesizer/process/src/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<N: Network> Process<N> {
// Retrieve the fee stack.
let fee_stack = self.get_stack(fee.program_id())?;
// Finalize the fee transition.
finalize_operations.extend(finalize_fee_transition(state, store, &fee_stack, fee)?);
finalize_operations.extend(finalize_fee_transition(state, store, fee_stack, fee)?);
lap!(timer, "Finalize transition for '{}/{}'", fee.program_id(), fee.function_name());

/* Finalize the deployment. */
Expand Down Expand Up @@ -110,15 +110,15 @@ impl<N: Network> Process<N> {
// Finalize the root transition.
// Note that this will result in all the remaining transitions being finalized, since the number
// of calls matches the number of transitions.
let mut finalize_operations = finalize_transition(state, store, &stack, transition, call_graph)?;
let mut finalize_operations = finalize_transition(state, store, stack, transition, call_graph)?;

/* Finalize the fee. */

if let Some(fee) = fee {
// Retrieve the fee stack.
let fee_stack = self.get_stack(fee.program_id())?;
// Finalize the fee transition.
finalize_operations.extend(finalize_fee_transition(state, store, &fee_stack, fee)?);
finalize_operations.extend(finalize_fee_transition(state, store, fee_stack, fee)?);
lap!(timer, "Finalize transition for '{}/{}'", fee.program_id(), fee.function_name());
}

Expand All @@ -144,7 +144,7 @@ impl<N: Network> Process<N> {
// Retrieve the stack.
let stack = self.get_stack(fee.program_id())?;
// Finalize the fee transition.
let result = finalize_fee_transition(state, store, &stack, fee);
let result = finalize_fee_transition(state, store, stack, fee);
finish!(timer, "Finalize transition for '{}/{}'", fee.program_id(), fee.function_name());
// Return the result.
result
Expand Down Expand Up @@ -496,7 +496,7 @@ function compute:
.unwrap();

// Initialize a new process.
let process = Process::load_testing_only().unwrap();
let mut process = Process::load().unwrap();
// Deploy the program.
let deployment = process.deploy::<CurrentAleo, _>(&program, rng).unwrap();

Expand Down
Loading