Skip to content

Commit

Permalink
scratchpad
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Jan 25, 2024
1 parent 9386529 commit e55362d
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 57 deletions.
30 changes: 6 additions & 24 deletions flake.lock

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

9 changes: 8 additions & 1 deletion parachain/pallets/ethereum-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,14 @@ pub mod pallet {
let execution_header_root: H256 = update
.execution_header
.hash_tree_root()
.map_err(|_| Error::<T>::BlockBodyHashTreeRootFailed)?;
.map_err(|e| {
log::error!(
target: LOG_TARGET,
"💫 BlockBodyHashTreeRootFailed error {}.",
e
);
Error::<T>::BlockBodyHashTreeRootFailed
})?;

ensure!(
verify_merkle_branch(
Expand Down
8 changes: 6 additions & 2 deletions parachain/runtime/test-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,9 @@ runtime-benchmarks = [
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]
beacon-spec-minimal = []
fast-runtime = ["beacon-spec-minimal"]
beacon-spec-minimal = [
"snowbridge-pallet-ethereum-client/beacon-spec-minimal"
]
fast-runtime = [
"beacon-spec-minimal",
]
140 changes: 113 additions & 27 deletions parachain/runtime/test-common/src/fixtures/inbound_queue_minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,92 @@ pub fn make_sync_committee_update_for_inbound() -> Box<Update> {
})
}

pub fn make_sync_committee_update_for_inbound_next_period() -> Box<Update> {
Box::new(Update {
attested_header: BeaconHeader {
slot: 80,
proposer_index: 0,
parent_root: hex!("36bb663ce560c573aad997a5046ac9f2476249705353e20be39fdf907e3326aa").into(),
state_root: hex!("dfae1d7fcc57a6a627f2960f6bd2a983161ff0a7bbc96a70f75fdddaff2985fd").into(),
body_root: hex!("f4411ad1f792f4f7f88965b0d8aa61828d8a37947bccab6ec5135d84a06347cb").into(),
},
sync_aggregate: SyncAggregate{
sync_committee_bits: hex!("ffffffff"),
sync_committee_signature: hex!("8195ba69d3dbc695b34a5cfdfaa0d76388214bcae1f2dcb8bf75cd898e4133b4273c98c544a47d7b1d3129e5daa6c12201751c6b4e2db44e0934463c038eeafbf81af4f7dcbb3baffa71cb4d7804c39243129a6579be7f31bfd8cf796115cd1f").into(),
},
signature_slot: 81,
next_sync_committee_update: Some(NextSyncCommitteeUpdate {
next_sync_committee: SyncCommittee {
pubkeys: [
hex!("a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c").into(),
hex!("ab0bdda0f85f842f431beaccf1250bf1fd7ba51b4100fd64364b6401fda85bb0069b3e715b58819684e7fc0b10a72a34").into(),
hex!("a8d4c7c27795a725961317ef5953a7032ed6d83739db8b0e8a72353d1b8b4439427f7efa2c89caa03cc9f28f8cbab8ac").into(),
hex!("81283b7a20e1ca460ebd9bbd77005d557370cabb1f9a44f530c4c4c66230f675f8df8b4c2818851aa7d77a80ca5a4a5e").into(),
hex!("9977f1c8b731a8d5558146bfb86caea26434f3c5878b589bf280a42c9159e700e9df0e4086296c20b011d2e78c27d373").into(),
hex!("88c141df77cd9d8d7a71a75c826c41a9c9f03c6ee1b180f3e7852f6a280099ded351b58d66e653af8e42816a4d8f532e").into(),
hex!("a3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b").into(),
hex!("b89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b").into(),
hex!("a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c").into(),
hex!("ab0bdda0f85f842f431beaccf1250bf1fd7ba51b4100fd64364b6401fda85bb0069b3e715b58819684e7fc0b10a72a34").into(),
hex!("a8d4c7c27795a725961317ef5953a7032ed6d83739db8b0e8a72353d1b8b4439427f7efa2c89caa03cc9f28f8cbab8ac").into(),
hex!("81283b7a20e1ca460ebd9bbd77005d557370cabb1f9a44f530c4c4c66230f675f8df8b4c2818851aa7d77a80ca5a4a5e").into(),
hex!("9977f1c8b731a8d5558146bfb86caea26434f3c5878b589bf280a42c9159e700e9df0e4086296c20b011d2e78c27d373").into(),
hex!("88c141df77cd9d8d7a71a75c826c41a9c9f03c6ee1b180f3e7852f6a280099ded351b58d66e653af8e42816a4d8f532e").into(),
hex!("a3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b").into(),
hex!("b89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b").into(),
hex!("a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c").into(),
hex!("ab0bdda0f85f842f431beaccf1250bf1fd7ba51b4100fd64364b6401fda85bb0069b3e715b58819684e7fc0b10a72a34").into(),
hex!("a8d4c7c27795a725961317ef5953a7032ed6d83739db8b0e8a72353d1b8b4439427f7efa2c89caa03cc9f28f8cbab8ac").into(),
hex!("81283b7a20e1ca460ebd9bbd77005d557370cabb1f9a44f530c4c4c66230f675f8df8b4c2818851aa7d77a80ca5a4a5e").into(),
hex!("9977f1c8b731a8d5558146bfb86caea26434f3c5878b589bf280a42c9159e700e9df0e4086296c20b011d2e78c27d373").into(),
hex!("88c141df77cd9d8d7a71a75c826c41a9c9f03c6ee1b180f3e7852f6a280099ded351b58d66e653af8e42816a4d8f532e").into(),
hex!("a3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b").into(),
hex!("b89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b").into(),
hex!("a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c").into(),
hex!("ab0bdda0f85f842f431beaccf1250bf1fd7ba51b4100fd64364b6401fda85bb0069b3e715b58819684e7fc0b10a72a34").into(),
hex!("a8d4c7c27795a725961317ef5953a7032ed6d83739db8b0e8a72353d1b8b4439427f7efa2c89caa03cc9f28f8cbab8ac").into(),
hex!("81283b7a20e1ca460ebd9bbd77005d557370cabb1f9a44f530c4c4c66230f675f8df8b4c2818851aa7d77a80ca5a4a5e").into(),
hex!("9977f1c8b731a8d5558146bfb86caea26434f3c5878b589bf280a42c9159e700e9df0e4086296c20b011d2e78c27d373").into(),
hex!("88c141df77cd9d8d7a71a75c826c41a9c9f03c6ee1b180f3e7852f6a280099ded351b58d66e653af8e42816a4d8f532e").into(),
hex!("a3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733bf7e4a9b").into(),
hex!("b89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1a874a0b").into(),
],
aggregate_pubkey: hex!("8fe11476a05750c52618deb79918e2e674f56dfbf12dbce55ae4386d108e8a1e83c6326f5957e2ef19137582ce270dc6").into(),
},
next_sync_committee_branch: vec![
hex!("f4559c0f3e0f259bae33f93ca3463d6737b4f695f3ed5f57b3bb6d41335bc668").into(),
hex!("2f5c3f1ffe90901e4233249e2b96114376538eca8826c1e89455c8358affc568").into(),
hex!("443bb731c28a655e9403263d605c36662184d743f3a0040e1e67bad2e3433018").into(),
hex!("5b068184f755f0224916b9f50f757f4c90d33b066efd1216c1519179fddee0ed").into(),
hex!("6a222825e2a0db30bdd8a4a9bbd6a97ba346d84193a312c57fd1e77d50067c3e").into(),
],
}),
finalized_header: BeaconHeader{
slot: 64,
proposer_index: 1,
parent_root: hex!("f5836885a3658653018057131bb2804971b2c31cf9a8e4deb3f3b593073fb5e8").into(),
state_root: hex!("b9798b26fccf8e4b55e18694608ef040d20cf127a5fe80cc49dcf580b67f1154").into(),
body_root: hex!("b7141601a8b32c576812f75f30ae4ec143454d36f526d1160a89a80c4cca2f6e").into(),
},
finality_branch: vec![
hex!("0800000000000000000000000000000000000000000000000000000000000000").into(),
hex!("10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7").into(),
hex!("93c1d7a5898af1bd11b58d29a14048e5917063fc5ce201e855a9cb4802823740").into(),
hex!("443bb731c28a655e9403263d605c36662184d743f3a0040e1e67bad2e3433018").into(),
hex!("5b068184f755f0224916b9f50f757f4c90d33b066efd1216c1519179fddee0ed").into(),
hex!("6a222825e2a0db30bdd8a4a9bbd6a97ba346d84193a312c57fd1e77d50067c3e").into(),
],
block_roots_root: hex!("9eaf5c27212f3f9e26943955d12189856a5ff6c9bbeb70010ba5af66c41fa1aa").into(),
block_roots_branch: vec![
hex!("d93b457d7b75d15bdcae37849ef0c41deadf905fed32745e4302e565d7322239").into(),
hex!("e2d69345651ecd08b93d2edaa952b177309d7a2886aee0542886b113014d6c4a").into(),
hex!("8e813d69e7c1989314a9ff2db97e23d1347455a155c64f8ade8666304bef44c5").into(),
hex!("91aa5098af40fb8cf04cd75838d5cc5ba6619ab6fcc83b6499e28f07993ea148").into(),
hex!("224c1fe6db9d898000b082879aa96a8d9c22b22266b4fed86c5140170f308f71").into(),
],
})
}

pub fn make_finalized_header_update_for_inbound() -> Box<Update> {
Box::new(Update {
attested_header: BeaconHeader {
Expand Down Expand Up @@ -204,45 +290,45 @@ pub fn make_finalized_header_update_for_inbound() -> Box<Update> {
pub fn make_execution_header_update_for_inbound() -> Box<ExecutionHeaderUpdate> {
Box::new(ExecutionHeaderUpdate {
header: BeaconHeader {
slot: 166,
proposer_index: 7,
parent_root: hex!("da28a205118aaf4aa69a3fb4eb7a565541b7172cc77771ec886b54b6f5bc10f3").into(),
state_root: hex!("179a6249c3e86ebcc9c71a0fc604a825a5fb5dd1602177681c54dc7e09af4265").into(),
body_root: hex!("e1290e50d64f043594bcac66824b04eb3047ae4174188e40106235183f47074c").into(),
slot: 46,
proposer_index: 2,
parent_root: hex!("bed3746d93e09573fc00565f3b0ed19afacb3d474f37168e2eee9c8cb115330e").into(),
state_root: hex!("ee67bd3bdbf21b52f3a43b70634f6abbf16986b7c51f744fbb660b8b30afa7a6").into(),
body_root: hex!("984cf4f6833c77a989dd803a61bea605a5d35b2ac66aa4dc85a99189536acc35").into(),
},
ancestry_proof: Some(AncestryProof {
header_branch: vec![
hex!("bb8245e89f5d7d9191c559425b8522487d98b8f2c9b814a158656eaf06caaa06").into(),
hex!("ab498fef414d709fcac589217246527b82c25706fa800f21d543c83a0ccc59a2").into(),
hex!("de054acbf636cf9f1692137f78179381b5b0328b49fbc4d324eb8e897b41f52c").into(),
hex!("c472fde1df644788c92208467ff5aad686ce55bab1570917e8de1922296666fd").into(),
hex!("11a71c67676c72696c452d875318501cd50968106f72fb611bfe5952285516f8").into(),
hex!("6d2bd2b6cd84ddadc89df27f3f7f9141bb88c742a30123c77eefebef9d5f6667").into(),
hex!("9c7f24db6968bf17b1eb0586eb8ead0c1dc76d9bf0e7edfeecca221a5fd28750").into(),
hex!("5ea3cfc6ca89e22528ec38288e8974863148f5ed4494edbea0cecfe2739801b2").into(),
hex!("77be546b9ec243d669b0c4fdb06f5a7c13bb0109046df7d2991f9019d414ab9a").into(),
hex!("948648ddfd941f2852c82964a8cbed5d1c6b6a4783c811f7df16d28ef1053bc6").into(),
hex!("dd590d345ca5f68003333ac68a80aa767dd659cb4d7368ff169f51e3f9544e7e").into(),
hex!("928ab023edb57be5341d09fa0cbfd8f44d5d0a348baabf8ea9692505adbfca1d").into(),
],
finalized_block_root: hex!("be7d9cc4483ed0065fc7c32e2a783ca3782d8dbd7bfe899fd7c0bcee82f11629").into(),
finalized_block_root: hex!("6102ee45368efa4ce28743d8d520fa2edcb1f3a3e2f1caee7f8966fcb9c81a76").into(),
}),
execution_header: ExecutionPayloadHeader {
parent_hash: hex!("96b27b6e0919c19a70c4a2f7136fd59d2e63a3ba0453a86775add3f2dd681cea").into(),
parent_hash: hex!("3bd02217d4d30e3c1937e8622d3d8e56023dd802baf7fdefaaead4ed7bf0ca5e").into(),
fee_recipient: hex!("0000000000000000000000000000000000000000").into(),
state_root: hex!("b847ee60946ebdb5bd92c22385da44b8a9aea4c6779f1a1402cc06e22b76fb4a").into(),
receipts_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(),
logs_bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(),
prev_randao: hex!("e6c6665aa502e12dd8f5937da2eb7f7fe7a78bc9a900c9321412b8ddd4d72325").into(),
block_number: 166,
gas_limit: 68022694,
gas_used: 0,
timestamp: 1704700423,
extra_data: hex!("d983010d05846765746888676f312e32312e318664617277696e").into(),
base_fee_per_gas: U256::from(7_u64),
block_hash: hex!("1871ded7b2b8b4b5b358c904104704811b15aeefc24e49daa2a1a68176d6553a").into(),
transactions_root: hex!("7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1").into(),
state_root: hex!("f24ad1582d213b6f4609e98c5a7d1359c54fbec3dc565e75298709239245f86f").into(),
receipts_root: hex!("7b1f61b9714c080ef0be014e01657a15f45f0304b477beebc7ca5596c8033095").into(),
logs_bloom: hex!("0000000000000000000000000000000100000000000000000200000000000010").into(),
prev_randao: hex!("e7b186195ecac8dd3612c8d34e78d38ffc6496f881104a673e97fb390cf050f8").into(),
block_number: 46,
gas_limit: 76484160,
gas_used: 119301,
timestamp: 1705413696,
extra_data: hex!("000000000000d983010c00846765746888676f312e32302e358664617277696e").into(),
base_fee_per_gas: U256::from(2240573_u64),
block_hash: hex!("90ffdbbb67ffadb16f4b9473f699d8fcb69e7fe1399c50b0134b7cd8f017fcb1").into(),
transactions_root: hex!("15a29155114530d5e632c145a97cec54ff21b24e4b5fc3744ea883fe7b929b2b").into(),
withdrawals_root: hex!("28ba1834a3a7b657460ce79fa3a1d909ab8828fd557659d4d0554a9bdbc0ec30").into(),
},
execution_branch: vec![
hex!("276d006ecfe51451787321ef00417b194e90b35d4106bd7d51372f39918a4531").into(),
hex!("e49c3af33ab80981116b235e9fea0a47280b912024720f759e283ac354a607a8").into(),
hex!("336488033fe5f3ef4ccc12af07b9370b92e553e35ecb4a337a1b1c0e4afe1e0e").into(),
hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(),
hex!("6b8ff91d1be713c644ef9b3e5b77323897930c342fd12615c0d2142bee5cd1d7").into(),
hex!("bec6857af8cdc6656627ff7e5b26c7f7f82614f3be2eab2484494f8480153d08").into(),
],
})
}
Expand Down
16 changes: 16 additions & 0 deletions parachain/runtime/test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ pub fn ethereum_to_polkadot_message_extrinsics_work<Runtime>(
.execute_with(|| {
let initial_checkpoint = fixtures::make_checkpoint_for_inbound();
let sync_committee_update = fixtures::make_sync_committee_update_for_inbound();
let sync_committee_update_for_next_period = fixtures::make_sync_committee_update_for_inbound_next_period();
let execution_header_update = fixtures::make_execution_header_update_for_inbound();

let alice = Alice;
let alice_account = alice.to_account_id();
Expand All @@ -424,7 +426,21 @@ pub fn ethereum_to_polkadot_message_extrinsics_work<Runtime>(
update: Box::new(*sync_committee_update),
}.into();

let update_sync_committee_call_for_next_period: <Runtime as pallet_utility::Config>::RuntimeCall = snowbridge_pallet_ethereum_client::Call::<Runtime>::submit {
update: Box::new(*sync_committee_update_for_next_period),
}.into();

let execution_header_call: <Runtime as pallet_utility::Config>::RuntimeCall = snowbridge_pallet_ethereum_client::Call::<Runtime>::submit_execution_header {
update: Box::new(*execution_header_update),
}.into();

let sync_committee_outcome = construct_and_apply_extrinsic(alice, update_sync_committee_call.into());
assert_ok!(sync_committee_outcome);

let sync_committee_outcome_next_period_outcome = construct_and_apply_extrinsic(alice, update_sync_committee_call_for_next_period.into());
assert_ok!(sync_committee_outcome_next_period_outcome);

let execution_header_outcome = construct_and_apply_extrinsic(alice, execution_header_call.into());
assert_ok!(execution_header_outcome);
});
}
6 changes: 3 additions & 3 deletions relayer/relays/beacon/header/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof)
}

var displayExecutionBranch []common.Hash
for _, executionHeaderBranch := range displayExecutionBranch {
displayExecutionBranch = append(displayExecutionBranch, common.HexToHash(executionHeaderBranch.Hex()))
for _, exe := range executionHeaderBranch {
displayExecutionBranch = append(displayExecutionBranch, common.HexToHash(exe.Hex()))
}

log.WithFields(log.Fields{
Expand All @@ -507,7 +507,7 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof)
"executionHeader.GasUsed": uint64(executionPayloadScale.GasUsed),
"executionHeader.Timestamp": uint64(executionPayloadScale.Timestamp),
"executionHeader.ExtraData": common.BytesToHash(executionPayloadScale.ExtraData),
"executionHeader.BaseFeePerGas": block.GetExecutionPayload().BaseFeePerGas,
"executionHeader.BaseFeePerGas": executionPayloadScale.BaseFeePerGas,
"executionHeader.BlockHash": executionPayloadScale.BlockHash.Hex(),
"executionHeader.TransactionsRoot": executionPayloadScale.TransactionsRoot.Hex(),
"executionHeader.WithdrawalsRoot": executionPayloadScale.WithdrawalsRoot.Hex(),
Expand Down

0 comments on commit e55362d

Please sign in to comment.