Skip to content

Commit

Permalink
Merge branch 'main' into custom-digest-item
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Dec 15, 2023
2 parents a7cd663 + 63906dd commit 193b240
Show file tree
Hide file tree
Showing 43 changed files with 614 additions and 329 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/parachain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ jobs:
- name: clippy
working-directory: parachain
run: cargo clippy -- -D warnings
- name: taplo
working-directory: parachain
run: |
cargo install taplo-cli --locked && taplo format --check --config .config/taplo.toml
- name: zepter
working-directory: parachain
run: |
cargo install zepter -f --locked && zepter run check
test:
needs: check
Expand Down
35 changes: 35 additions & 0 deletions parachain/.config/taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# all options https://taplo.tamasfe.dev/configuration/formatter-options.html

# ignore zombienet as they do some deliberate custom toml stuff
exclude = [
"_typos.toml",
"contracts/**",
"rust-toolchain.toml",
"web/packages/test/config/launch-config.toml",
"polkadot-sdk/**",
".config/**",
]

# global rules
[formatting]
reorder_arrays = true
inline_table_expand = false
array_auto_expand = false
array_auto_collapse = false
indent_string = " " # tab

# don't re-order order-dependent deb package metadata
[[rule]]
include = ["polkadot/Cargo.toml"]
keys = ["package.metadata.deb"]

[rule.formatting]
reorder_arrays = false

# don't re-order order-dependent rustflags
[[rule]]
include = [".cargo/config.toml"]
keys = ["build"]

[rule.formatting]
reorder_arrays = false
40 changes: 40 additions & 0 deletions parachain/.config/zepter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version:
format: 1
# Minimum version of the binary that is expected to work. This is just for printing a nice error
# message when someone tries to use an older version.
binary: 0.13.2

# The examples in this file assume crate `A` to have a dependency on crate `B`.
workflows:
check:
- [
'lint',
# Check that `A` activates the features of `B`.
'propagate-feature',
# These are the features to check:
'--features=try-runtime,runtime-benchmarks,std',
# Do not try to add a new section into `[features]` of `A` only because `B` expose that feature. There are edge-cases where this is still needed, but we can add them manually.
'--left-side-feature-missing=ignore',
# Ignore the case that `A` it outside of the workspace. Otherwise it will report errors in external dependencies that we have no influence on.
'--left-side-outside-workspace=ignore',
# Some features imply that they activate a specific dependency as non-optional. Otherwise the default behaviour with a `?` is used.
'--feature-enables-dep=try-runtime:frame-try-runtime,runtime-benchmarks:frame-benchmarking',
# Auxillary flags:
'--offline',
'--locked',
'--show-path',
'--quiet',
]
# Same as `check`, but with the `--fix` flag.
default:
- [ $check.0, '--fix' ]

# Will be displayed when any workflow fails:
help:
text: |
Polkadot-SDK uses the Zepter CLI to detect abnormalities in the feature configuration.
It looks like one more more checks failed; please check the console output. You can try to automatically address them by running `zepter`.
Otherwise please ask directly in the Merge Request, GitHub Discussions or on Matrix Chat, thank you.
links:
- "https://github.com/paritytech/polkadot-sdk/issues/1831"
- "https://github.com/ggwpez/zepter"
28 changes: 14 additions & 14 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[workspace]
resolver = "2"
members = [
"primitives/beacon",
"primitives/core",
"primitives/ethereum",
"primitives/router",
"pallets/inbound-queue",
"pallets/outbound-queue",
"pallets/outbound-queue/runtime-api",
"pallets/outbound-queue/merkle-tree",
"pallets/ethereum-beacon-client",
"pallets/system",
"pallets/system/runtime-api",
"runtime/runtime-common",
"runtime/rococo-common",
"runtime/tests",
"pallets/ethereum-beacon-client",
"pallets/inbound-queue",
"pallets/outbound-queue",
"pallets/outbound-queue/merkle-tree",
"pallets/outbound-queue/runtime-api",
"pallets/system",
"pallets/system/runtime-api",
"primitives/beacon",
"primitives/core",
"primitives/ethereum",
"primitives/router",
"runtime/rococo-common",
"runtime/runtime-common",
"runtime/tests",
]

