-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: Validium mode abstraction #1015
Closed
ilitteri
wants to merge
75
commits into
matter-labs:main
from
lambdaclass:feat_validium_pubdata_abstraction
Closed
feat: Validium mode abstraction #1015
ilitteri
wants to merge
75
commits into
matter-labs:main
from
lambdaclass:feat_validium_pubdata_abstraction
Conversation
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
- Needs to fix errors in tests related to the new Generic Data Type
…ods from L1BatchWithMetadata as they're now part of the L1BatchCommitter trait and utils in the case of construct_pubdata
…mmitOperation construction and DatasizeCriterion::last_l1_batch_to_publish usage
…_publish parameter (only used by DataSizeCriterion)
…tter::l1_commit_data function
…l1_commit_data function
…ter depending on the VALIDIUM_MODE env value
…class/zksync-era into feat_validium_pubdata_abstraction
* Rename Validium pubdata abstraction and implementors * Rename struct fields and variables * feat: Abstract commit data generator initialization (#94) * Add L1BatchCommitDataGeneratorMode to StateKeeperConfig * Initialize L1BatchCommitter depending on the StateKeeperConfig * Fix bad merge
* add variable to .toml * zk fmt
ilitteri
requested review from
alexandrst88,
artmakh,
hatemosphere,
onyxet and
otani88
February 19, 2024 17:05
…Class/zksync-era into feat_validium_pubdata_abstraction
Closed
This was referenced Feb 20, 2024
This reverts commit c4b6cde.
This was referenced Feb 26, 2024
6 tasks
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 28, 2024
## What ❔ This is the final PR for merging the Validium feature into the project. It contains all off the addressed issues coming from #1015 + the EIP-4844 feature available on the main branch ## Why ❔ The Validium feature was develop isolated and in parallel from EIP4844 feature, but now we need to release it integrated with this feature, which was already deployed into mainnet. ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [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`. - [x] Spellcheck has been run via `zk spellcheck`. - [x] Linkcheck has been run via `zk linkcheck`. --------- Co-authored-by: Jordi <[email protected]> Co-authored-by: toni-calvin <[email protected]> Co-authored-by: ilitteri <[email protected]> Co-authored-by: Ivan Litteri <[email protected]> Co-authored-by: Joaquin Carletti <[email protected]> Co-authored-by: Santiago Pittella <[email protected]> Co-authored-by: Mario Rugiero <[email protected]> Co-authored-by: Joaquin Carletti <[email protected]> Co-authored-by: Igor Aleksanov <[email protected]> Co-authored-by: Roman Brodetski <[email protected]>
I will close this as the merge was done here #1461 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initiating the system
The system is initiated at compile time by running
zk init --validium-mode
. This flag sets different configurations across the system to convert the system into a Validium operator as described below.Not sending
pubdata
to L1L1 batches are committed by the
commitBatches
method of theExecutor.sol
contract. It receives aStoredBatchInfo
(last committed batch info) and an array ofCommitBatchInfo
(data needed to commit the batch) as parameters. The pubdata is part of theCommitBatchInfo
therefore not sending it to L1 means not including it in said struct.The transaction that executes a call to
commitBatches
with its calldata is constructed and sent by the server. Particularly, theeth_tx_aggregator
constructs it and saves it in the Postgres database and then it is picked up by theeth_tx_manager
and sent to the L1 (as explained above).In our proposal, the calldata saved in the database by the
eth_tx_aggregator
does not contain the pubdata for everyCommitBatchInfo
in Validium mode, it does in Rollup mode.CommitBatches
is in charge of encoding the calldata forcommitBatches
, it implements the traitTokenize
to perform such a task. Said implementation iterates over every batch to commit, and wraps them intoCommitBatchInfo
(Rust counterpart of Solidity’s) which also implementsTokenize
which finally encodes it. Here it lays the logic we need to abstract.To abstract this, we defined the
L1BatchCommitGenerator
trait one methodl1_commit_data(&self, l1_batch_with_metadata: &L1BatchWithMetadata)
.For the Rollup mode, we have a
RollupModeL1BatchCommitGenerator
struct implementingL1BatchCommitGenerator
in such a way thatl1_commit_data
includes the pubdata, and aValidiumModeL1BatchCommitGenerator
struct for Validium mode, not including the pubdata inl1_commit_data
.validium_mode_l1_commit_data
is implemented in such a way that it does not include the pubdata in theCommitBatchInfo
encodingIn
rollup_mode_l1_commit_data
the same as invalidium_mode_l1_commit_data
is being done but the pubdata is added at the end of the commit data.A field
l1_batch_commit_data_generator: Arc<dyn L1BatchCommitGenerator>
was added toCommitBatchInfo
to perform the L1 commit data encoding.The same field was also added to the
Aggregator
andCommitBatches
structs. The first one instantiatesCommitBatches
s and the latter instantiatesCommitBatchInfo
s.Which of the mentioned trait implementors will be instantiated as the
l1_batch_commit_generator
value of theAggregator
's field will depend on thel1_batch_commit_generator_mode
value in thechain.toml
file,state_keeper
section.Contracts changes
The following lines in
Executor.sol
are being skipped by solpp when the Validium mode flag is set totrue
:bytes32 providedL2ToL1PubdataHash = keccak256(_newBatch.totalL2ToL1Pubdata);
require(logSender == L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, "ln");
require(providedL2ToL1PubdataHash == logValue, "wp");
We also have to change how the
DiamondInit
is initialized due to the new fee model changes:pubdataPricingMode
is fixed toPubdataPricingMode.Rollup
, this value will depend on theVALIDIUM_MODE
env now.Not charging for
pubdata
When running the stack as a Validium, gas-used calculations have to account for the fact that
pubdata
is no longer published, and thus certain operations like storage become cheaper (they don’t pay forpubdata
inclusion on L1). Under the new fee model that was recently merged, every change needed here is managed through the following configuration values. With this in mind, all that’s needed is, when runningzk init
, if the user is initializing the stack in Validium mode (passing the--validium-mode
flag) we should load the following config specified for Validium in the fileetc/env/base/chain.toml
:chore(docs): Update documentation about our new fee model by mm-zk · Pull Request #904 · matter-labs/zksync-era
The only flag not available in the
chain.toml
is thel1_pubdata_price
as it is computed and set by the functionestimate_effective_pubdata_price()
defined in theL1GasPriceProvider
trait, implemented byGasAdjuster
. To make this value equal to zero, we need to set the constL1_GAS_PER_PUBDATA_BYTE
to zero for validium, and 17 for rollup. For this, we’ve added a new field in theGasAdjusterConfig
struct which is loaded from theeth_sender.toml
file (hence the same field was added there to be read).