Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejka committed Dec 18, 2024
1 parent f68968c commit 01c9d5b
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @maciejka
4 changes: 4 additions & 0 deletions .github/linter/base_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
all
# lame rules
exclude_rule 'MD002'
exclude_rule 'MD041'
12 changes: 12 additions & 0 deletions .github/linter/readme_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all
# allow inline HTML for README fmt
exclude_rule 'MD033'
# badges trigger rule
exclude_rule 'MD034'
# README img serves as 'First Header'
exclude_rule 'MD002'
exclude_rule 'MD041'
# TODO: disable/enable not working for all-contribs
exclude_rule 'MD013'
# Allow no endline at the end
exclude_rule 'MD047'
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: build

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
permissions: read-all

jobs:
l2-check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./l2
steps:
- uses: actions/checkout@v4
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.9.1"
- uses: foundry-rs/setup-snfoundry@v3
with:
starknet-foundry-version: 0.34.0
- run: pwd
- run: scarb --version
- run: scarb fmt --check
- run: scarb build
36 changes: 36 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: check

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
permissions: read-all

jobs:
markdown:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
sudo gem install mdl
mdl -s .github/linter/readme_style.rb README.md
mdl -s .github/linter/base_style.rb .github
l2-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./l2
steps:
- uses: actions/checkout@v4
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.9.1"
- uses: foundry-rs/setup-snfoundry@v3
with:
starknet-foundry-version: 0.34.0
- run: pwd
- run: scarb --version
- run: scarb test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Pontis

`OP_CAT` enabled Bitcoin <> Starknet Bridge POC

<p align="center" width="100%">
Expand Down
32 changes: 12 additions & 20 deletions l2/src/bridge_poc.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ type L1Address = u256;

#[starknet::interface]
trait IBridgePOC<TContractState> {
fn deposit(ref self: TContractState, recipient: ContractAddress, amount: u256) {
}
fn withdraw(ref self: TContractState, recipient: L1Address, amount: u256) {
}
fn deposit(ref self: TContractState, recipient: ContractAddress, amount: u256) {}
fn withdraw(ref self: TContractState, recipient: L1Address, amount: u256) {}
}


Expand All @@ -28,8 +26,8 @@ mod BridgePOC {
pub const TREE_HEIGHT: u8 = 16;

// Branch of a merkle tree of withdrawal requests. Uses algo described here:
// * https://github.com/ethereum/research/blob/a4a600f2869feed5bfaab24b13ca1692069ef312/beacon_chain_impl/progressive_merkle_tree.py
// * https://www.youtube.com/watch?v=nZ8cquX5kew&ab_channel=FormalMethodsEurope
// https://github.com/ethereum/research/blob/a4a600f2869feed5bfaab24b13ca1692069ef312/beacon_chain_impl/progressive_merkle_tree.py
// https://www.youtube.com/watch?v=nZ8cquX5kew&ab_channel=FormalMethodsEurope
#[phantom]
#[starknet::storage_node]
struct Branch {
Expand All @@ -44,11 +42,8 @@ mod BridgePOC {

#[abi(embed_v0)]
impl BridgePOC of super::IBridgePOC<ContractState> {
fn deposit(ref self: ContractState, recipient: ContractAddress, amount: u256) {
}
fn withdraw(ref self: ContractState, recipient: L1Address, amount: u256) {
}

fn deposit(ref self: ContractState, recipient: ContractAddress, amount: u256) {}
fn withdraw(ref self: ContractState, recipient: L1Address, amount: u256) {}
}

#[generate_trait]
Expand Down Expand Up @@ -76,33 +71,32 @@ mod BridgePOC {

fn append(ref self: ContractState, withdrawal: Digest) {
let mut value = withdrawal;
let original_size = self.withdrawals.size.read();
let original_size = self.withdrawals.size.read();

// TODO: close the queue when it's full?
if original_size == Bounded::<u16>::MAX {
panic!("BridgePoc::withdrawals queue is full");
}

let mut size = original_size;
let mut i = 0;

while size % 2 == 1 {
let element = self.withdrawals.elements.at(i).read();
value = double_sha256_digests(@element, @value);
size = size / 2;
i += 1;
};

self.withdrawals.elements.at(i).write(value);
self.withdrawals.size.write(original_size + 1);
}

fn root(self: @ContractState) -> Digest {

let zero_hashes = Self::ZERO_HASHES.span();

let mut root = DigestTrait::new(*zero_hashes.at(0));

let mut height = 0;
let mut size = self.withdrawals.size.read();

Expand All @@ -120,9 +114,7 @@ mod BridgePOC {

root
}

}

}

#[cfg(test)]
Expand All @@ -141,4 +133,4 @@ mod tests {
previous = double_sha256_digests(@previous, @previous);
}
}
}
}

0 comments on commit 01c9d5b

Please sign in to comment.