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

Contracts V3 #882

Merged
merged 47 commits into from
Jul 30, 2023
Merged

Contracts V3 #882

merged 47 commits into from
Jul 30, 2023

Conversation

vgeddes
Copy link
Collaborator

@vgeddes vgeddes commented Jul 15, 2023

Several major changes:

  1. Instead of a dozen contracts managing their own state, the bridge is now centred around a single contract design: Gateway.sol.
  2. Agent contracts for Polkadot parachains as discussed with Parity
  3. I've switched over to the proxy upgrade pattern, and using a special technique to implement upgradable storage.

All in all, I think this is a major improvement over the old code. There's less code, and its easier to reason about.

ParaID bridgeHubParaID;
}

bytes32 internal constant SLOT = keccak256("org.snowbridge.storage.core");
Copy link
Collaborator

Choose a reason for hiding this comment

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

should b versioned?

// Operating mode:
OperatingMode mode;
// Message channels
mapping(ParaID paraID => Channel) channels;
Copy link
Collaborator

Choose a reason for hiding this comment

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

as discussed, maybe make this mapping from an agentId instead of paraId?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there's enough time before the audit to properly spec the change and implement it.

@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Patch coverage: 60.61% and project coverage change: +4.92% 🎉

Comparison is base (3c4bec4) 69.80% compared to head (2019277) 74.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #882      +/-   ##
==========================================
+ Coverage   69.80%   74.72%   +4.92%     
==========================================
  Files          47       40       -7     
  Lines        1679     1737      +58     
  Branches       58       74      +16     
