Skip to content

Commit

Permalink
refactor(vm): Move event types to VM interface and multivm crates (#2655
Browse files Browse the repository at this point in the history
)

## What ❔

Continuing from #2645,
this PR moves VM event types to VM interface / implementation crates.

## Why ❔

So that types are separated by domain rather than all collected in
`zksync_types`.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
slowli authored Aug 19, 2024
1 parent 6a2e3b0 commit f13bd49
Show file tree
Hide file tree
Showing 81 changed files with 895 additions and 890 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions core/lib/dal/src/contract_verification_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use zksync_types::{
DeployContractCalldata, VerificationIncomingRequest, VerificationInfo, VerificationRequest,
VerificationRequestStatus,
},
event::DEPLOY_EVENT_SIGNATURE,
Address, CONTRACT_DEPLOYER_ADDRESS,
};
use zksync_utils::address_to_h256;
use zksync_vm_interface::VmEvent;

use crate::{models::storage_verification_request::StorageVerificationRequest, Core};

Expand Down Expand Up @@ -291,6 +291,7 @@ impl ContractVerificationDal<'_, '_> {
address: Address,
) -> anyhow::Result<Option<(Vec<u8>, DeployContractCalldata)>> {
let address_h256 = address_to_h256(&address);

let Some(row) = sqlx::query!(
r#"
SELECT
Expand Down Expand Up @@ -323,7 +324,7 @@ impl ContractVerificationDal<'_, '_> {
)
"#,
CONTRACT_DEPLOYER_ADDRESS.as_bytes(),
DEPLOY_EVENT_SIGNATURE.as_bytes(),
VmEvent::DEPLOY_EVENT_SIGNATURE.as_bytes(),
address_h256.as_bytes(),
)
.fetch_optional(self.storage.conn())
Expand Down
6 changes: 3 additions & 3 deletions core/lib/dal/src/events_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use zksync_db_connection::{
use zksync_system_constants::L1_MESSENGER_ADDRESS;
use zksync_types::{
api,
event::L1_MESSENGER_BYTECODE_PUBLICATION_EVENT_SIGNATURE,
l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log},
tx::IncludedTxLocation,
Address, L1BatchNumber, L2BlockNumber, VmEvent, H256,
Address, L1BatchNumber, L2BlockNumber, H256,
};
use zksync_vm_interface::VmEvent;

use crate::{
models::storage_event::{StorageL2ToL1Log, StorageWeb3Log},
Expand Down Expand Up @@ -278,7 +278,7 @@ impl EventsDal<'_, '_> {
i64::from(from_l2_block.0),
i64::from(to_l2_block.0),
L1_MESSENGER_ADDRESS.as_bytes(),
L1_MESSENGER_BYTECODE_PUBLICATION_EVENT_SIGNATURE.as_bytes()
VmEvent::L1_MESSENGER_BYTECODE_PUBLICATION_EVENT_SIGNATURE.as_bytes()
)
.instrument("get_l1_batch_raw_published_bytecode_hashes")
.with_arg("from_l2_block", &from_l2_block)
Expand Down
5 changes: 3 additions & 2 deletions core/lib/dal/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ use zksync_types::{
protocol_upgrade::{ProtocolUpgradeTx, ProtocolUpgradeTxCommonData},
snapshots::SnapshotRecoveryStatus,
Address, Execute, K256PrivateKey, L1BatchNumber, L1BlockNumber, L1TxCommonData, L2BlockNumber,
L2ChainId, PriorityOpId, ProtocolVersion, ProtocolVersionId, VmEvent, H160, H256, U256,
L2ChainId, PriorityOpId, ProtocolVersion, ProtocolVersionId, H160, H256, U256,
};
use zksync_vm_interface::{
TransactionExecutionMetrics, TransactionExecutionResult, TxExecutionStatus, VmExecutionMetrics,
TransactionExecutionMetrics, TransactionExecutionResult, TxExecutionStatus, VmEvent,
VmExecutionMetrics,
};

use crate::{
Expand Down
8 changes: 5 additions & 3 deletions core/lib/dal/src/transactions_web3_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use zksync_db_connection::{
interpolate_query, match_query_as,
};
use zksync_types::{
api, api::TransactionReceipt, block::build_bloom, event::DEPLOY_EVENT_SIGNATURE, Address,
BloomInput, L2BlockNumber, L2ChainId, Transaction, CONTRACT_DEPLOYER_ADDRESS, H256, U256,
api, api::TransactionReceipt, block::build_bloom, Address, BloomInput, L2BlockNumber,
L2ChainId, Transaction, CONTRACT_DEPLOYER_ADDRESS, H256, U256,
};
use zksync_vm_interface::VmEvent;

use crate::{
models::storage_transaction::{
Expand Down Expand Up @@ -40,6 +41,7 @@ impl TransactionsWeb3Dal<'_, '_> {
hashes: &[H256],
) -> DalResult<Vec<TransactionReceipt>> {
let hash_bytes: Vec<_> = hashes.iter().map(H256::as_bytes).collect();

// Clarification for first part of the query(`WITH` clause):
// Looking for `ContractDeployed` event in the events table
// to find the address of deployed contract
Expand Down Expand Up @@ -88,7 +90,7 @@ impl TransactionsWeb3Dal<'_, '_> {
// ^ Filter out transactions with pruned data, which would lead to potentially incomplete / bogus
// transaction info.
CONTRACT_DEPLOYER_ADDRESS.as_bytes(),
DEPLOY_EVENT_SIGNATURE.as_bytes(),
VmEvent::DEPLOY_EVENT_SIGNATURE.as_bytes(),
&hash_bytes as &[&[u8]],
)
.instrument("get_transaction_receipts")
Expand Down
Loading

0 comments on commit f13bd49

Please sign in to comment.