-
Notifications
You must be signed in to change notification settings - Fork 85
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
Feature: L1 <> L2 messaging with Token Bridge example #253
Open
0xNeshi
wants to merge
29
commits into
NethermindEth:main
Choose a base branch
from
0xNeshi:l1-l2-token-bridge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5f8715a
Add token bridge scaffold
0xNeshi 33188fc
Create L2 bridge
0xNeshi 251ff2c
Add tests for L2 bridge
0xNeshi 5b507bb
Add solidity bridge contract
0xNeshi b4e93b5
rename consumeMessage->consumeWithdrawal & initiateWithdrawal->bridge…
0xNeshi bbf3a56
Rename initiate_withdrawal->bridge_to_l1
0xNeshi 7efed11
make TokenBridge work + add tests
0xNeshi 1936c31
Add ability to set l2bridge post deployment
0xNeshi 8bc413f
Add ability to set l1bridge and token post deployment to cairo
0xNeshi 8cd9ff3
Add getters + pass governor in ctor
0xNeshi db4565a
Split uint256 amount to low/high before bridging to L2
0xNeshi f4d5687
TokenBridge: remove token from ctor + token ops limited to bridge
0xNeshi ad6fcae
Move starknet contracts to lib
0xNeshi 09a3ff0
leave source to orig strk mess local
0xNeshi 08a0a14
make l2 handler selector customizable
0xNeshi 8fa90a1
manually set token and l1 bridge address in STRK
0xNeshi 0170de5
MintableTokenMock: OnlyBridge->Unauthorized
0xNeshi 195bb71
Strk: set token post-ctor + add missing mock token
0xNeshi f9ca0f6
add comments to contract.cairo
0xNeshi 28bac93
Remove cache and out from solidity
0xNeshi 4602eef
move ./cairo contents to root folder
0xNeshi 30ed1c7
mintableToken->token
0xNeshi c018053
Merge remote-tracking branch 'origin/main' into l1-l2-token-bridge
0xNeshi 5813aaf
Remove redundant l1_bridge felt252 init in tests
0xNeshi 3d18859
mocks.cairo->mintable_token_mock.cairo
0xNeshi b8b57e1
Update the .md file
0xNeshi 8e0c198
remove TokenBridge @author tag
0xNeshi 8a1ea4c
Merge remote-tracking branch 'origin/main' into l1-l2-token-bridge
0xNeshi 6ce10e8
Update edition to point to workspace
0xNeshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,2 @@ | ||
target | ||
.snfoundry_cache/ |
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,17 @@ | ||
[package] | ||
name = "l1_l2_token_bridge" | ||
version.workspace = true | ||
edition = "2024_07" | ||
|
||
[dependencies] | ||
starknet.workspace = true | ||
openzeppelin.workspace = true | ||
|
||
[dev-dependencies] | ||
assert_macros.workspace = true | ||
snforge_std.workspace = true | ||
|
||
[scripts] | ||
test.workspace = true | ||
|
||
[[target.starknet-contract]] |
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,2 @@ | ||
cache | ||
out |
66 changes: 66 additions & 0 deletions
66
listings/applications/l1_l2_token_bridge/solidity/README.md
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,66 @@ | ||
## Foundry | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
|
||
Foundry consists of: | ||
|
||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
## Usage | ||
|
||
### Build | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Test | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
|
||
### Format | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
|
||
### Gas Snapshots | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
|
||
### Anvil | ||
|
||
```shell | ||
$ anvil | ||
``` | ||
|
||
### Deploy | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
### Cast | ||
|
||
```shell | ||
$ cast <subcommand> | ||
``` | ||
|
||
### Help | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` |
7 changes: 7 additions & 0 deletions
7
listings/applications/l1_l2_token_bridge/solidity/foundry.toml
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,7 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options | ||
remappings = ["starknet/=lib/starknet/"] |
1 change: 1 addition & 0 deletions
1
listings/applications/l1_l2_token_bridge/solidity/lib/forge-std/.gitattributes
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 @@ | ||
src/Vm.sol linguist-generated | ||
128 changes: 128 additions & 0 deletions
128
listings/applications/l1_l2_token_bridge/solidity/lib/forge-std/.github/workflows/ci.yml
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,128 @@ | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
# Backwards compatibility checks: | ||
# - the oldest and newest version of each supported minor version | ||
# - versions with specific issues | ||
- name: Check compatibility with latest | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
|
||
- name: Check compatibility with 0.8.0 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.8.0) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
|
||
- name: Check compatibility with 0.7.6 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.7.6) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
|
||
- name: Check compatibility with 0.7.0 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.7.0) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
|
||
- name: Check compatibility with 0.6.12 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.6.12) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
|
||
- name: Check compatibility with 0.6.2 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.6.2) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
|
||
# via-ir compilation time checks. | ||
- name: Measure compilation time of Test with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationTest.sol --use solc:0.8.17 --via-ir | ||
|
||
- name: Measure compilation time of TestBase with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationTestBase.sol --use solc:0.8.17 --via-ir | ||
|
||
- name: Measure compilation time of Script with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationScript.sol --use solc:0.8.17 --via-ir | ||
|
||
- name: Measure compilation time of ScriptBase with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationScriptBase.sol --use solc:0.8.17 --via-ir | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Run tests | ||
run: forge test -vvv | ||
|
||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Check formatting | ||
run: forge fmt --check |
31 changes: 31 additions & 0 deletions
31
listings/applications/l1_l2_token_bridge/solidity/lib/forge-std/.github/workflows/sync.yml
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,31 @@ | ||
name: Sync Release Branch | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
sync-release-branch: | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.event.release.tag_name, 'v1') | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: v1 | ||
|
||
# The email is derived from the bots user id, | ||
# found here: https://api.github.com/users/github-actions%5Bbot%5D | ||
- name: Configure Git | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
|
||
- name: Sync Release Branch | ||
run: | | ||
git fetch --tags | ||
git checkout v1 | ||
git reset --hard ${GITHUB_REF} | ||
git push --force |
4 changes: 4 additions & 0 deletions
4
listings/applications/l1_l2_token_bridge/solidity/lib/forge-std/.gitignore
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,4 @@ | ||
cache/ | ||
out/ | ||
.vscode | ||
.idea |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of notes/questions:
forge-std
library is included in the source, as it makes it any extra setup unnecessary to run tests for the SolidityTokenBridge
in the future. Let me know if you want this removed, and we can add a README note with instructions on how to set this up.