Skip to content

Commit

Permalink
feat(config): update eth_sender to use blobs (#1295)
Browse files Browse the repository at this point in the history
## 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`.
- [ ] Spellcheck has been run via `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.

---------

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
Co-authored-by: perekopskiy <mikeson.dp@gmail.com>
  • Loading branch information
3 people committed Mar 1, 2024
1 parent 43a4093 commit e81f080
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 2 deletions.

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

42 changes: 42 additions & 0 deletions core/lib/dal/src/eth_sender_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,46 @@ impl EthSenderDal<'_, '_> {
.await?;
Ok(())
}

pub async fn delete_eth_txs(&mut self, last_batch_to_keep: L1BatchNumber) -> sqlx::Result<()> {
sqlx::query!(
r#"
DELETE FROM eth_txs
WHERE
id IN (
(
SELECT
eth_commit_tx_id
FROM
l1_batches
WHERE
number > $1
)
UNION
(
SELECT
eth_prove_tx_id
FROM
l1_batches
WHERE
number > $1
)
UNION
(
SELECT
eth_execute_tx_id
FROM
l1_batches
WHERE
number > $1
)
)
"#,
last_batch_to_keep.0 as i64
)
.execute(self.storage.conn())
.await?;

Ok(())
}
}
6 changes: 6 additions & 0 deletions core/lib/zksync_core/src/block_reverter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ impl BlockReverter {
.rollback_storage_logs(last_miniblock_to_keep)
.await
.unwrap();
tracing::info!("rolling back eth_txs...");
transaction
.eth_sender_dal()
.delete_eth_txs(last_l1_batch_to_keep)
.await
.unwrap();
tracing::info!("rolling back l1 batches...");
transaction
.blocks_dal()
Expand Down
4 changes: 3 additions & 1 deletion etc/env/base/eth_sender.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[eth_sender.sender]
# operator_private_key is defined in the `private.toml`
# operator_commit_eth_addr is defined in the `private.toml`
# operator_blobs_private_key is defined in the `private.toml`
# operator_blobs_eth_addr is defined in the `private.toml`

# Amount of confirmations required to consider L1 transaction committed.
wait_confirmations=1
Expand Down Expand Up @@ -46,7 +48,7 @@ max_acceptable_priority_fee_in_gwei=100000000000

proof_loading_mode="OldProofFromDb"

pubdata_sending_mode="Calldata"
pubdata_sending_mode="Blobs"

[eth_sender.gas_adjuster]
# Priority fee to be used by GasAdjuster (in wei).
Expand Down
3 changes: 3 additions & 0 deletions etc/env/base/private.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ operator_private_key="0x27593fea79697e947890ecbecce7901b0008345e5d7259710d0dd5e5
# Derived from the `OPERATOR_PRIVATE_KEY`.
operator_commit_eth_addr="0xde03a0B5963f75f1C8485B355fF6D30f3093BDE7"

operator_blobs_private_key="0xe667e57a9b8aaa6709e51ff7d093f1c5b73b63f9987e4ab4aa9a5c699e024ee8"
operator_blobs_eth_addr="0x4F9133D1d3F50011A6859807C837bdCB31Aaab13"

[consensus]
config_path = "etc/env/consensus_config.json"
# generated with zksync_consensus_tools/src/bin/keys.rs
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/zk/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export async function setup(opts: DbOpts) {
await utils.spawn(
`pg_dump ${process.env.TEMPLATE_DATABASE_URL} -F c | pg_restore -d ${process.env.DATABASE_URL}`
);
// Remove `unconfirmed` rows from `eth_txs_history` table.
await utils.spawn(
`psql ${process.env.DATABASE_URL} -c "DELETE FROM eth_txs_history WHERE confirmed_at IS NULL"`
);

process.chdir(process.env.ZKSYNC_HOME as string);

Expand Down

0 comments on commit e81f080

Please sign in to comment.