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

chore(contracts): merge release 23 into dev #508

Merged
merged 43 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a27c778
chore: Compile yul files in parallel within a single folder (#271)
popzxc Mar 22, 2024
4aa7006
ci: Make build release manual triggered only (#287)
onyxet Mar 26, 2024
fcee799
Script + safeTransferFromLegacy (#402)
StanislavBreadless Apr 24, 2024
381911e
fix: get all hyperchains (#403)
kelemeno Apr 24, 2024
670434d
chore(executor): remove constraint on pubdata hash for validiums (#404)
koloz193 Apr 24, 2024
8099425
Update L1SharedBridge.sol (#405)
StanislavBreadless Apr 24, 2024
78d339f
chore(scripts): update setValidium to setPubdataPricing (#406)
koloz193 Apr 24, 2024
f78faf0
Accept ownership script (#409)
StanislavBreadless Apr 25, 2024
f9ccb10
Script to cross check the contracts from the upgrade (#408)
StanislavBreadless Apr 26, 2024
b824726
fix: upgrade hyperchain add missing fields (#415)
kelemeno Apr 26, 2024
b5314f6
Extend bootloader memory (#421)
StanislavBreadless Apr 26, 2024
d89e406
feat: improve foundry l1 config deployment (#378)
aon Apr 29, 2024
d8e07b6
Kl/l2 bridge fix l1 bridge names (#434)
kelemeno May 1, 2024
51c3b47
remove redundant configs (#429)
Deniallugo May 2, 2024
3e59239
fix: correct local bridge testing (#440)
benceharomi May 2, 2024
13445ad
Move gas bound caller to a separate folder (#425)
StanislavBreadless May 6, 2024
61d81d3
Merge branch 'main' into release-v23
vladbochok May 7, 2024
f9e9d3c
Attempt to fix CI
vladbochok May 7, 2024
accecc4
fix: hyperchain upgrade fix2 (don't merge) (#401)
kelemeno May 8, 2024
fa85062
remove log values when validium (#465)
koloz193 May 11, 2024
46c9170
Updates Verifier.sol for 1.5.0 patch
EmilLuta May 11, 2024
3a0dd43
update vk
koloz193 May 11, 2024
452a54f
Merge pull request #466 from matter-labs/evl-update-verifier-sol-for-…
EmilLuta May 11, 2024
d57c659
fix: allow to skip initialization of chain governance
ischasny May 13, 2024
bffbf0a
Merge pull request #468 from matter-labs/ivan/skip-initialize-governance
ischasny May 13, 2024
707043f
Deploy l2 contracts and use governance for upgrades (#441)
Deniallugo May 14, 2024
d334f82
update verification keys (#472)
kelemeno May 15, 2024
900c5c9
Update Verifier from new vk (#474)
koloz193 May 16, 2024
c64d448
fix init bridges (#469)
Deniallugo May 17, 2024
12a7d3b
feat: register hyperchain through governance EVM-597 (#443)
ischasny May 20, 2024
41fb9d9
feat: update foundry scripts with new config (#485)
aon May 21, 2024
5312fd4
fix: utils library getting deployed (#487)
aon May 22, 2024
8cc766e
Packed protocol version (#492)
StanislavBreadless May 29, 2024
32ca4e6
Use governance as hyperchain governor upon init (#501)
StanislavBreadless May 30, 2024
16ae765
feat: update verifier (#503)
Artemka374 May 31, 2024
fe0b7f4
Change how we update chain creation params (#502)
StanislavBreadless May 31, 2024
8a70bbb
chore: Move l1-contracts-foundry (#504)
matias-gonz Jun 3, 2024
8e4c291
Merge branch 'release-v23' into dev
koloz193 Jun 5, 2024
d97d8cd
tests and fix merge conflict
koloz193 Jun 5, 2024
704b41b
fix merge conflicts and bump hashes
koloz193 Jun 5, 2024
ee5667e
fixed lint
koloz193 Jun 5, 2024
5c4525a
update system contracts hashes and verifier hash
koloz193 Jun 5, 2024
131f823
update forge-std
koloz193 Jun 5, 2024
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
50 changes: 0 additions & 50 deletions .github/workflows/buld-release.yaml

This file was deleted.

40 changes: 23 additions & 17 deletions .github/workflows/l1-contracts-foundry-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -28,7 +29,7 @@ jobs:
run: yarn

- name: Build artifacts
working-directory: ./l1-contracts-foundry
working-directory: ./l1-contracts
run: forge build

- name: Build system-contract artifacts
Expand All @@ -39,8 +40,8 @@ jobs:
with:
key: artifacts-l1-contracts-foudry-${{ github.sha }}
path: |
l1-contracts-foundry/cache
l1-contracts-foundry/out
l1-contracts/cache
l1-contracts/out
system-contracts/artifacts-zk
system-contracts/bootloader/build
system-contracts/cache-zk
Expand All @@ -62,8 +63,8 @@ jobs:
fail-on-cache-miss: true
key: artifacts-l1-contracts-foudry-${{ github.sha }}
path: |
l1-contracts-foundry/cache
l1-contracts-foundry/out
l1-contracts/cache
l1-contracts/out
system-contracts/artifacts-zk
system-contracts/bootloader/build
system-contracts/cache-zk
Expand All @@ -73,6 +74,10 @@ jobs:
- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Copy configs from template
working-directory: ./l1-contracts
run: cp -r deploy-script-config-template script-config

- name: Run anvil
run: |
anvil --silent &
Expand All @@ -95,17 +100,18 @@ jobs:
fi

- name: Run DeployL1 script
working-directory: ./l1-contracts-foundry
run: forge script ./script/DeployL1.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY

- name: Run RegisterHyperchain script
working-directory: ./l1-contracts-foundry
run: forge script ./script/RegisterHyperchain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
working-directory: ./l1-contracts
run: forge script ./deploy-scripts/DeployL1.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY

- name: Run DeployErc20 script
working-directory: ./l1-contracts-foundry
run: forge script ./script/DeployErc20.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY

- name: Run InitializeL2WethToken script
working-directory: ./l1-contracts-foundry
run: forge script ./script/InitializeL2WethToken.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
working-directory: ./l1-contracts
run: forge script ./deploy-scripts/DeployErc20.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# TODO restore scripts verification
# - name: Run RegisterHyperchain script
# working-directory: ./l1-contracts
# run: |
# cat ./script-out/output-deploy-l1.toml >> ./script-config/register-hyperchain.toml
# forge script ./deploy-scripts/RegisterHyperchain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# - name: Run InitializeL2WethToken script
# working-directory: ./l1-contracts-foundry
# run: forge script ./deploy-scripts/InitializeL2WethToken.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ l1-contracts/lcov.info
l1-contracts/report/*
l1-contracts/coverage/*
l1-contracts/out/*
l1-contracts-foundry/broadcast/*
l1-contracts-foundry/script-out/*
!l1-contracts-foundry/script-out/.gitkeep
*.timestamp
l1-contracts/broadcast/*
l1-contracts/script-config/*
l1-contracts/script-out/*
!l1-contracts/script-out/.gitkeep
15 changes: 7 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
[submodule "l1-contracts/lib/murky"]
path = l1-contracts/lib/murky
url = https://github.com/dmfxyz/murky
[submodule "l1-contracts-foundry/lib/forge-std"]
path = l1-contracts-foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "l1-contracts-foundry/lib/openzeppelin-contracts"]
path = l1-contracts-foundry/lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts
[submodule "l1-contracts-foundry/lib/openzeppelin-contracts-upgradeable"]
path = l1-contracts-foundry/lib/openzeppelin-contracts-upgradeable
[submodule "l1-contracts/lib/openzeppelin-contracts-upgradeable"]
path = l1-contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/Openzeppelin/openzeppelin-contracts-upgradeable
branch = release-v4.9
[submodule "l1-contracts/lib/openzeppelin-contracts"]
path = l1-contracts/lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts
branch = release-v4.9
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ system-contracts/contracts/openzeppelin
system-contracts/contracts/Constants.sol
system-contracts/contracts/test-contracts
system-contracts/contracts-preprocessed

# gas-bound-caller
gas-bound-caller/contracts/test-contracts
51 changes: 51 additions & 0 deletions gas-bound-caller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# GasBoundCaller

Starting from v24 On Era, the gas for pubdata is charged at the end of the execution of the entire transaction. This means that if a subcall is not trusted, it can consume a significant amount of pubdata during the process. While this may not be an issue for most contracts, there are use cases, e.g., for relayers, where it is crucial to ensure that the subcall will not spend more money than intended.

The `GasBoundCaller` is a contract with the following interface:

```solidity
function gasBoundCall(address _to, uint256 _maxTotalGas, bytes calldata _data) external payable
```

> Note that the amount of gas passed into this function should be less than or equal to `_maxTotalGas`. If the computational gas provided is higher than `_maxTotalGas`, the higher value will be used.

This contract will call the address `_to` with the entire execution gas passed to it, while ensuring that the total consumed gas does not exceed `_maxTotalGas` under any circumstances.

If the call to the `_to` address fails, the gas used on pubdata is considered zero, and the total gas used is fully equivalent to the gas consumed within the execution. The `GasBoundCaller` will relay the revert message as-is.

If the call to the `_to` address succeeds, the `GasBoundCaller` will ensure that the total consumed gas does not exceed `_maxTotalGas`. If it does, it will revert with a "Not enough gas for pubdata" error. If the total consumed gas is less than or equal to `_maxTotalGas`, the `GasBoundCaller` will return returndata equal to `abi.encode(bytes returndataFromSubcall, uint256 gasUsedForPubdata)`.

## Usage

Summing up the information from the previous chapter, the `GasBoundCaller` should be used in the following way:

TODO(EVM-585): switch `addr` with address.

```solidity
uint256 computeGasBefore = gasleft();

(bool success, bytes memory returnData) = address(this).call{gas: _gasToPass}(abi.encodeWithSelector(GasBoundCaller.gasBoundCall.selector, _to, _maxTotalGas, _data));

uint256 pubdataGasSpent;
if (success) {
(returnData, pubdataGasSpent) = abi.decode(returnData, (bytes, uint256));
} else {
// `returnData` is fully equal to the returndata, while `pubdataGasSpent` is equal to 0
}

uint256 computeGasAfter = gasleft();

// This is the total gas that the subcall made the transaction to be charged for
uint256 totalGasConsumed = computeGasBefore - computeGasAfter + pubdataGasSpent;
```

### Preserving `msg.sender`

Since `GasBoundCaller` would be the contract that calls the `_to` contract, the `msg.sender` will be equal to the `GasBoundCaller`'s address. To preserve the current `msg.sender`, this contract can be inherited from and used the same way, but instead of calling `GasBoundCaller.gasBoundCall`, `this.gasBoundCall` could be called.

## Deployed Address

It should be deployed via a built-in CREATE2 factory on each individual chain.

TODO(EVM-585)
Loading
Loading