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: update test to correctly expect fork promotion #2

Merged
merged 45 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
25dbf5b
feat: update test to correctly expect fork promotion
raventid Jun 4, 2024
7cf132e
feat: add new public interface to the smart contract
raventid Jun 5, 2024
17e1c1e
fix: fix chainwork calculation on fork promotion
raventid Jun 5, 2024
0344263
feat: add reading full contract stat to the relay
raventid Jun 5, 2024
993a35f
fix: update public contract interfaces
raventid Jun 6, 2024
a16e062
feat: unify block submisssion interface
raventid Jun 7, 2024
87ecc9c
feat: add GC for promoted forks
raventid Jun 7, 2024
e6b94c9
feat: connect new interface to relayer offchain
raventid Jun 7, 2024
62c135a
fix: correct fork diverge on relayer side
raventid Jun 7, 2024
00d1158
chore: add deploy script
raventid Jun 11, 2024
d994543
feat: use tree based fork reorg
raventid Jun 14, 2024
1208f10
fix: fix fork promotion from the tree
raventid Jun 14, 2024
90a76e5
fix: update chainwork computation inside the block
raventid Jun 14, 2024
03c9fd2
feat: additional integration tests
raventid Jun 14, 2024
8870658
chore: update integration tests with chain reorg
raventid Jun 14, 2024
1a0a24f
chore: simplify fork insertion logic
raventid Jun 18, 2024
d0d9e9d
chore: change fork promotion algorithm
raventid Jun 18, 2024
5ad3497
fix: use u64 instead of usize
raventid Jun 18, 2024
3c1beb0
chore: update reorg algo
raventid Jun 18, 2024
2d4d152
chore: use block hashcode instead of a block height
raventid Jun 20, 2024
f1aee62
update relay to work with a new contract architecture
raventid Jun 20, 2024
e9b95de
feat: use init macro to initialize contract
raventid Jun 21, 2024
042d941
chore: rename init_genesis method, add panic on default
raventid Jun 21, 2024
d5aece1
chore: remove dead default implemenetation
raventid Jun 21, 2024
c3c2dbf
chore: add rust.yml ci
raventid Jun 24, 2024
e2691c4
chore: convert value to the u64
raventid Jun 24, 2024
80f6254
chore: ci fixes for contract
raventid Jun 25, 2024
cf8d335
chore: restruct ci script
raventid Jun 25, 2024
caeb833
chore: add manifest path
raventid Jun 25, 2024
671186c
chore: fmt changes for merkle helpers
raventid Jun 25, 2024
6b25a4c
chore: add tests to CI
raventid Jun 25, 2024
af4853a
chore: install wasm32 before tests
raventid Jun 25, 2024
ceaf63a
chore: add backtrace to the test
raventid Jun 25, 2024
ad18a5a
chore: add clippy
raventid Jun 25, 2024
a2770d8
chore: add manifest path to clippy runner
raventid Jun 25, 2024
465efef
chore: add secret token to clippy
raventid Jun 25, 2024
b3da28f
chore: clippy fixes
raventid Jun 25, 2024
9f700e0
chore: additional fmt fixes
raventid Jun 25, 2024
699829b
chore: try to skip integration tests
raventid Jun 25, 2024
4183c02
chore: add relayer checks to the CI
raventid Jun 25, 2024
99781e0
chore: clippy fixes for relayer
raventid Jun 25, 2024
6a76965
chore: fmt for relayer
raventid Jun 25, 2024
3a37daf
chore: additional clippy directive
raventid Jun 25, 2024
0f19904
Merge pull request #7 from aurora-is-near/generated-ci
raventid Jun 25, 2024
deb91aa
chore: remove artifact
raventid Jun 25, 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
63 changes: 63 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
contract:
name: "Smart contract checks"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./contract
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./contract/Cargo.toml --all -- --check

- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path ./contract/Cargo.toml --all-targets -- -D warnings

- name: Run tests
run: |
rustup target add wasm32-unknown-unknown
RUST_BACKTRACE=1 cargo test -- --skip test_setting_genesis_block --skip test_setting_chain_reorg

relayer:
name: "Relayer checks"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./relayer
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./relayer/Cargo.toml --all -- --check

- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path ./relayer/Cargo.toml --all-targets -- -D warnings

- name: Run tests
run: |
RUST_BACKTRACE=1 cargo test
1 change: 1 addition & 0 deletions contract/Cargo.lock

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

1 change: 1 addition & 0 deletions contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ borsh = "1.5.0"
bitcoin = { version = "0.32.0", features = ["serde"] }
serde_json = "1"
merkle-tools = { path = "../merkle-tools" }
serde = { version = "1.0.200", features = ["derive"] }

[dev-dependencies]
near-sdk = { version = "5.1.0", features = ["unit-testing"] }
Expand Down
14 changes: 14 additions & 0 deletions contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ If you want to test on a testnet follow next steps
```bash
cargo-near near create-dev-account use-random-account-id autogenerate-new-keypair save-to-legacy-keychain network-config testnet create
```
- Add nears to your test account if needed
Go to https://near-faucet.io/ website and request Near for your account
- Deploy contract to testnet
```bash
near contract deploy <<ACCOUNT_NAME_FROM_PREVIOUS_COMMAND>> use-file ./target/wasm32-unknown-unknown/release/btc_light_client_contract.wasm without-init-call network-config testnet sign-with-keychain send
```

Setup relayer service:

```shell
cat <<PATH_TO_THE_KEY_FILE_FROM_ACCOUNT_CREATION_COMMAND>> | jq -r '.private_key'
```

## Useful Links

In more detail, the verification component performs the operations of a Bitcoin SPV client. See this paper (Appendix D) for a more detailed and formal discussion on the necessary functionality.
Expand All @@ -40,3 +48,9 @@ In more detail, the verification component performs the operations of a Bitcoin
* Transaction Inclusion Verification - given a transaction, a reference to a block header, the transaction’s index in that block and a Merkle tree path, determine whether the transaction is indeed included in the specified block header (which in turn must be already verified and stored in the Bitcoin main chain tracked by BTC-Relay).

An overview and explanation of the different classes of blockchain state verification in the context of cross-chain communication, specifically the difference between full validation of transactions and mere verification of their inclusion in the underlying blockchain, can be found in this paper (Section 5).

## FAQ
What if somebody start to send older blocks than the genesis we used to initialize the relay?

In this case we will ot insert those block headers, so we will not use storage for it. We also quickly check if prev_block is included into the contract, so
we will not spend a lot of gas on it.
Loading
Loading