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

feat(en): Remove SyncBlock.root_hash #633

Merged
merged 2 commits into from
Dec 11, 2023
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
190 changes: 92 additions & 98 deletions core/lib/dal/sqlx-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -5720,6 +5720,98 @@
},
"query": "SELECT id FROM prover_fri_protocol_versions WHERE recursion_circuits_set_vks_hash = $1 AND recursion_leaf_level_vk_hash = $2 AND recursion_node_level_vk_hash = $3 AND recursion_scheduler_level_vk_hash = $4 "
},
"6ad9309a48f387da7d437ba6ed94aa7b6a42813e5ee566104b904f0bee0dfde7": {
"describe": {
"columns": [
{
"name": "number",
"ordinal": 0,
"type_info": "Int8"
},
{
"name": "l1_batch_number!",
"ordinal": 1,
"type_info": "Int8"
},
{
"name": "last_batch_miniblock?",
"ordinal": 2,
"type_info": "Int8"
},
{
"name": "timestamp",
"ordinal": 3,
"type_info": "Int8"
},
{
"name": "l1_gas_price",
"ordinal": 4,
"type_info": "Int8"
},
{
"name": "l2_fair_gas_price",
"ordinal": 5,
"type_info": "Int8"
},
{
"name": "bootloader_code_hash",
"ordinal": 6,
"type_info": "Bytea"
},
{
"name": "default_aa_code_hash",
"ordinal": 7,
"type_info": "Bytea"
},
{
"name": "virtual_blocks",
"ordinal": 8,
"type_info": "Int8"
},
{
"name": "hash",
"ordinal": 9,
"type_info": "Bytea"
},
{
"name": "consensus",
"ordinal": 10,
"type_info": "Jsonb"
},
{
"name": "protocol_version!",
"ordinal": 11,
"type_info": "Int4"
},
{
"name": "fee_account_address?",
"ordinal": 12,
"type_info": "Bytea"
}
],
"nullable": [
false,
null,
null,
false,
false,
false,
true,
true,
false,
false,
true,
true,
false
],
"parameters": {
"Left": [
"Int8"
]
}
},
"query": "SELECT miniblocks.number, COALESCE(miniblocks.l1_batch_number, (SELECT (max(number) + 1) FROM l1_batches)) as \"l1_batch_number!\", (SELECT max(m2.number) FROM miniblocks m2 WHERE miniblocks.l1_batch_number = m2.l1_batch_number) as \"last_batch_miniblock?\", miniblocks.timestamp, miniblocks.l1_gas_price, miniblocks.l2_fair_gas_price, miniblocks.bootloader_code_hash, miniblocks.default_aa_code_hash, miniblocks.virtual_blocks, miniblocks.hash, miniblocks.consensus, miniblocks.protocol_version as \"protocol_version!\", l1_batches.fee_account_address as \"fee_account_address?\" FROM miniblocks LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number WHERE miniblocks.number = $1"
},
"6b53e5cb619c9649d28ae33df6a43e6984e2d9320f894f3d04156a2d1235bb60": {
"describe": {
"columns": [
Expand Down Expand Up @@ -6043,104 +6135,6 @@
},
"query": "SELECT * FROM call_traces WHERE tx_hash IN (SELECT hash FROM transactions WHERE miniblock_number = $1)"
},
"7947dd8e7d6c138146f7ebe6b1e89fcd494b2679ac4e9fcff6aa2b2944aeed50": {
"describe": {
"columns": [
{
"name": "number",
"ordinal": 0,
"type_info": "Int8"
},
{
"name": "l1_batch_number!",
"ordinal": 1,
"type_info": "Int8"
},
{
"name": "last_batch_miniblock?",
"ordinal": 2,
"type_info": "Int8"
},
{
"name": "timestamp",
"ordinal": 3,
"type_info": "Int8"
},
{
"name": "root_hash?",
"ordinal": 4,
"type_info": "Bytea"
},
{
"name": "l1_gas_price",
"ordinal": 5,
"type_info": "Int8"
},
{
"name": "l2_fair_gas_price",
"ordinal": 6,
"type_info": "Int8"
},
{
"name": "bootloader_code_hash",
"ordinal": 7,
"type_info": "Bytea"
},
{
"name": "default_aa_code_hash",
"ordinal": 8,
"type_info": "Bytea"
},
{
"name": "virtual_blocks",
"ordinal": 9,
"type_info": "Int8"
},
{
"name": "hash",
"ordinal": 10,
"type_info": "Bytea"
},
{
"name": "consensus",
"ordinal": 11,
"type_info": "Jsonb"
},
{
"name": "protocol_version!",
"ordinal": 12,
"type_info": "Int4"
},
{
"name": "fee_account_address?",
"ordinal": 13,
"type_info": "Bytea"
}
],
"nullable": [
false,
null,
null,
false,
false,
false,
false,
true,
true,
false,
false,
true,
true,
false
],
"parameters": {
"Left": [
"Int8"
]
}
},
"query": "SELECT miniblocks.number, COALESCE(miniblocks.l1_batch_number, (SELECT (max(number) + 1) FROM l1_batches)) as \"l1_batch_number!\", (SELECT max(m2.number) FROM miniblocks m2 WHERE miniblocks.l1_batch_number = m2.l1_batch_number) as \"last_batch_miniblock?\", miniblocks.timestamp, miniblocks.hash as \"root_hash?\", miniblocks.l1_gas_price, miniblocks.l2_fair_gas_price, miniblocks.bootloader_code_hash, miniblocks.default_aa_code_hash, miniblocks.virtual_blocks, miniblocks.hash, miniblocks.consensus, miniblocks.protocol_version as \"protocol_version!\", l1_batches.fee_account_address as \"fee_account_address?\" FROM miniblocks LEFT JOIN l1_batches ON miniblocks.l1_batch_number = l1_batches.number WHERE miniblocks.number = $1"
},
"79cdb4cdd3c47b3654e6240178985fb4b4420e0634f9482a6ef8169e90200b84": {
"describe": {
"columns": [
Expand Down
17 changes: 7 additions & 10 deletions core/lib/dal/src/models/storage_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use zksync_protobuf::{read_required, ProtoFmt};
use zksync_types::{api::en, Address, L1BatchNumber, MiniblockNumber, Transaction, H160, H256};

#[derive(Debug, Clone, sqlx::FromRow)]
pub struct StorageSyncBlock {
pub(crate) struct StorageSyncBlock {
pub number: i64,
pub l1_batch_number: i64,
pub last_batch_miniblock: Option<i64>,
pub timestamp: i64,
pub root_hash: Option<Vec<u8>>,
// L1 gas price assumed in the corresponding batch
pub l1_gas_price: i64,
// L2 gas price assumed in the corresponding batch
Expand Down Expand Up @@ -48,11 +47,6 @@ impl StorageSyncBlock {
.map(|n| n == self.number)
.unwrap_or(false),
timestamp: self.timestamp.try_into().context("timestamp")?,
root_hash: self
.root_hash
.map(|h| parse_h256(&h))
.transpose()
.context("root_hash")?,
l1_gas_price: self.l1_gas_price.try_into().context("l1_gas_price")?,
l2_fair_gas_price: self
.l2_fair_gas_price
Expand Down Expand Up @@ -106,22 +100,25 @@ pub struct ConsensusBlockFields {
}

impl ConsensusBlockFields {
pub fn decode(src: &en::ConsensusBlockFields) -> anyhow::Result<Self> {
zksync_protobuf::decode(&src.0 .0)
}

pub fn encode(&self) -> en::ConsensusBlockFields {
en::ConsensusBlockFields(zksync_protobuf::encode(self).into())
}
pub fn decode(x: &en::ConsensusBlockFields) -> anyhow::Result<Self> {
zksync_protobuf::decode(&x.0 .0)
}
}

impl ProtoFmt for ConsensusBlockFields {
type Proto = crate::models::proto::ConsensusBlockFields;

fn read(r: &Self::Proto) -> anyhow::Result<Self> {
Ok(Self {
parent: read_required(&r.parent).context("parent")?,
justification: read_required(&r.justification).context("justification")?,
})
}

fn build(&self) -> Self::Proto {
Self::Proto {
parent: Some(self.parent.build()),
Expand Down
Loading