==========================================
+ Hits         1172     1298     +126     
+ Misses        489      419      -70     
- Partials       18       20       +2     
Flag Coverage Δ
rust 75.17% <49.33%> (+4.99%) ⬆️
solidity 72.88% <71.73%> (+5.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
parachain/pallets/control/src/weights.rs 0.00% <0.00%> (ø)
parachain/primitives/core/src/outbound.rs 16.92% <16.92%> (ø)
parachain/primitives/router/src/inbound/mod.rs 48.59% <21.42%> (+41.45%) ⬆️
contracts/src/Verification.sol 52.94% <52.94%> (ø)
parachain/pallets/control/src/lib.rs 64.70% <64.51%> (+64.70%) ⬆️
contracts/src/Assets.sol 67.85% <67.85%> (ø)
contracts/src/Gateway.sol 73.28% <73.28%> (ø)
parachain/pallets/inbound-queue/src/lib.rs 65.95% <77.77%> (+9.61%) ⬆️
contracts/src/BeefyClient.sol 75.42% <80.00%> (ø)
parachain/primitives/router/src/outbound/mod.rs 87.96% <85.00%> (-2.80%) ⬇️
... and 9 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -2,18 +2,36 @@
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
pragma solidity 0.8.20;

type ParaID is uint32;
type ParaID is uint256;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this type correct? ParaId is still a u32 in the parachain:

pub use polkadot_parachain::primitives::Id as ParaId;

Copy link
Contributor

Choose a reason for hiding this comment

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

parachain/pallets/control/src/mock.rs Outdated Show resolved Hide resolved
parachain/pallets/control/src/lib.rs Outdated Show resolved Hide resolved
vgeddes and others added 8 commits July 18, 2023 22:54
* Upgrade ssz_rs crate. (#880)

* Upgrade ssz_rs crate.

* Upgrade ssz_rs crate.

---------

Co-authored-by: claravanstaden <Cats 4 life!>

* Bump nixpkgs to use its geth package (#885)

* Bump nixpkgs to use its geth package

* Use source config in PolkadotListener

* Match field order in struct def

* Move info log to relay creation

* Remove unused channel

* Whitespace

* Add context to errors

* Add logs

* Bump node & pnpm in workflow

* Rename locals

* Remove unused variable

* Add Troubleshooting README section

* Fix up .envrc-example files

* Add note about pure shells

* Update cumulus submodule (#886)

* Inbound queue benchmarks (#876)

* Start with inbound channel benchmarks.

* Add method to set execution header storage for benchmark test.

* Working on benchmarks

* Basic working version

* Cleanup

* Removes cleanup.

* Adds some comments for Alistair.

* Adds branch name.

* Makes note

* Test transactions

* Cleaning up beacon client deps.

* Clean up comments.

* Tests cleanup.

* Fixes non-benchmark test runs.

* Cleanup.

* Update fixtures and generates benchmarks.

* Revert relayer logs.

* Cleanup BenchmarkHelper impl and inbound queue dependencies.

* fmt

* Cleanup imports.

* Cleanup imports.

* Touch

* Adds weights in inbound queue pallet.

* Fix tests.

* Update cumulus.

---------

Co-authored-by: claravanstaden <Cats 4 life!>

* Fix parachain build

* Move BalanceOf outside of pallet

* remove benchmark for non existing method

* downgrade cargo.lock to match cumulus

* fix benchmarks

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
* Halting & resuming bridge pallets

* Ignore .env

* Remove .env

* Some polish

* Set owner of bridge pallets

* Upgrade ssz_rs crate. (#880)

* Upgrade ssz_rs crate.

* Upgrade ssz_rs crate.

---------

Co-authored-by: claravanstaden <Cats 4 life!>

* Update cumulus

* Bump nixpkgs to use its geth package (#885)

* Bump nixpkgs to use its geth package

* Use source config in PolkadotListener

* Match field order in struct def

* Move info log to relay creation

* Remove unused channel

* Whitespace

* Add context to errors

* Add logs

* Bump node & pnpm in workflow

* Rename locals

* Remove unused variable

* Add Troubleshooting README section

* Fix up .envrc-example files

* Add note about pure shells

* Relax RANDAO_COMMIT_DELAY for local setup

* Update cumulus

* Update cumulus submodule (#886)

* Update cumulus

* Inbound queue benchmarks (#876)

* Start with inbound channel benchmarks.

* Add method to set execution header storage for benchmark test.

* Working on benchmarks

* Basic working version

* Cleanup

* Removes cleanup.

* Adds some comments for Alistair.

* Adds branch name.

* Makes note

* Test transactions

* Cleaning up beacon client deps.

* Clean up comments.

* Tests cleanup.

* Fixes non-benchmark test runs.

* Cleanup.

* Update fixtures and generates benchmarks.

* Revert relayer logs.

* Cleanup BenchmarkHelper impl and inbound queue dependencies.

* fmt

* Cleanup imports.

* Cleanup imports.

* Touch

* Adds weights in inbound queue pallet.

* Fix tests.

* Update cumulus.

---------

Co-authored-by: claravanstaden <Cats 4 life!>

* Fix test

* Fix parachain build

* Move BalanceOf outside of pallet

* remove benchmark for non existing method

* downgrade cargo.lock to match cumulus

* fix benchmarks

* Clara/sno 552 (#887)

* Spacing

* Spacing

* Undo typo.

* Minor updates.

* Adds comment about IrrelevantUpdate.

* One more comment.

* Update error name.

---------

Co-authored-by: claravanstaden <Cats 4 life!>

* Halting & resuming bridge pallets (#883)

* Halting & resuming bridge pallets

* Ignore .env

* Remove .env

* Some polish

* Set owner of bridge pallets

* Update cumulus

* Relax RANDAO_COMMIT_DELAY for local setup

* Update cumulus

* Update cumulus

* Fix test

* Fix Warnings

* Fix test

* Fix build & format

* Fix benchmark test

* Check for duplicate versions of substrate and polkadot (#891)

* modified pre-commit

* fixes

* testing

* testing

* testing

* fixed tests

* Format

* Some fix

* Update cumulus

* Update cumulus

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: David Dunn <26876072+doubledup@users.noreply.github.com>
Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
vgeddes and others added 4 commits July 23, 2023 13:31
doubledup and others added 7 commits July 24, 2023 16:43
* Catching customized error reverted in solidity

* Fix building error

* Improve error log

* Revert "Fix building error"

This reverts commit 5dc75e0.

* Some polish
claravanstaden and others added 9 commits July 26, 2023 09:46
* Update inbound queue benchmarks.

* Update inbound queue benchmarks.

* Simplify code.

* Fix benchmark test.

* Updates cumulus.

* Cleans up test.

---------

Co-authored-by: claravanstaden <Cats 4 life!>
* Improve Beefy tests

* Update gas snapshot

* Split test fixture

* Update snapshot

* Decode mmr leaf from commitment file

* Regenerate final bitField

* Update foundry remove ffi

* Update test remove hardcode check
* Check vset len on ticket against relevant vset len

* Order methods by expected use

* Sort errors

* Add mocked tests

* Add comments about zero-value tickets

* Move helpers back

* Swap final length checks for initial id checks

* Fix handover stale commitment test
* update gateway to registry

* fixed test

* fmt

* make agents relative to the relaychain

* use address(this)

* fmt

* log out reciept and drop sent amount

* update cumulus

* use real agent ids

* create agents on initialize

* Revert "create agents on initialize"

This reverts commit e53557d.

* update agents and fix abi encode

* encode with enum

* fmt

* update cumulus

* fix encoding

* fix tests

* update cumulus

* rustfmt

* remove duplicate enum

* generate bindings

* remove tuple

* use framebenchmarking v2

* updated cumulus
* Improve documentation of code comments

* Refactor snowbridge-core crate

* Add more comments

* Add final newline
* Make core/contracts js independent

* Clean dependencies

* More cleanup

* Fix ci

* remove submodules

* move contracts dir

* foo

* forge install: forge-std

v1.6.0

* forge install: openzeppelin-contracts

v4.9.2

* forge install: ds-test

* forge install: canonical-weth

* Move contracts dir

* improve contract-types package

* rename

* refacta

* foo

* update docs

* fixes

* foo

* fix imports

---------

Co-authored-by: Vincent Geddes <vincent.geddes@hey.com>
Copy link
Contributor

@alistair-singh alistair-singh left a comment

Choose a reason for hiding this comment

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

🚀

@vgeddes vgeddes merged commit 30d0f0a into main Jul 30, 2023
5 checks passed
@vgeddes vgeddes deleted the proxy-contracts branch July 30, 2023 13:35
@vgeddes vgeddes restored the proxy-contracts branch July 30, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants