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

feat: L3 support #437

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8949443
feat : l3 support init
ocdbytes Dec 18, 2024
abc808e
code : refactor
ocdbytes Dec 18, 2024
a49e209
feat : added tests for starknet client
ocdbytes Dec 20, 2024
0d6168e
changelog update
ocdbytes Dec 20, 2024
76bc944
Merge branch 'main' into l3-support
ocdbytes Dec 20, 2024
75229a4
fix : lint
ocdbytes Dec 20, 2024
661cd33
feat: added update state worker test for starknet client
ocdbytes Dec 20, 2024
62fb337
feat : added messaging implementation for l2 client & resolved commen…
ocdbytes Dec 26, 2024
d4aa988
feat : updated l2 messaging implementation
ocdbytes Dec 27, 2024
a4314be
feat : updated l2 messaging implementation
ocdbytes Dec 27, 2024
9dea223
feat : updated messaging logic
ocdbytes Dec 27, 2024
fafd2c3
clients refactoring done
ocdbytes Jan 6, 2025
aa7834e
refactor : tests
ocdbytes Jan 6, 2025
6c1ff95
fix : tests
ocdbytes Jan 7, 2025
26c9319
feat : updated streams and added tests for streams
ocdbytes Jan 14, 2025
2a19391
fix : changed event params in messaging contract
ocdbytes Jan 14, 2025
8abf999
refactor : removed external devnet.yaml file
ocdbytes Jan 14, 2025
749df1c
feat : removed expects
ocdbytes Jan 14, 2025
b63cf61
refactor crates structure
ocdbytes Jan 14, 2025
c837570
merge main
ocdbytes Jan 14, 2025
1d4d3a4
resolved comments
ocdbytes Jan 15, 2025
fffd9dd
refactor
ocdbytes Jan 17, 2025
71c5524
feat : added automock tests and resolved comments
ocdbytes Jan 21, 2025
62d1df3
merge : main
ocdbytes Jan 21, 2025
79ef5ab
refactor
ocdbytes Jan 21, 2025
8657da3
refactor code and comments resolved
ocdbytes Jan 22, 2025
7afd1a3
Merge branch 'main' into l3-support
Mohiiit Feb 1, 2025
c2ba583
refactor: eth settlement client test udpated to use same anvil instance
Mohiiit Feb 5, 2025
885ae41
refactor: test simplified
Mohiiit Feb 5, 2025
ab24677
fix(eth-settlement): error handling cases fixed
Mohiiit Feb 5, 2025
2349d33
refactor(eth-settlement): fold pattern used
Mohiiit Feb 5, 2025
545c5b5
refactor(eth-settlement): event stream tests removed code duplication
Mohiiit Feb 5, 2025
704ca2d
refactor(settlement-client): SettlementClientError introduced replaci…
Mohiiit Feb 5, 2025
8e17399
refactor(settlement-client): SettlmentClientError added for every any…
Mohiiit Feb 6, 2025
22e4586
fix(settlement-client): messagin tests working, new removed from Clie…
Mohiiit Feb 7, 2025
77ad470
refactor(settlement-client): clientTrait changed to settlementClientT…
Mohiiit Feb 7, 2025
a55eb4e
chore(settlment-client): resolving comments regarding automock and na…
Mohiiit Feb 7, 2025
156bd33
chore(settlement-client): comments resolved in starknet settlement cl…
Mohiiit Feb 11, 2025
911cb87
chore(settlement-client): starknet test working
Mohiiit Feb 12, 2025
949826c
chore(settlement-client): cargo.toml cleaned
Mohiiit Feb 12, 2025
46ece21
chore(github-workflow): workflow updated to use cached madara binary
Mohiiit Feb 12, 2025
4cc7b99
chore: linting and formatting
Mohiiit Feb 12, 2025
4d6ef19
fix(settlement-client): madara drop issue fixed, linting and formatting
Mohiiit Feb 12, 2025
2b9ace3
Merge branch 'main' into l3-support
Mohiiit Feb 13, 2025
5664430
Merge branch 'main' into l3-support
Mohiiit Feb 25, 2025
b96b091
refactor(settlement-client): introducing trait specific error type
Mohiiit Feb 25, 2025
bdadcda
refactor(settlement-client): introducing common error to the rest of …
Mohiiit Feb 25, 2025
4d3489e
refactor(settlement-client): updating the context and other error han…
Mohiiit Feb 26, 2025
aee128b
refactor(settlement-client): error handling resolved
Mohiiit Feb 26, 2025
75a5692
chore: merging main with l3-support
Mohiiit Feb 26, 2025
039a73b
chore: main merged
Mohiiit Feb 26, 2025
eb85f68
chore: rust-toolchain updated
Mohiiit Feb 26, 2025
ecf3f8c
refactor(settlement-client): tests refactored to drop db
Mohiiit Feb 27, 2025
95cadd3
fix(test)(settlement-client): messaging test fixed
Mohiiit Feb 27, 2025
734df0d
linting: toml filed linted
Mohiiit Feb 28, 2025
b7ddb02
refactor(settlement-client): errors improved
Mohiiit Feb 28, 2025
d4fd1a2
fix(l1-txn): l2<>l3 messages were breaking because of the conversion,…
Mohiiit Feb 28, 2025
9750d43
chore(linting): formatting and linting, fixing one test
Mohiiit Feb 28, 2025
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
10 changes: 10 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ jobs:
with:
version: nightly

