-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update prover to use the correct storage oracle (#446)
## What ❔ Making the FRI prover use the correct storage oracle ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`.
- Loading branch information
1 parent
283096c
commit 835dd82
Showing
5 changed files
with
85 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use zksync_types::zkevm_test_harness::zk_evm::abstractions::{ | ||
RefundType, RefundedAmounts, Storage, | ||
}; | ||
use zksync_types::{LogQuery, Timestamp}; | ||
|
||
#[derive(Debug)] | ||
pub struct StorageOracle<T> { | ||
inn: T, | ||
storage_refunds: std::vec::IntoIter<u32>, | ||
} | ||
|
||
impl<T> StorageOracle<T> { | ||
pub fn new(inn: T, storage_refunds: Vec<u32>) -> Self { | ||
Self { | ||
inn, | ||
storage_refunds: storage_refunds.into_iter(), | ||
} | ||
} | ||
} | ||
|
||
impl<T: Storage> Storage for StorageOracle<T> { | ||
fn estimate_refunds_for_write( | ||
&mut self, | ||
_monotonic_cycle_counter: u32, | ||
_partial_query: &LogQuery, | ||
) -> RefundType { | ||
let pubdata_bytes = self.storage_refunds.next().expect("Missing refund"); | ||
RefundType::RepeatedWrite(RefundedAmounts { | ||
pubdata_bytes, | ||
ergs: 0, | ||
}) | ||
} | ||
|
||
fn execute_partial_query(&mut self, monotonic_cycle_counter: u32, query: LogQuery) -> LogQuery { | ||
self.inn | ||
.execute_partial_query(monotonic_cycle_counter, query) | ||
} | ||
|
||
fn finish_frame(&mut self, timestamp: Timestamp, panicked: bool) { | ||
self.inn.finish_frame(timestamp, panicked) | ||
} | ||
|
||
fn start_frame(&mut self, timestamp: Timestamp) { | ||
self.inn.start_frame(timestamp) | ||
} | ||
} |