-
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.
feat(vm)!: Update Refund model (#181)
# What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## 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`. Signed-off-by: Danil <[email protected]>
- Loading branch information
1 parent
fe2d6ad
commit 92b6f59
Showing
137 changed files
with
11,929 additions
and
166 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
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,48 @@ | ||
use crate::glue::tracer::IntoVmVirtualBlocksTracer; | ||
use vm_latest::{CallTracer, StorageInvocations, ValidationTracer}; | ||
use zksync_state::WriteStorage; | ||
|
||
impl<S, H> IntoVmVirtualBlocksTracer<S, H> for StorageInvocations | ||
where | ||
H: crate::HistoryMode, | ||
S: WriteStorage, | ||
{ | ||
fn vm_virtual_blocks(&self) -> Box<dyn vm_virtual_blocks::VmTracer<S, H::VmVirtualBlocksMode>> { | ||
Box::new(vm_virtual_blocks::StorageInvocations::new(self.limit)) | ||
} | ||
} | ||
|
||
impl<S, H> IntoVmVirtualBlocksTracer<S, H> for CallTracer<H::VmVirtualBlocksRefundsEnhancement> | ||
where | ||
H: crate::HistoryMode + 'static, | ||
S: WriteStorage, | ||
{ | ||
fn vm_virtual_blocks(&self) -> Box<dyn vm_virtual_blocks::VmTracer<S, H::VmVirtualBlocksMode>> { | ||
Box::new(vm_virtual_blocks::CallTracer::new( | ||
self.result.clone(), | ||
H::VmVirtualBlocksMode::default(), | ||
)) | ||
} | ||
} | ||
|
||
impl<S, H> IntoVmVirtualBlocksTracer<S, H> | ||
for ValidationTracer<H::VmVirtualBlocksRefundsEnhancement> | ||
where | ||
H: crate::HistoryMode + 'static, | ||
S: WriteStorage, | ||
{ | ||
fn vm_virtual_blocks(&self) -> Box<dyn vm_virtual_blocks::VmTracer<S, H::VmVirtualBlocksMode>> { | ||
let params = self.params(); | ||
Box::new(vm_virtual_blocks::ValidationTracer::new( | ||
vm_virtual_blocks::ValidationTracerParams { | ||
user_address: params.user_address, | ||
paymaster_address: params.paymaster_address, | ||
trusted_slots: params.trusted_slots, | ||
trusted_addresses: params.trusted_addresses, | ||
trusted_address_slots: params.trusted_address_slots, | ||
computational_gas_limit: params.computational_gas_limit, | ||
}, | ||
self.result.clone(), | ||
)) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
core/lib/multivm/src/glue/types/vm/bytecompression_result.rs
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,33 @@ | ||
use crate::glue::{GlueFrom, GlueInto}; | ||
use vm_latest::{BytecodeCompressionError, VmExecutionResultAndLogs}; | ||
|
||
impl GlueFrom<vm_virtual_blocks::BytecodeCompressionError> for BytecodeCompressionError { | ||
fn glue_from(value: vm_virtual_blocks::BytecodeCompressionError) -> Self { | ||
match value { | ||
vm_virtual_blocks::BytecodeCompressionError::BytecodeCompressionFailed => { | ||
Self::BytecodeCompressionFailed | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl | ||
GlueFrom< | ||
Result< | ||
vm_virtual_blocks::VmExecutionResultAndLogs, | ||
vm_virtual_blocks::BytecodeCompressionError, | ||
>, | ||
> for Result<VmExecutionResultAndLogs, BytecodeCompressionError> | ||
{ | ||
fn glue_from( | ||
value: Result< | ||
vm_virtual_blocks::VmExecutionResultAndLogs, | ||
vm_virtual_blocks::BytecodeCompressionError, | ||
>, | ||
) -> Self { | ||
match value { | ||
Ok(result) => Ok(result.glue_into()), | ||
Err(err) => Err(err.glue_into()), | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
core/lib/multivm/src/glue/types/vm/current_execution_state.rs
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,15 @@ | ||
use crate::glue::GlueFrom; | ||
use vm_latest::CurrentExecutionState; | ||
|
||
impl GlueFrom<vm_virtual_blocks::CurrentExecutionState> for CurrentExecutionState { | ||
fn glue_from(value: vm_virtual_blocks::CurrentExecutionState) -> Self { | ||
Self { | ||
events: value.events, | ||
storage_log_queries: value.storage_log_queries, | ||
used_contract_hashes: value.used_contract_hashes, | ||
l2_to_l1_logs: value.l2_to_l1_logs, | ||
total_log_queries: value.total_log_queries, | ||
cycles_used: value.cycles_used, | ||
} | ||
} | ||
} |
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,18 @@ | ||
use crate::glue::{GlueFrom, GlueInto}; | ||
use vm_latest::ExecutionResult; | ||
|
||
impl GlueFrom<vm_virtual_blocks::ExecutionResult> for ExecutionResult { | ||
fn glue_from(value: vm_virtual_blocks::ExecutionResult) -> Self { | ||
match value { | ||
vm_virtual_blocks::ExecutionResult::Success { output } => { | ||
ExecutionResult::Success { output } | ||
} | ||
vm_virtual_blocks::ExecutionResult::Revert { output } => ExecutionResult::Revert { | ||
output: output.glue_into(), | ||
}, | ||
vm_virtual_blocks::ExecutionResult::Halt { reason } => ExecutionResult::Halt { | ||
reason: reason.glue_into(), | ||
}, | ||
} | ||
} | ||
} |
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,44 @@ | ||
use crate::glue::{GlueFrom, GlueInto}; | ||
use vm_latest::Halt; | ||
|
||
impl GlueFrom<vm_virtual_blocks::Halt> for Halt { | ||
fn glue_from(value: vm_virtual_blocks::Halt) -> Self { | ||
match value { | ||
vm_virtual_blocks::Halt::ValidationFailed(reason) => { | ||
Self::ValidationFailed(reason.glue_into()) | ||
} | ||
vm_virtual_blocks::Halt::PaymasterValidationFailed(reason) => { | ||
Self::PaymasterValidationFailed(reason.glue_into()) | ||
} | ||
vm_virtual_blocks::Halt::PrePaymasterPreparationFailed(reason) => { | ||
Self::PrePaymasterPreparationFailed(reason.glue_into()) | ||
} | ||
vm_virtual_blocks::Halt::PayForTxFailed(reason) => { | ||
Self::PayForTxFailed(reason.glue_into()) | ||
} | ||
vm_virtual_blocks::Halt::FailedToMarkFactoryDependencies(reason) => { | ||
Self::FailedToMarkFactoryDependencies(reason.glue_into()) | ||
} | ||
vm_virtual_blocks::Halt::FailedToChargeFee(reason) => { | ||
Self::FailedToChargeFee(reason.glue_into()) | ||
} | ||
vm_virtual_blocks::Halt::FromIsNotAnAccount => Self::FromIsNotAnAccount, | ||
vm_virtual_blocks::Halt::InnerTxError => Self::InnerTxError, | ||
vm_virtual_blocks::Halt::Unknown(reason) => Self::Unknown(reason.glue_into()), | ||
vm_virtual_blocks::Halt::UnexpectedVMBehavior(reason) => { | ||
Self::UnexpectedVMBehavior(reason) | ||
} | ||
vm_virtual_blocks::Halt::BootloaderOutOfGas => Self::BootloaderOutOfGas, | ||
vm_virtual_blocks::Halt::TooBigGasLimit => Self::TooBigGasLimit, | ||
vm_virtual_blocks::Halt::NotEnoughGasProvided => Self::NotEnoughGasProvided, | ||
vm_virtual_blocks::Halt::MissingInvocationLimitReached => { | ||
Self::MissingInvocationLimitReached | ||
} | ||
vm_virtual_blocks::Halt::FailedToSetL2Block(reason) => Self::FailedToSetL2Block(reason), | ||
vm_virtual_blocks::Halt::FailedToAppendTransactionToL2Block(reason) => { | ||
Self::FailedToAppendTransactionToL2Block(reason) | ||
} | ||
vm_virtual_blocks::Halt::VMPanic => Self::VMPanic, | ||
} | ||
} | ||
} |
Oops, something went wrong.