[patch.'https://github.com/snowfork/snowbridge']
Expand Down
82 changes: 45 additions & 37 deletions parachain/pallets/ethereum-beacon-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
serde = { version = "1.0.188", optional = true }
serde_json = { version = "1.0.96", optional = true }
codec = { version = "3.6.1", package = "parity-scale-codec", default-features = false, features = [ "derive" ] }
scale-info = { version = "2.9.0", default-features = false, features = [ "derive" ] }
ssz_rs = { version="0.9.0", default-features = false }
ssz_rs_derive = { version="0.9.0", default-features = false }
codec = { version = "3.6.1", package = "parity-scale-codec", default-features = false, features = ["derive"] }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
ssz_rs = { version = "0.9.0", default-features = false }
ssz_rs_derive = { version = "0.9.0", default-features = false }
byte-slice-cast = { version = "1.2.1", default-features = false }
rlp = { version = "0.5.2", default-features = false }
hex-literal = { version = "0.4.1", optional = true }
log = { version = "0.4.20", default-features = false }

frame-benchmarking = { path = "../../../polkadot-sdk/substrate/frame/benchmarking", default-features = false, optional = true}
frame-benchmarking = { path = "../../../polkadot-sdk/substrate/frame/benchmarking", default-features = false, optional = true }
frame-support = { path = "../../../polkadot-sdk/substrate/frame/support", default-features = false }
frame-system = { path = "../../../polkadot-sdk/substrate/frame/system", default-features = false }
sp-core = { path = "../../../polkadot-sdk/substrate/primitives/core", default-features = false }
Expand All @@ -35,7 +35,7 @@ snowbridge-ethereum = { path = "../../primitives/ethereum", default-features = f
primitives = { package = "snowbridge-beacon-primitives", path = "../../primitives/beacon", default-features = false }
static_assertions = { version = "1.1.0", default-features = false }
bp-runtime = { path = "../../../polkadot-sdk/bridges/primitives/runtime", default-features = false }
pallet-timestamp = { path = "../../../polkadot-sdk/substrate/frame/timestamp", default-features = false, optional = true}
pallet-timestamp = { path = "../../../polkadot-sdk/substrate/frame/timestamp", default-features = false, optional = true }

[dev-dependencies]
rand = "0.8.5"
Expand All @@ -49,40 +49,48 @@ serde = "1.0.188"
[features]
default = ["std"]
fuzzing = [
"sp-io",
"pallet-timestamp",
"serde",
"serde_json",
"hex-literal"
"hex-literal",
"pallet-timestamp",
"serde",
"serde_json",
"sp-io",
]
std = [
"serde",
"codec/std",
"scale-info/std",
"frame-support/std",
"frame-system/std",
'frame-benchmarking/std',
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
"snowbridge-core/std",
"snowbridge-ethereum/std",
"primitives/std",
"ssz_rs/std",
"byte-slice-cast/std",
"bp-runtime/std",
"byte-slice-cast/std",
"rlp/std",
"log/std",
"pallet-timestamp/std",
"bp-runtime/std",
"byte-slice-cast/std",
"byte-slice-cast/std",
"codec/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-timestamp/std",
"primitives/std",
"rlp/std",
"scale-info/std",
"serde",
"snowbridge-core/std",
"snowbridge-ethereum/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"ssz_rs/std",
'frame-benchmarking/std',
]
runtime-benchmarks = [
"beacon-spec-mainnet",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"snowbridge-core/runtime-benchmarks",
"beacon-spec-mainnet",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-timestamp?/runtime-benchmarks",
"snowbridge-core/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-timestamp?/try-runtime",
"sp-runtime/try-runtime",
]
beacon-spec-mainnet = []
6 changes: 3 additions & 3 deletions parachain/pallets/ethereum-beacon-client/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ edition = "2021"
cargo-fuzz = true

[dependencies]
libfuzzer-sys = { version = "0.4", features = [ "arbitrary-derive" ]}
libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] }
arbitrary = { version = "1", optional = true, features = ["derive"] }
snowbridge-ethereum-beacon-client = {path = "..", features = [ "fuzzing" ]}
snowbridge-beacon-primitives= {path = "../../../primitives/beacon"}
snowbridge-ethereum-beacon-client = { path = "..", features = ["fuzzing"] }
snowbridge-beacon-primitives = { path = "../../../primitives/beacon" }
hex-literal = "0.4.1"
sp-core = { path = "../../../../polkadot-sdk/substrate/primitives/core", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/ethereum-beacon-client/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub const MAX_FEE_RECIPIENT_SIZE: usize = 20;
pub const MAX_BRANCH_PROOF_SIZE: usize = 20;

/// DomainType('0x07000000')
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#domain-types
/// <https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#domain-types>
pub const DOMAIN_SYNC_COMMITTEE: [u8; 4] = [7, 0, 0, 0];

pub const PUBKEY_SIZE: usize = 48;
Expand Down
12 changes: 6 additions & 6 deletions parachain/pallets/ethereum-beacon-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ pub mod pallet {
Ok(())
}

/// References and strictly follows https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#validate_light_client_update
/// References and strictly follows <https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#validate_light_client_update>
/// Verifies that provided next sync committee is valid through a series of checks
/// (including checking that a sync committee period isn't skipped and that the header is
/// signed by the current sync committee.
Expand Down Expand Up @@ -468,7 +468,7 @@ pub mod pallet {
Self::validators_root(),
update.signature_slot,
)?;
// Improvement here per https://eth2book.info/capella/part2/building_blocks/signatures/#sync-aggregates
// Improvement here per <https://eth2book.info/capella/part2/building_blocks/signatures/#sync-aggregates>
// suggested start from the full set aggregate_pubkey then subtracting the absolute
// minority that did not participate.
fast_aggregate_verify(
Expand All @@ -482,7 +482,7 @@ pub mod pallet {
Ok(())
}

/// Reference and strictly follows https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#apply_light_client_update
/// Reference and strictly follows <https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#apply_light_client_update
/// Applies a finalized beacon header update to the beacon client. If a next sync committee
/// is present in the update, verify the sync committee by converting it to a
/// SyncCommitteePrepared type. Stores the provided finalized header.
Expand Down Expand Up @@ -722,16 +722,16 @@ pub mod pallet {
/// Stores the validators root in storage. Validators root is the hash tree root of all the
/// validators at genesis and is used to used to identify the chain that we are on
/// (used in conjunction with the fork version).
/// https://eth2book.info/capella/part3/containers/state/#genesis_validators_root
/// <https://eth2book.info/capella/part3/containers/state/#genesis_validators_root>
fn store_validators_root(validators_root: H256) {
<ValidatorsRoot<T>>::set(validators_root);
}

/// Returns the domain for the domain_type and fork_version. The domain is used to
/// distinguish between the different players in the chain (see DomainTypes
/// https://eth2book.info/capella/part3/config/constants/#domain-types) and to ensure we are
/// <https://eth2book.info/capella/part3/config/constants/#domain-types>) and to ensure we are
/// addressing the correct chain.
/// https://eth2book.info/capella/part3/helper/misc/#compute_domain
/// <https://eth2book.info/capella/part3/helper/misc/#compute_domain>
pub(super) fn compute_domain(
domain_type: Vec<u8>,
fork_version: ForkVersion,
Expand Down
2 changes: 2 additions & 0 deletions parachain/pallets/ethereum-beacon-client/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub mod minimal {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
Expand Down Expand Up @@ -209,6 +210,7 @@ pub mod mainnet {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type RuntimeTask = RuntimeTask;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
Expand Down
Loading

0 comments on commit 193b240

Please sign in to comment.