forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cheaper L1->L2 txs + upgrade implementation (#168)
- Loading branch information
1 parent
f44e405
commit d8ed1d7
Showing
4 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.20; | ||
|
||
import {Diamond} from "../zksync/libraries/Diamond.sol"; | ||
import {BaseZkSyncUpgrade} from "./BaseZkSyncUpgrade.sol"; | ||
import {PubdataPricingMode, FeeParams} from "../zksync/Storage.sol"; | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
contract Upgrade_v1_4_1 is BaseZkSyncUpgrade { | ||
/// This event is an exact copy of the "IAdmin.NewFeeParams" event. Since they have the same name and parameters, | ||
/// these will be tracked by indexers in the same manner. | ||
event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams); | ||
|
||
/// This function is a copy of the "Admin.changeFeeParams" function. | ||
/// It is to be used once to set the new fee params for the first time as they needed for the correct functioning of the upgrade. | ||
function changeFeeParams(FeeParams memory _newFeeParams) private { | ||
// Double checking that the new fee params are valid, i.e. | ||
// the maximal pubdata per batch is not less than the maximal pubdata per priority transaction. | ||
require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, "n6"); | ||
|
||
FeeParams memory oldFeeParams = s.feeParams; | ||
s.feeParams = _newFeeParams; | ||
|
||
emit NewFeeParams(oldFeeParams, _newFeeParams); | ||
} | ||
|
||
/// @notice The main function that will be called by the upgrade proxy. | ||
/// @param _proposedUpgrade The upgrade to be executed. | ||
function upgrade(ProposedUpgrade calldata _proposedUpgrade) public override returns (bytes32) { | ||
// The execution of the next parts of the upgrade does depend on these fee params being already set correctly | ||
changeFeeParams( | ||
FeeParams({ | ||
pubdataPricingMode: PubdataPricingMode.Rollup, | ||
batchOverheadL1Gas: $(PRIORITY_TX_BATCH_OVERHEAD_L1_GAS), | ||
maxPubdataPerBatch: $(PRIORITY_TX_PUBDATA_PER_BATCH), | ||
maxL2GasPerBatch: $(PRIORITY_TX_MAX_GAS_PER_BATCH), | ||
priorityTxMaxPubdata: $(PRIORITY_TX_PUBDATA_PER_BATCH), | ||
minimalL2GasPrice: $(PRIORITY_TX_MINIMAL_GAS_PRICE) | ||
}) | ||
); | ||
|
||
super.upgrade(_proposedUpgrade); | ||
|
||
return Diamond.DIAMOND_INIT_SUCCESS_RETURN_VALUE; | ||
} | ||
} |
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