- name: Restore Madara binary
uses: actions/cache@v3
id: cache-madara
with:
path: test-artifacts/madara
key: ${{ runner.os }}-madara-bin-
restore-keys: |
${{ runner.os }}-madara-bin-
fail-on-cache-miss: true

- name: Build and run tests
env:
ETH_FORK_URL: ${{ secrets.ETH_FORK_URL }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ jobs:
needs: rust_check
uses: ./.github/workflows/linters-cargo.yml

coverage:
name: Run Coverage
needs: update_db_version
secrets: inherit
uses: ./.github/workflows/coverage.yml

build:
name: Build Madara
needs: update_db_version
uses: ./.github/workflows/build.yml

coverage:
name: Run Coverage
needs: build
secrets: inherit
uses: ./.github/workflows/coverage.yml

js_test:
name: Run JS Tests
needs: build
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ jobs:
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Launch Anvil
run: anvil --fork-url $ANVIL_FORK_URL --fork-block-number $ANVIL_BLOCK_NUMBER &
env:
ANVIL_FORK_URL: "https://eth.merkle.io"
ANVIL_BLOCK_NUMBER: 20395662
- name: Wait for Anvil to be ready
run: |
while ! nc -z localhost 8545; do
sleep 1
done
Comment on lines +23 to +32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this is necessary? If I remember the rust unit tests should start anvil anyway no?

# TODO : For now madara binary is stored in aws s3 bucket :
# After the proper release binaries are implemented
# We can directly use that and we can remove this
# temporary AWS implementation
- name: Download madara binary for l2 client testing
run: |
curl -L https://madara-test-binary.s3.us-west-1.amazonaws.com/madara-linux -o ./test-artifacts/madara
chmod +x ./test-artifacts/madara
Comment on lines +37 to +40
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


- name: Run unit tests
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ tmp/
# Running madara with make and docker compose
.secrets
image.tar.gz

# madara test artifacts for testing l2 clients for appchains
test-artifacts/madara
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- feat: settlement client introduced instead of just ethereum, starknet client added for settlement
- fix(primitives): limit legacy class sizes
- fix(block_production): dynamic block closing now adds special address with prev block hash
- fix(rpc): call, simulate, estimate rpcs executed on top of the block, not at the start of it
Expand Down
110 changes: 61 additions & 49 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[workspace]
members = [
# madara
"crates/madara/client/db",
"crates/madara/client/exec",
"crates/madara/client/sync",
"crates/madara/client/eth",
"crates/madara/client/settlement_client",
"crates/madara/client/rpc",
"crates/madara/client/gateway/client",
"crates/madara/client/gateway/server",
Expand Down Expand Up @@ -32,11 +31,10 @@ members = [
resolver = "2"
# Everything except test-related packages, so that they are not compiled when doing `cargo build`.
default-members = [
# madara
"crates/madara/client/db",
"crates/madara/client/exec",
"crates/madara/client/sync",
"crates/madara/client/eth",
"crates/madara/client/settlement_client",
"crates/madara/client/gateway/client",
"crates/madara/client/gateway/server",
"crates/madara/client/rpc",
Expand Down Expand Up @@ -132,7 +130,7 @@ mc-rpc = { path = "crates/madara/client/rpc" }
mc-gateway-client = { path = "crates/madara/client/gateway/client" }
mc-gateway-server = { path = "crates/madara/client/gateway/server" }
mc-sync = { path = "crates/madara/client/sync" }
mc-eth = { path = "crates/madara/client/eth" }
mc-settlement-client = { path = "crates/madara/client/settlement_client" }
mc-mempool = { path = "crates/madara/client/mempool" }
mc-block-production = { path = "crates/madara/client/block_production" }
mc-block-import = { path = "crates/madara/client/block_import" }
Expand All @@ -143,6 +141,8 @@ m-cairo-test-contracts = { path = "crates/madara/cairo-test-contracts" }

# Starknet dependencies
cairo-vm = "=1.0.1"
starknet-accounts = "0.11.0"
starknet-contract = "0.11.0"
starknet-core = "0.12"
starknet-crypto = "0.7"
starknet-providers = "0.12"
Expand Down
53 changes: 53 additions & 0 deletions cairo/src/appchain_test.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#[starknet::contract]
mod StateUpdateContract {
type StateRoot = felt252;
type BlockNumber = felt252;
type BlockHash = felt252;

#[storage]
struct Storage {
state_root: StateRoot,
block_number: BlockNumber,
block_hash: BlockHash,
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
LogStateUpdate: LogStateUpdate
}

#[derive(Drop, starknet::Event)]
struct LogStateUpdate {
state_root: felt252,
block_number: felt252,
block_hash: felt252,
}

#[constructor]
fn constructor(ref self: ContractState) {
// Initialize with default values
self.state_root.write(0);
self.block_number.write(0);
self.block_hash.write(0);
}

#[external(v0)]
fn update_state(
ref self: ContractState,
block_number: BlockNumber,
state_root: StateRoot,
block_hash: BlockHash
) {
self.state_root.write(state_root);
self.block_number.write(block_number);
self.block_hash.write(block_hash);

self.emit(LogStateUpdate { state_root, block_number, block_hash, });
}

#[external(v0)]
fn get_state(self: @ContractState) -> (StateRoot, BlockNumber, BlockHash) {
(self.state_root.read(), self.block_number.read(), self.block_hash.read())
}
}
2 changes: 2 additions & 0 deletions cairo/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

pub mod test_account;
pub mod hello;
pub mod appchain_test;
pub mod messaging_test;
Loading
Loading