diff --git a/Cargo.lock b/Cargo.lock index 4df619131383..99e0661e2718 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2071,6 +2071,7 @@ dependencies = [ "snowbridge-core", "snowbridge-outbound-queue-runtime-api", "snowbridge-pallet-ethereum-client", + "snowbridge-pallet-gas-price", "snowbridge-pallet-inbound-queue", "snowbridge-pallet-outbound-queue", "snowbridge-pallet-system", @@ -19127,6 +19128,7 @@ dependencies = [ "snowbridge-core", "snowbridge-ethereum", "snowbridge-pallet-ethereum-client-fixtures", + "snowbridge-pallet-gas-price", "sp-core", "sp-io", "sp-keyring", @@ -19146,6 +19148,24 @@ dependencies = [ "sp-std 14.0.0", ] +[[package]] +name = "snowbridge-pallet-gas-price" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "snowbridge-core", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0", +] + [[package]] name = "snowbridge-pallet-inbound-queue" version = "0.2.0" @@ -19164,6 +19184,7 @@ dependencies = [ "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-pallet-ethereum-client", + "snowbridge-pallet-gas-price", "snowbridge-pallet-inbound-queue-fixtures", "snowbridge-router-primitives", "sp-core", @@ -19201,6 +19222,7 @@ dependencies = [ "serde", "snowbridge-core", "snowbridge-outbound-queue-merkle-tree", + "snowbridge-pallet-gas-price", "sp-arithmetic", "sp-core", "sp-io", diff --git a/Cargo.toml b/Cargo.toml index d6099e420f91..6e7e726c868c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ members = [ "bridges/relays/utils", "bridges/snowbridge/pallets/ethereum-client", "bridges/snowbridge/pallets/ethereum-client/fixtures", + "bridges/snowbridge/pallets/gas-price", "bridges/snowbridge/pallets/inbound-queue", "bridges/snowbridge/pallets/inbound-queue/fixtures", "bridges/snowbridge/pallets/outbound-queue", diff --git a/bridges/snowbridge/Cargo.lock b/bridges/snowbridge/Cargo.lock index fa1335eef6fc..b235d6ca9702 100644 --- a/bridges/snowbridge/Cargo.lock +++ b/bridges/snowbridge/Cargo.lock @@ -3073,6 +3073,7 @@ name = "pallet-migrations" version = "1.0.0" dependencies = [ "docify", + "frame-benchmarking", "frame-support", "frame-system", "impl-trait-for-tuples", @@ -3740,9 +3741,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -4587,6 +4588,7 @@ dependencies = [ "snowbridge-core", "snowbridge-ethereum", "snowbridge-pallet-ethereum-client-fixtures", + "snowbridge-pallet-gas-price", "sp-core", "sp-io", "sp-keyring", @@ -4606,6 +4608,24 @@ dependencies = [ "sp-std 14.0.0", ] +[[package]] +name = "snowbridge-pallet-gas-price" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "snowbridge-core", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0", +] + [[package]] name = "snowbridge-pallet-inbound-queue" version = "0.2.0" @@ -4624,6 +4644,7 @@ dependencies = [ "snowbridge-beacon-primitives", "snowbridge-core", "snowbridge-pallet-ethereum-client", + "snowbridge-pallet-gas-price", "snowbridge-pallet-inbound-queue-fixtures", "snowbridge-router-primitives", "sp-core", @@ -4661,6 +4682,7 @@ dependencies = [ "serde", "snowbridge-core", "snowbridge-outbound-queue-merkle-tree", + "snowbridge-pallet-gas-price", "sp-arithmetic", "sp-core", "sp-io", diff --git a/bridges/snowbridge/Cargo.toml b/bridges/snowbridge/Cargo.toml index ca70de1d0e07..159f7b79cf4e 100644 --- a/bridges/snowbridge/Cargo.toml +++ b/bridges/snowbridge/Cargo.toml @@ -8,6 +8,7 @@ resolver = "2" members = [ "pallets/ethereum-client", "pallets/ethereum-client/fixtures", + "pallets/gas-price", "pallets/inbound-queue", "pallets/inbound-queue/fixtures", "pallets/outbound-queue", diff --git a/bridges/snowbridge/pallets/ethereum-client/Cargo.toml b/bridges/snowbridge/pallets/ethereum-client/Cargo.toml index 8a5ae18e1c21..7e4c0689c90f 100644 --- a/bridges/snowbridge/pallets/ethereum-client/Cargo.toml +++ b/bridges/snowbridge/pallets/ethereum-client/Cargo.toml @@ -33,6 +33,7 @@ sp-io = { path = "../../../../substrate/primitives/io", default-features = false snowbridge-core = { path = "../../primitives/core", default-features = false } snowbridge-ethereum = { path = "../../primitives/ethereum", default-features = false } snowbridge-pallet-ethereum-client-fixtures = { path = "fixtures", default-features = false, optional = true } +snowbridge-pallet-gas-price = { path = "../gas-price", default-features = false } primitives = { package = "snowbridge-beacon-primitives", path = "../../primitives/beacon", default-features = false } static_assertions = { version = "1.1.0", default-features = false } pallet-migrations = { path = "../../../../substrate/frame/migrations", default-features = false } @@ -66,6 +67,7 @@ std = [ "snowbridge-core/std", "snowbridge-ethereum/std", "snowbridge-pallet-ethereum-client-fixtures/std", + "snowbridge-pallet-gas-price/std", "sp-core/std", "sp-io/std", "sp-runtime/std", @@ -80,11 +82,13 @@ runtime-benchmarks = [ "pallet-migrations/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "snowbridge-pallet-ethereum-client-fixtures/runtime-benchmarks", + "snowbridge-pallet-gas-price/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-migrations/try-runtime", + "snowbridge-pallet-gas-price/try-runtime", "sp-runtime/try-runtime", ] diff --git a/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs b/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs index 37fe45ba60b0..e580b12290da 100644 --- a/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs +++ b/bridges/snowbridge/pallets/ethereum-client/fixtures/src/lib.rs @@ -21,11 +21,11 @@ type Update = snowbridge_beacon_primitives::Update; pub fn make_checkpoint() -> Box { Box::new(CheckpointUpdate { header: BeaconHeader { - slot: 864, - proposer_index: 4, - parent_root: hex!("614e7672f991ac268cd841055973f55e1e42228831a211adef207bb7329be614").into(), - state_root: hex!("5fa8dfca3d760e4242ab46d529144627aa85348a19173b6e081172c701197a4a").into(), - body_root: hex!("0f34c083b1803666bb1ac5e73fa71582731a2cf37d279ff0a3b0cad5a2ff371e").into(), + slot: 4320, + proposer_index: 5, + parent_root: hex!("392451e9e403108d6e770302863c9bee68998a8a295be6e9e37a84f9a4b67361").into(), + state_root: hex!("6b477bcbdeb6fc7cfa297ddfba57961d3f0a99f8de1fb7bd8dd2730a2b9a2f58").into(), + body_root: hex!("b597fe0fc2598ca4b3c99b16757829d9c2a172c8ed2a57efb1ce5896fa8b9b52").into(), }, current_sync_committee: SyncCommittee { pubkeys: [ @@ -546,19 +546,19 @@ pub fn make_checkpoint() -> Box { }, current_sync_committee_branch: vec![ hex!("3ade38d498a062b50880a9409e1ca3a7fd4315d91eeb3bb83e56ac6bfe8d6a59").into(), - hex!("a9e90f89e7f90fd5d79a6bbcaf40ba5cfc05ab1b561ac51c84867c32248d5b1e").into(), - hex!("bd1a76b03e02402bb24a627de1980a80ab17691980271f597b844b89b497ef75").into(), - hex!("07bbcd27c7cad089023db046eda17e8209842b7d97add8b873519e84fe6480e7").into(), - hex!("94c11eeee4cb6192bf40810f23486d8c75dfbc2b6f28d988d6f74435ede243b0").into(), + hex!("6813365f8806f7df9814298e19bbde59d59efe48e2d854d39423fb1e9ed8368c").into(), + hex!("fd2f24d90a2d6c5d909d7170ae8f891e6d330bf6f4122846a15bf819a03de494").into(), + hex!("87d49b977225dc785c07deaf3ece44c130af18fef6a5afbbfb87c419339a2246").into(), + hex!("8307ddad7440aba5b70536366a2bd56d303be6f7f41106b678eadc1b5e2cf15c").into(), ], validators_root: hex!("270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69").into(), - block_roots_root: hex!("b9aab9c388c4e4fcd899b71f62c498fc73406e38e8eb14aa440e9affa06f2a10").into(), + block_roots_root: hex!("eb96512ab79f2db3623e974e42a7083a228e480b2cde553a9435dc462ab013e9").into(), block_roots_branch: vec![ - hex!("733422bd810895dab74cbbe07c69dd440cbb51f573181ad4dddac30fcdd0f41f").into(), - hex!("9b9eca73ab01d14549c325ba1b4610bb20bf1f8ec2dbd649f9d8cc7f3cea75fa").into(), - hex!("bcc666ad0ad9f9725cbd682bc95589d35b1b53b2a615f1e6e8dd5e086336becf").into(), - hex!("3069b547a08f703a1715016e926cbd64e71f93f64fb68d98d8c8f1ab745c46e5").into(), - hex!("c2de7e1097239404e17b263cfa0473533cc41e903cb03440d633bc5c27314cb4").into(), + hex!("0e9fe3f0cee24cd93739acb2c3f40cfff8f0f031e77c78d1d3b08daabb8c4709").into(), + hex!("716f84dca72470ff71e4d5d435bff588e04497b5c0a777b1397ed9caf2a87c76").into(), + hex!("283908513e23fddf75eb6eb50125d9cf68eecfec10280a036bd45dbfc6a5e86b").into(), + hex!("c4704c3804d3de847771c498b2f90cb62de1b3f079c5897b58c1e4c410dfbb81").into(), + hex!("03ddd20620f208b8465baa1c3cac470479101f320f19ac3541a2f7241e30307d").into(), ], }) } @@ -568,13 +568,13 @@ pub fn make_sync_committee_update() -> Box { attested_header: BeaconHeader { slot: 129, proposer_index: 5, - parent_root: hex!("c2def03fe44a2802130ca1a6d8406e4ccf4f344fec7075d4d84431cd4a8b0904").into(), - state_root: hex!("fa62cde6666add7353d7aedcb61ebe3c6c84b5361e34f814825b1250affb5be4").into(), - body_root: hex!("0f9c69f243fe7b5fa5860396c66c720a9e8b1e526e7914188930497cc4a9134c").into(), + parent_root: hex!("1260041a3519aede50ac472d2d96b0925f3433a016c3ced1d713ba827219f58d").into(), + state_root: hex!("46d9bf0cc73d4c17517b42482e1676b9e287a517241f5f14433519574537fe29").into(), + body_root: hex!("46f556950f1bc1674e22fad298ea49787108fac67c7fe55948d92144817a5457").into(), }, sync_aggregate: SyncAggregate{ sync_committee_bits: hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), - sync_committee_signature: hex!("810cfde2afea3e276256c09bdf1cd321c33dcadeefddcfd24f488e6f756d917cfda90b5b437b3a4b4ef880985afa28a40cf565ec0a82877ddee36adc01d55d9d4a911ae3e22556e4c2636f1c707366fba019fb49450440fcd263d0b054b04bf0").into(), + sync_committee_signature: hex!("a3527a0332ff8a64deef812f1942bf15009de17cc64d80e91735711b7f21289dab52e88ea41148f667905c7a73ba065600354ed5e505ad11020ba325975b464afa6c21d206f2c28da0be2721c428f07c210ab5b7d219c7ded5d80eae303bad3a").into(), }, signature_slot: 130, next_sync_committee_update: Some(NextSyncCommitteeUpdate { @@ -1097,34 +1097,59 @@ pub fn make_sync_committee_update() -> Box { }, next_sync_committee_branch: vec![ hex!("3ade38d498a062b50880a9409e1ca3a7fd4315d91eeb3bb83e56ac6bfe8d6a59").into(), - hex!("43276bee17fc9fba3f4866e902f0e5b5b308d79db91154bb8bf819973837a7d9").into(), - hex!("5572348e13ce59446ca0ea7cfeed07579da05f121920a76559e19bda94dd81cd").into(), - hex!("2d58adca9f3c742530de037f1933d6de1920ea4b68581613d4bc32b71547f221").into(), - hex!("7072b3c6577cd5a89b3234968f316f54630bb97eafbdb59e5b61637a9640255f").into(), + hex!("9ba18fe4e8bbf1c4206159dcc7892fbf4bab4c98ec899f7c59dfb6e8a9dbd1a5").into(), + hex!("90c9bf4594fa3df03a7492beea4901df5701371e59fa475e670b7d0ffc3efd18").into(), + hex!("2889eeff56882ba62ded394b013ce7e8f91fb421490e8d72b8bdfa709f6dee16").into(), + hex!("eeb6862f1c0f1d2c2044d8a81402025331d1c87fd74beb2ae75b7a6157adaedc").into(), ], }), finalized_header: BeaconHeader{ slot: 64, proposer_index: 4, - parent_root: hex!("a876486aaad7ddb897f369fd22d0a9903cd61d00c9e0dfe7998dd68d1008c678").into(), - state_root: hex!("818e21c3388575f8ccc9ff17ec79d5a57915bcd31bccf47770f65a18e068416b").into(), - body_root: hex!("1d1f73b864b3bb7e11ff91b56ca1381e0f9ca8122b2c542db88243604c763019").into(), + parent_root: hex!("5d7e31bfa881e957b4b304b4db4a77fb54c0bcc57df1f2c1c224686485f24a6b").into(), + state_root: hex!("9ede0f25442def7371df4dae47efd8fd85246c07b59748b5f12ea660d27e19a6").into(), + body_root: hex!("db4479e8a7c1eb0f2633caa0495873a3155fe296317cacc6307d290e9ae7bd1d").into(), }, finality_branch: vec![ hex!("0200000000000000000000000000000000000000000000000000000000000000").into(), hex!("10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7").into(), hex!("98e9116c6bb7f20de18800dc63e73e689d06d6a47d35b5e2b32cf093d475840d").into(), - hex!("5572348e13ce59446ca0ea7cfeed07579da05f121920a76559e19bda94dd81cd").into(), - hex!("2d58adca9f3c742530de037f1933d6de1920ea4b68581613d4bc32b71547f221").into(), - hex!("7072b3c6577cd5a89b3234968f316f54630bb97eafbdb59e5b61637a9640255f").into(), + hex!("90c9bf4594fa3df03a7492beea4901df5701371e59fa475e670b7d0ffc3efd18").into(), + hex!("2889eeff56882ba62ded394b013ce7e8f91fb421490e8d72b8bdfa709f6dee16").into(), + hex!("eeb6862f1c0f1d2c2044d8a81402025331d1c87fd74beb2ae75b7a6157adaedc").into(), ], - block_roots_root: hex!("715b08694bef183a6d94b3113d16a7129f89fc3edec85a7e0eaf6ef9153552ef").into(), + block_roots_root: hex!("5d51b82acb0723f82aa9a26135c6416b722f35de9f25a2d8353f15dd31b7ce42").into(), block_roots_branch: vec![ - hex!("4028c72c71b6ce80ea7d18b2c9471f4e4fa39746261a9921e832a4a2f9bdf7bb").into(), - hex!("75f98062661785d3290b7bd998b64446582baa49210733fd4603e1a97cd45a44").into(), - hex!("6fb757f44052f30c464810f01b0132adfa1a5446d8715b41e9af88eee1ee3e65").into(), + hex!("ec42bbdf7abaf34e7279722abbd117dbe778e04131d6a7948c358023ac58f802").into(), + hex!("00a1edb40170a804bfbca2b849e6b0792b2f2238f5a9eeefa31549774644bbae").into(), + hex!("e2f9426422c48479e95156519d910e3abbe669b15e81ee68b9d67beadfcbbc7e").into(), hex!("5340ad5877c72dca689ca04bc8fedb78d67a4801d99887937edd8ccd29f87e82").into(), - hex!("f2b3cb56753939a728ccad399a434ca490f018f2f331529ec0d8b2d59c509271").into(), + hex!("235b0961213d02e78a9fc07cc5f63530f7b00ed18c6890d32bb8ba7c0becb160").into(), + ], + execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { + parent_hash: hex!("45a7ebb5280cbc140b6a1c8b834dea2cffd67ec763eaefc0352aae3a4d730608").into(), + fee_recipient: hex!("0000000000000000000000000000000000000000").into(), + state_root: hex!("4af04a75faa4b87ae218ffe959acda66227b2ef6d8816ea18e7729f93aeb5976").into(), + receipts_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), + logs_bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(), + prev_randao: hex!("fb2d4f65540fceef0cea5fc6213dddec29b1c7cdad4183ad20cc97d91a2ede9b").into(), + block_number: 64, + gas_limit: 75150842, + gas_used: 0, + timestamp: 1718199583, + extra_data: hex!("d983010e03846765746888676f312e32322e338664617277696e").into(), + base_fee_per_gas: U256::from(203491u64), + block_hash: hex!("56db9ccb1521a3234366d83aa672f5a30c37d2105031d913dbb03d286536572e").into(), + transactions_root: hex!("7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1").into(), + withdrawals_root: hex!("792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535").into(), + blob_gas_used: 0, + excess_blob_gas: 0, + }), + execution_branch: vec![ + hex!("0af737aaf89b87d2b5dc6f1e018d8d0e4a56d875579cbdaada559b13fdb523cf").into(), + hex!("b46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb").into(), + hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(), + hex!("723d3769a1e23e40d9885ae54882d6776cd84b5c44fee1637876a8a7108ad80b").into(), ], }) } @@ -1132,95 +1157,120 @@ pub fn make_sync_committee_update() -> Box { pub fn make_finalized_header_update() -> Box { Box::new(Update { attested_header: BeaconHeader { - slot: 933, - proposer_index: 1, - parent_root: hex!("f5fc63e2780ca302b97aea73fc95d74d702b5afe9a772c2b68f695026337b620").into(), - state_root: hex!("d856d11636bc4d866e78be9e747b222b0977556a367ab42e4085277301438050").into(), - body_root: hex!("5689091ab4eb76c2e876271add4924e1c66ce987c300c24aac2ad8c703e9a33f").into(), + slot: 4386, + proposer_index: 6, + parent_root: hex!("d25abc3a738193e0bd431f27dd7954c91f8bee813fc096e398632d6663e8ffaa").into(), + state_root: hex!("ec74363ce5709043a799d5267f444b5d8ab502222243dab087bca53029d55f87").into(), + body_root: hex!("9e1d1462b606c6b0f1b41ed0a3b71317d9d4046edf2632cf3a5c415a1cf8a1b4").into(), }, sync_aggregate: SyncAggregate{ sync_committee_bits: hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), - sync_committee_signature: hex!("93a3d482fe2a2f7fd2b634169752a8fddf1dc28b23a020b398be8526faf37a74ca0f6db1bed78a9c7256c09a6115235e108e0e8a7ce09287317b0856c4b77dfa5adba6cf4c3ebea5bfa4cd2fcde80fd0a532f2defe65d530201d5d2258796559").into(), + sync_committee_signature: hex!("87fa037a99a32cb1ca99f26609b8ddb8130219c065f912789a782fcd664b30f98ace55ac34074134eb4790610b1988ac16c0716c8f254d50f61b098cd274c83073385bc2efd1dcdf29b0a31c11f709d0a599f1b0915a286d5f495865b9962c77").into(), }, - signature_slot: 934, + signature_slot: 4387, next_sync_committee_update: None, finalized_header: BeaconHeader { - slot: 864, - proposer_index: 4, - parent_root: hex!("614e7672f991ac268cd841055973f55e1e42228831a211adef207bb7329be614").into(), - state_root: hex!("5fa8dfca3d760e4242ab46d529144627aa85348a19173b6e081172c701197a4a").into(), - body_root: hex!("0f34c083b1803666bb1ac5e73fa71582731a2cf37d279ff0a3b0cad5a2ff371e").into(), + slot: 4320, + proposer_index: 5, + parent_root: hex!("392451e9e403108d6e770302863c9bee68998a8a295be6e9e37a84f9a4b67361").into(), + state_root: hex!("6b477bcbdeb6fc7cfa297ddfba57961d3f0a99f8de1fb7bd8dd2730a2b9a2f58").into(), + body_root: hex!("b597fe0fc2598ca4b3c99b16757829d9c2a172c8ed2a57efb1ce5896fa8b9b52").into(), }, finality_branch: vec![ - hex!("1b00000000000000000000000000000000000000000000000000000000000000").into(), + hex!("8700000000000000000000000000000000000000000000000000000000000000").into(), hex!("10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7").into(), hex!("98e9116c6bb7f20de18800dc63e73e689d06d6a47d35b5e2b32cf093d475840d").into(), - hex!("f12d9aededc72724e417b518fe6f847684f26f81616243dedf8c551cc7d504f5").into(), - hex!("89a85d0907ab3fd6e00ae385f61d456c6191646404ae7b8d23d0e60440cf4d00").into(), - hex!("9fc943b6020eb61d780d78bcc6f6102a81d2c868d58f36e61c6e286a2dc4d8c2").into(), + hex!("4db2644facd545c22e14258c7ddf7acd7a3ce8267018dac87a981598eee017c8").into(), + hex!("57eba5dfef4f9969adecae20dc8b9afd64ffbbf685ba9ea4cab0ea6b2fe52cc7").into(), + hex!("201b5843dc1d4a9e7d1afeb1e2b10a74ecde46f1aa58daac898070ccae9994ed").into(), ], - block_roots_root: hex!("b9aab9c388c4e4fcd899b71f62c498fc73406e38e8eb14aa440e9affa06f2a10").into(), + block_roots_root: hex!("eb96512ab79f2db3623e974e42a7083a228e480b2cde553a9435dc462ab013e9").into(), block_roots_branch: vec![ - hex!("733422bd810895dab74cbbe07c69dd440cbb51f573181ad4dddac30fcdd0f41f").into(), - hex!("9b9eca73ab01d14549c325ba1b4610bb20bf1f8ec2dbd649f9d8cc7f3cea75fa").into(), - hex!("bcc666ad0ad9f9725cbd682bc95589d35b1b53b2a615f1e6e8dd5e086336becf").into(), - hex!("3069b547a08f703a1715016e926cbd64e71f93f64fb68d98d8c8f1ab745c46e5").into(), - hex!("c2de7e1097239404e17b263cfa0473533cc41e903cb03440d633bc5c27314cb4").into(), - ] + hex!("0e9fe3f0cee24cd93739acb2c3f40cfff8f0f031e77c78d1d3b08daabb8c4709").into(), + hex!("716f84dca72470ff71e4d5d435bff588e04497b5c0a777b1397ed9caf2a87c76").into(), + hex!("283908513e23fddf75eb6eb50125d9cf68eecfec10280a036bd45dbfc6a5e86b").into(), + hex!("c4704c3804d3de847771c498b2f90cb62de1b3f079c5897b58c1e4c410dfbb81").into(), + hex!("03ddd20620f208b8465baa1c3cac470479101f320f19ac3541a2f7241e30307d").into(), + ], + execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { + parent_hash: hex!("7ba7d91836f0a83994def54b13c320944b685f11f53f7a5b55dbd7717f8282f2").into(), + fee_recipient: hex!("0000000000000000000000000000000000000000").into(), + state_root: hex!("19240d5e896f0135f8d4afd1d38809e40973953466ebe93e5b7907ed33b7f602").into(), + receipts_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), + logs_bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(), + prev_randao: hex!("02c62f23df88c2683fd9ab9498209d169b97dd508c598c896a29c731a388a170").into(), + block_number: 4320, + gas_limit: 30000000, + gas_used: 0, + timestamp: 1718203839, + extra_data: hex!("d983010e03846765746888676f312e32322e338664617277696e").into(), + base_fee_per_gas: U256::from(7u64), + block_hash: hex!("b444aa2b99b54bdfc94488f21d4ae3d90a6bb3c79135f867afa0ecc33671a282").into(), + transactions_root: hex!("7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1").into(), + withdrawals_root: hex!("792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535").into(), + blob_gas_used: 0, + excess_blob_gas: 0, + }), + execution_branch: vec![ + hex!("4a6f98b8d0bd23c79e1729184f2fb2d9bba6f3ecacf057b8a176c2ad4e9cbfaf").into(), + hex!("b46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb").into(), + hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(), + hex!("c6a6c8c08db6db2332dfc5cd60e31bfadd8c549cbde1dfc18c431f8569546e59").into(), + ], }) } pub fn make_execution_proof() -> Box { Box::new(ExecutionProof { header: BeaconHeader { - slot: 393, - proposer_index: 4, - parent_root: hex!("6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef").into(), - state_root: hex!("b62ac34a8cb82497be9542fe2114410c9f6021855b766015406101a1f3d86434").into(), - body_root: hex!("04005fe231e11a5b7b1580cb73b177ae8b338bedd745497e6bb7122126a806db").into(), + slot: 3315, + proposer_index: 5, + parent_root: hex!("821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce").into(), + state_root: hex!("6b670b6deb66165307d80a8d3740b22ac529ead8afeb486222715f1a2f0c3301").into(), + body_root: hex!("09d89a4d1a76f840cdf7b081c2d08a88875b452f81201fb251ae31f85e3db547").into(), }, ancestry_proof: Some(AncestryProof { header_branch: vec![ - hex!("6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef").into(), - hex!("fa84cc88ca53a72181599ff4eb07d8b444bce023fe2347c3b4f51004c43439d3").into(), - hex!("cadc8ae211c6f2221c9138e829249adf902419c78eb4727a150baa4d9a02cc9d").into(), - hex!("33a89962df08a35c52bd7e1d887cd71fa7803e68787d05c714036f6edf75947c").into(), - hex!("2c9760fce5c2829ef3f25595a703c21eb22d0186ce223295556ed5da663a82cf").into(), - hex!("e1aa87654db79c8a0ecd6c89726bb662fcb1684badaef5cd5256f479e3c622e1").into(), - hex!("aa70d5f314e4a1fbb9c362f3db79b21bf68b328887248651fbd29fc501d0ca97").into(), - hex!("160b6c235b3a1ed4ef5f80b03ee1c76f7bf3f591c92fca9d8663e9221b9f9f0f").into(), - hex!("f68d7dcd6a07a18e9de7b5d2aa1980eb962e11d7dcb584c96e81a7635c8d2535").into(), - hex!("1d5f912dfd6697110dd1ecb5cb8e77952eef57d85deb373572572df62bb157fc").into(), - hex!("ffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b").into(), - hex!("6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220").into(), - hex!("b7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f").into(), + hex!("821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce").into(), + hex!("4581c25575c7e00f58dee2272387ea90e2740e7f6da8db900c599f2d508324a6").into(), + hex!("2cc1e6c3ebe7e86b47f1bf0c039894e31b4b0dafa6756b54fd3022bb7c61010b").into(), + hex!("96b7d5435be00d11587ddbb26327ad9c41294dbbe2c5943514ec4989dd2da812").into(), + hex!("50ebfb5e5deee271444106d243563b3de7a9b1d08cbd3e8eaeab7aeb54804a8e").into(), + hex!("1c1bec0b29aad780aa6110529359b04d389ad4120b365cb32713fdffb4819cf7").into(), + hex!("cb67238ab2373af38548ebacb1d5fb5b0f0f96969308d4ea85e866e8061ca964").into(), + hex!("5b53ce8f1b1098fe87cade580965959151da4937811353dfedfc9f9d92f75e0c").into(), + hex!("d0aad9b87576b605a7ad13b78a536ef1ddd1ece9004ea584f5c11fe3fc45b13b").into(), + hex!("aa4ebb2acc02add1b4611cfe133b19549de088dc19582104ba28174f8e4e594b").into(), + hex!("ac7cdaaa65f87292f595658ff5812097ad6923b85b3228096c5f013737d004c1").into(), + hex!("49eed12837108fb1e1876339acc6cc7c0aaae4ef21cce7537a0ae0deb795ff5c").into(), + hex!("76e4f7a89c5148cc2c634756e50c372648bf7735ebcb033417cf7fab52ff15c0").into(), ], - finalized_block_root: hex!("751414cd97c0624f922b3e80285e9f776b08fa22fd5f87391f2ed7ef571a8d46").into(), + finalized_block_root: hex!("c4a7023de9f2c068ff89d0b25860042e3a21a1e5a084cde53a5723b5951783a6").into(), }), execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { - parent_hash: hex!("8092290aa21b7751576440f77edd02a94058429ce50e63a92d620951fb25eda2").into(), + parent_hash: hex!("235a9f7885eec82443ebeffb387f5cbfa1ac7880f3934af7d1ed120f35243421").into(), fee_recipient: hex!("0000000000000000000000000000000000000000").into(), - state_root: hex!("96a83e9ddf745346fafcb0b03d57314623df669ed543c110662b21302a0fae8b").into(), - receipts_root: hex!("dccdfceea05036f7b61dcdabadc937945d31e68a8d3dfd4dc85684457988c284").into(), - logs_bloom: hex!("00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000400000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000080000000000000000000000000000040004000000000000002002002000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000080000000000000000000000000000000000100000000000000000200000200000010").into(), - prev_randao: hex!("62e309d4f5119d1f5c783abc20fc1a549efbab546d8d0b25ff1cfd58be524e67").into(), - block_number: 393, - gas_limit: 54492273, - gas_used: 199644, - timestamp: 1710552813, - extra_data: hex!("d983010d0b846765746888676f312e32312e368664617277696e").into(), + state_root: hex!("4d37354c85482e0062441b5c3aef7821e7bc8fec2cbaccc3c3109a07d0867d2d").into(), + receipts_root: hex!("8c24b67e120a15b533ad051c4b5de89736b4334cff9a310cdc9c09a22c86ee68").into(), + logs_bloom: hex!("00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010").into(), + prev_randao: hex!("f42f6e6ec377f1bd2bb00fdb0b450f9326495444071f1c739ebaea1b95c18ede").into(), + block_number: 3315, + gas_limit: 30000000, + gas_used: 123129, + timestamp: 1718202834, + extra_data: hex!("d983010e03846765746888676f312e32322e338664617277696e").into(), base_fee_per_gas: U256::from(7u64), - block_hash: hex!("6a9810efb9581d30c1a5c9074f27c68ea779a8c1ae31c213241df16225f4e131").into(), - transactions_root: hex!("2cfa6ed7327e8807c7973516c5c32a68ef2459e586e8067e113d081c3bd8c07d").into(), + block_hash: hex!("249cbbf7f53da87ba9f38a64bdac502e33a3a6fee5de4b4cdb9dea272ba66af9").into(), + transactions_root: hex!("b85a76005e5d27afcfe8089bb1643d5ef8b93b0af98de881e15b9ddf88d44fd9").into(), withdrawals_root: hex!("792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535").into(), blob_gas_used: 0, excess_blob_gas: 0, }), execution_branch: vec![ - hex!("a6833fa629f3286b6916c6e50b8bf089fc9126bee6f64d0413b4e59c1265834d").into(), + hex!("5b11a468bfdc8f8c658ebd2af2338ecdcce844b60625f437b803c30030910add").into(), hex!("b46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb").into(), hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(), - hex!("d3af7c05c516726be7505239e0b9c7cb53d24abce6b91cdb3b3995f0164a75da").into(), + hex!("d57384ee343bcb9fd81bb0c76b12c10e63c7c76acab987b73e780d60daeb3f35").into(), ], }) } @@ -1239,73 +1289,71 @@ pub fn make_inbound_fixture() -> InboundQueueFixture { }, proof: Proof { receipt_proof: (vec![ - hex!("dccdfceea05036f7b61dcdabadc937945d31e68a8d3dfd4dc85684457988c284").to_vec(), - hex!("4a98e45a319168b0fc6005ce6b744ee9bf54338e2c0784b976a8578d241ced0f").to_vec(), + hex!("8c24b67e120a15b533ad051c4b5de89736b4334cff9a310cdc9c09a22c86ee68").to_vec(), ], vec![ - hex!("f851a09c01dd6d2d8de951c45af23d3ad00829ce021c04d6c8acbe1612d456ee320d4980808080808080a04a98e45a319168b0fc6005ce6b744ee9bf54338e2c0784b976a8578d241ced0f8080808080808080").to_vec(), - hex!("f9028c30b9028802f90284018301d205b9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90179f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").to_vec(), + hex!("f9028e822080b9028802f90284018301e0f9b9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90179f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").to_vec(), ]), execution_proof: ExecutionProof { header: BeaconHeader { - slot: 393, - proposer_index: 4, - parent_root: hex!("6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef").into(), - state_root: hex!("b62ac34a8cb82497be9542fe2114410c9f6021855b766015406101a1f3d86434").into(), - body_root: hex!("04005fe231e11a5b7b1580cb73b177ae8b338bedd745497e6bb7122126a806db").into(), + slot: 3315, + proposer_index: 5, + parent_root: hex!("821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce").into(), + state_root: hex!("6b670b6deb66165307d80a8d3740b22ac529ead8afeb486222715f1a2f0c3301").into(), + body_root: hex!("09d89a4d1a76f840cdf7b081c2d08a88875b452f81201fb251ae31f85e3db547").into(), }, ancestry_proof: Some(AncestryProof { header_branch: vec![ - hex!("6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef").into(), - hex!("fa84cc88ca53a72181599ff4eb07d8b444bce023fe2347c3b4f51004c43439d3").into(), - hex!("cadc8ae211c6f2221c9138e829249adf902419c78eb4727a150baa4d9a02cc9d").into(), - hex!("33a89962df08a35c52bd7e1d887cd71fa7803e68787d05c714036f6edf75947c").into(), - hex!("2c9760fce5c2829ef3f25595a703c21eb22d0186ce223295556ed5da663a82cf").into(), - hex!("e1aa87654db79c8a0ecd6c89726bb662fcb1684badaef5cd5256f479e3c622e1").into(), - hex!("aa70d5f314e4a1fbb9c362f3db79b21bf68b328887248651fbd29fc501d0ca97").into(), - hex!("160b6c235b3a1ed4ef5f80b03ee1c76f7bf3f591c92fca9d8663e9221b9f9f0f").into(), - hex!("f68d7dcd6a07a18e9de7b5d2aa1980eb962e11d7dcb584c96e81a7635c8d2535").into(), - hex!("1d5f912dfd6697110dd1ecb5cb8e77952eef57d85deb373572572df62bb157fc").into(), - hex!("ffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b").into(), - hex!("6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220").into(), - hex!("b7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f").into(), + hex!("821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce").into(), + hex!("4581c25575c7e00f58dee2272387ea90e2740e7f6da8db900c599f2d508324a6").into(), + hex!("2cc1e6c3ebe7e86b47f1bf0c039894e31b4b0dafa6756b54fd3022bb7c61010b").into(), + hex!("96b7d5435be00d11587ddbb26327ad9c41294dbbe2c5943514ec4989dd2da812").into(), + hex!("50ebfb5e5deee271444106d243563b3de7a9b1d08cbd3e8eaeab7aeb54804a8e").into(), + hex!("1c1bec0b29aad780aa6110529359b04d389ad4120b365cb32713fdffb4819cf7").into(), + hex!("cb67238ab2373af38548ebacb1d5fb5b0f0f96969308d4ea85e866e8061ca964").into(), + hex!("5b53ce8f1b1098fe87cade580965959151da4937811353dfedfc9f9d92f75e0c").into(), + hex!("d0aad9b87576b605a7ad13b78a536ef1ddd1ece9004ea584f5c11fe3fc45b13b").into(), + hex!("aa4ebb2acc02add1b4611cfe133b19549de088dc19582104ba28174f8e4e594b").into(), + hex!("ac7cdaaa65f87292f595658ff5812097ad6923b85b3228096c5f013737d004c1").into(), + hex!("49eed12837108fb1e1876339acc6cc7c0aaae4ef21cce7537a0ae0deb795ff5c").into(), + hex!("76e4f7a89c5148cc2c634756e50c372648bf7735ebcb033417cf7fab52ff15c0").into(), ], - finalized_block_root: hex!("751414cd97c0624f922b3e80285e9f776b08fa22fd5f87391f2ed7ef571a8d46").into(), + finalized_block_root: hex!("c4a7023de9f2c068ff89d0b25860042e3a21a1e5a084cde53a5723b5951783a6").into(), }), execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { - parent_hash: hex!("8092290aa21b7751576440f77edd02a94058429ce50e63a92d620951fb25eda2").into(), + parent_hash: hex!("235a9f7885eec82443ebeffb387f5cbfa1ac7880f3934af7d1ed120f35243421").into(), fee_recipient: hex!("0000000000000000000000000000000000000000").into(), - state_root: hex!("96a83e9ddf745346fafcb0b03d57314623df669ed543c110662b21302a0fae8b").into(), - receipts_root: hex!("dccdfceea05036f7b61dcdabadc937945d31e68a8d3dfd4dc85684457988c284").into(), - logs_bloom: hex!("00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000400000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000080000000000000000000000000000040004000000000000002002002000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000080000000000000000000000000000000000100000000000000000200000200000010").into(), - prev_randao: hex!("62e309d4f5119d1f5c783abc20fc1a549efbab546d8d0b25ff1cfd58be524e67").into(), - block_number: 393, - gas_limit: 54492273, - gas_used: 199644, - timestamp: 1710552813, - extra_data: hex!("d983010d0b846765746888676f312e32312e368664617277696e").into(), + state_root: hex!("4d37354c85482e0062441b5c3aef7821e7bc8fec2cbaccc3c3109a07d0867d2d").into(), + receipts_root: hex!("8c24b67e120a15b533ad051c4b5de89736b4334cff9a310cdc9c09a22c86ee68").into(), + logs_bloom: hex!("00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010").into(), + prev_randao: hex!("f42f6e6ec377f1bd2bb00fdb0b450f9326495444071f1c739ebaea1b95c18ede").into(), + block_number: 3315, + gas_limit: 30000000, + gas_used: 123129, + timestamp: 1718202834, + extra_data: hex!("d983010e03846765746888676f312e32322e338664617277696e").into(), base_fee_per_gas: U256::from(7u64), - block_hash: hex!("6a9810efb9581d30c1a5c9074f27c68ea779a8c1ae31c213241df16225f4e131").into(), - transactions_root: hex!("2cfa6ed7327e8807c7973516c5c32a68ef2459e586e8067e113d081c3bd8c07d").into(), + block_hash: hex!("249cbbf7f53da87ba9f38a64bdac502e33a3a6fee5de4b4cdb9dea272ba66af9").into(), + transactions_root: hex!("b85a76005e5d27afcfe8089bb1643d5ef8b93b0af98de881e15b9ddf88d44fd9").into(), withdrawals_root: hex!("792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535").into(), blob_gas_used: 0, excess_blob_gas: 0, }), execution_branch: vec![ - hex!("a6833fa629f3286b6916c6e50b8bf089fc9126bee6f64d0413b4e59c1265834d").into(), + hex!("5b11a468bfdc8f8c658ebd2af2338ecdcce844b60625f437b803c30030910add").into(), hex!("b46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb").into(), hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(), - hex!("d3af7c05c516726be7505239e0b9c7cb53d24abce6b91cdb3b3995f0164a75da").into(), + hex!("d57384ee343bcb9fd81bb0c76b12c10e63c7c76acab987b73e780d60daeb3f35").into(), ], } }, }, finalized_header: BeaconHeader { - slot: 864, - proposer_index: 4, - parent_root: hex!("614e7672f991ac268cd841055973f55e1e42228831a211adef207bb7329be614").into(), - state_root: hex!("5fa8dfca3d760e4242ab46d529144627aa85348a19173b6e081172c701197a4a").into(), - body_root: hex!("0f34c083b1803666bb1ac5e73fa71582731a2cf37d279ff0a3b0cad5a2ff371e").into(), + slot: 4320, + proposer_index: 5, + parent_root: hex!("392451e9e403108d6e770302863c9bee68998a8a295be6e9e37a84f9a4b67361").into(), + state_root: hex!("6b477bcbdeb6fc7cfa297ddfba57961d3f0a99f8de1fb7bd8dd2730a2b9a2f58").into(), + body_root: hex!("b597fe0fc2598ca4b3c99b16757829d9c2a172c8ed2a57efb1ce5896fa8b9b52").into(), }, - block_roots_root: hex!("b9aab9c388c4e4fcd899b71f62c498fc73406e38e8eb14aa440e9affa06f2a10").into(), + block_roots_root: hex!("eb96512ab79f2db3623e974e42a7083a228e480b2cde553a9435dc462ab013e9").into(), } } diff --git a/bridges/snowbridge/pallets/ethereum-client/src/lib.rs b/bridges/snowbridge/pallets/ethereum-client/src/lib.rs index 367eadc50aaa..0262d69b4332 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/lib.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/lib.rs @@ -41,7 +41,7 @@ use primitives::{ fast_aggregate_verify, verify_merkle_branch, verify_receipt_proof, BeaconHeader, BlsError, CompactBeaconState, ForkData, ForkVersion, ForkVersions, PublicKeyPrepared, SigningData, }; -use snowbridge_core::{BasicOperatingMode, RingBufferMap}; +use snowbridge_core::{BasicOperatingMode, GasPriceEstimator, RingBufferMap}; use sp_core::H256; use sp_std::prelude::*; pub use weights::WeightInfo; @@ -49,9 +49,8 @@ pub use weights::WeightInfo; use functions::{ compute_epoch, compute_period, decompress_sync_committee_bits, sync_committee_sum, }; -use types::{CheckpointUpdate, FinalizedBeaconStateBuffer, SyncCommitteePrepared, Update}; - pub use pallet::*; +use types::{CheckpointUpdate, FinalizedBeaconStateBuffer, SyncCommitteePrepared, Update}; pub use config::SLOTS_PER_HISTORICAL_ROOT; @@ -63,6 +62,7 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + use sp_runtime::traits::UniqueSaturatedInto; #[derive(scale_info::TypeInfo, codec::Encode, codec::Decode, codec::MaxEncodedLen)] #[codec(mel_bound(T: Config))] @@ -83,6 +83,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; #[pallet::constant] type ForkVersions: Get; + type GasPrice: GasPriceEstimator; type WeightInfo: WeightInfo; } @@ -115,6 +116,7 @@ pub mod pallet { InvalidExecutionHeaderProof, InvalidAncestryMerkleProof, InvalidBlockRootsRootMerkleProof, + ExpectedExecutionHeader, /// The gap between the finalized headers is larger than the sync committee period, /// rendering execution headers unprovable using ancestry proofs (blocks root size is /// the same as the sync committee period slots). @@ -403,6 +405,23 @@ pub mod pallet { ); } + // Execution payload header corresponding to `beacon.body_root` (from Capella onward) + // https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/light-client/sync-protocol.md#modified-lightclientheader + let execution_header_root: H256 = update + .execution_header + .hash_tree_root() + .map_err(|_| Error::::BlockBodyHashTreeRootFailed)?; + ensure!( + verify_merkle_branch( + execution_header_root, + &update.execution_branch.clone(), + config::EXECUTION_HEADER_SUBTREE_INDEX, + config::EXECUTION_HEADER_DEPTH, + update.finalized_header.body_root + ), + Error::::InvalidExecutionHeaderProof + ); + // Verify sync committee aggregate signature. let sync_committee = if signature_period == store_period { >::get() @@ -468,6 +487,9 @@ pub mod pallet { if update.finalized_header.slot > latest_finalized_state.slot { Self::store_finalized_header(update.finalized_header, update.block_roots_root)?; + T::GasPrice::update( + update.execution_header.base_fee_per_gas().unique_saturated_into(), + ); } Ok(()) diff --git a/bridges/snowbridge/pallets/ethereum-client/src/mock.rs b/bridges/snowbridge/pallets/ethereum-client/src/mock.rs index b29584a0da77..1aa1ddbc6d46 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/mock.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/mock.rs @@ -102,6 +102,7 @@ parameter_types! { impl ethereum_beacon_client::Config for Test { type RuntimeEvent = RuntimeEvent; type ForkVersions = ChainForkVersions; + type GasPrice = (); type WeightInfo = (); } diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/execution-proof.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/execution-proof.json index f55898087dfe..509613840168 100755 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/execution-proof.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/execution-proof.json @@ -1,54 +1,54 @@ { "header": { - "slot": 393, - "proposer_index": 4, - "parent_root": "0x6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef", - "state_root": "0xb62ac34a8cb82497be9542fe2114410c9f6021855b766015406101a1f3d86434", - "body_root": "0x04005fe231e11a5b7b1580cb73b177ae8b338bedd745497e6bb7122126a806db" + "slot": 3315, + "proposer_index": 5, + "parent_root": "0x821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce", + "state_root": "0x6b670b6deb66165307d80a8d3740b22ac529ead8afeb486222715f1a2f0c3301", + "body_root": "0x09d89a4d1a76f840cdf7b081c2d08a88875b452f81201fb251ae31f85e3db547" }, "ancestry_proof": { "header_branch": [ - "0x6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef", - "0xfa84cc88ca53a72181599ff4eb07d8b444bce023fe2347c3b4f51004c43439d3", - "0xcadc8ae211c6f2221c9138e829249adf902419c78eb4727a150baa4d9a02cc9d", - "0x33a89962df08a35c52bd7e1d887cd71fa7803e68787d05c714036f6edf75947c", - "0x2c9760fce5c2829ef3f25595a703c21eb22d0186ce223295556ed5da663a82cf", - "0xe1aa87654db79c8a0ecd6c89726bb662fcb1684badaef5cd5256f479e3c622e1", - "0xaa70d5f314e4a1fbb9c362f3db79b21bf68b328887248651fbd29fc501d0ca97", - "0x160b6c235b3a1ed4ef5f80b03ee1c76f7bf3f591c92fca9d8663e9221b9f9f0f", - "0xf68d7dcd6a07a18e9de7b5d2aa1980eb962e11d7dcb584c96e81a7635c8d2535", - "0x1d5f912dfd6697110dd1ecb5cb8e77952eef57d85deb373572572df62bb157fc", - "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", - "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", - "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f" + "0x821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce", + "0x4581c25575c7e00f58dee2272387ea90e2740e7f6da8db900c599f2d508324a6", + "0x2cc1e6c3ebe7e86b47f1bf0c039894e31b4b0dafa6756b54fd3022bb7c61010b", + "0x96b7d5435be00d11587ddbb26327ad9c41294dbbe2c5943514ec4989dd2da812", + "0x50ebfb5e5deee271444106d243563b3de7a9b1d08cbd3e8eaeab7aeb54804a8e", + "0x1c1bec0b29aad780aa6110529359b04d389ad4120b365cb32713fdffb4819cf7", + "0xcb67238ab2373af38548ebacb1d5fb5b0f0f96969308d4ea85e866e8061ca964", + "0x5b53ce8f1b1098fe87cade580965959151da4937811353dfedfc9f9d92f75e0c", + "0xd0aad9b87576b605a7ad13b78a536ef1ddd1ece9004ea584f5c11fe3fc45b13b", + "0xaa4ebb2acc02add1b4611cfe133b19549de088dc19582104ba28174f8e4e594b", + "0xac7cdaaa65f87292f595658ff5812097ad6923b85b3228096c5f013737d004c1", + "0x49eed12837108fb1e1876339acc6cc7c0aaae4ef21cce7537a0ae0deb795ff5c", + "0x76e4f7a89c5148cc2c634756e50c372648bf7735ebcb033417cf7fab52ff15c0" ], - "finalized_block_root": "0x751414cd97c0624f922b3e80285e9f776b08fa22fd5f87391f2ed7ef571a8d46" + "finalized_block_root": "0xc4a7023de9f2c068ff89d0b25860042e3a21a1e5a084cde53a5723b5951783a6" }, "execution_header": { "Deneb": { - "parent_hash": "0x8092290aa21b7751576440f77edd02a94058429ce50e63a92d620951fb25eda2", + "parent_hash": "0x235a9f7885eec82443ebeffb387f5cbfa1ac7880f3934af7d1ed120f35243421", "fee_recipient": "0x0000000000000000000000000000000000000000", - "state_root": "0x96a83e9ddf745346fafcb0b03d57314623df669ed543c110662b21302a0fae8b", - "receipts_root": "0xdccdfceea05036f7b61dcdabadc937945d31e68a8d3dfd4dc85684457988c284", - "logs_bloom": "0x00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000400000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000080000000000000000000000000000040004000000000000002002002000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000080000000000000000000000000000000000100000000000000000200000200000010", - "prev_randao": "0x62e309d4f5119d1f5c783abc20fc1a549efbab546d8d0b25ff1cfd58be524e67", - "block_number": 393, - "gas_limit": 54492273, - "gas_used": 199644, - "timestamp": 1710552813, - "extra_data": "0xd983010d0b846765746888676f312e32312e368664617277696e", + "state_root": "0x4d37354c85482e0062441b5c3aef7821e7bc8fec2cbaccc3c3109a07d0867d2d", + "receipts_root": "0x8c24b67e120a15b533ad051c4b5de89736b4334cff9a310cdc9c09a22c86ee68", + "logs_bloom": "0x00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010", + "prev_randao": "0xf42f6e6ec377f1bd2bb00fdb0b450f9326495444071f1c739ebaea1b95c18ede", + "block_number": 3315, + "gas_limit": 30000000, + "gas_used": 123129, + "timestamp": 1718202834, + "extra_data": "0xd983010e03846765746888676f312e32322e338664617277696e", "base_fee_per_gas": 7, - "block_hash": "0x6a9810efb9581d30c1a5c9074f27c68ea779a8c1ae31c213241df16225f4e131", - "transactions_root": "0x2cfa6ed7327e8807c7973516c5c32a68ef2459e586e8067e113d081c3bd8c07d", + "block_hash": "0x249cbbf7f53da87ba9f38a64bdac502e33a3a6fee5de4b4cdb9dea272ba66af9", + "transactions_root": "0xb85a76005e5d27afcfe8089bb1643d5ef8b93b0af98de881e15b9ddf88d44fd9", "withdrawals_root": "0x792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535", "blob_gas_used": 0, "excess_blob_gas": 0 } }, "execution_branch": [ - "0xa6833fa629f3286b6916c6e50b8bf089fc9126bee6f64d0413b4e59c1265834d", + "0x5b11a468bfdc8f8c658ebd2af2338ecdcce844b60625f437b803c30030910add", "0xb46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb", "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", - "0xd3af7c05c516726be7505239e0b9c7cb53d24abce6b91cdb3b3995f0164a75da" + "0xd57384ee343bcb9fd81bb0c76b12c10e63c7c76acab987b73e780d60daeb3f35" ] } \ No newline at end of file diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/finalized-header-update.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/finalized-header-update.json index 2dec5cc56fac..5bb925325bca 100755 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/finalized-header-update.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/finalized-header-update.json @@ -1,40 +1,65 @@ { "attested_header": { - "slot": 933, - "proposer_index": 1, - "parent_root": "0xf5fc63e2780ca302b97aea73fc95d74d702b5afe9a772c2b68f695026337b620", - "state_root": "0xd856d11636bc4d866e78be9e747b222b0977556a367ab42e4085277301438050", - "body_root": "0x5689091ab4eb76c2e876271add4924e1c66ce987c300c24aac2ad8c703e9a33f" + "slot": 4386, + "proposer_index": 6, + "parent_root": "0xd25abc3a738193e0bd431f27dd7954c91f8bee813fc096e398632d6663e8ffaa", + "state_root": "0xec74363ce5709043a799d5267f444b5d8ab502222243dab087bca53029d55f87", + "body_root": "0x9e1d1462b606c6b0f1b41ed0a3b71317d9d4046edf2632cf3a5c415a1cf8a1b4" }, "sync_aggregate": { "sync_committee_bits": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "sync_committee_signature": "0x93a3d482fe2a2f7fd2b634169752a8fddf1dc28b23a020b398be8526faf37a74ca0f6db1bed78a9c7256c09a6115235e108e0e8a7ce09287317b0856c4b77dfa5adba6cf4c3ebea5bfa4cd2fcde80fd0a532f2defe65d530201d5d2258796559" + "sync_committee_signature": "0x87fa037a99a32cb1ca99f26609b8ddb8130219c065f912789a782fcd664b30f98ace55ac34074134eb4790610b1988ac16c0716c8f254d50f61b098cd274c83073385bc2efd1dcdf29b0a31c11f709d0a599f1b0915a286d5f495865b9962c77" }, - "signature_slot": 934, + "signature_slot": 4387, "next_sync_committee_update": null, "finalized_header": { - "slot": 864, - "proposer_index": 4, - "parent_root": "0x614e7672f991ac268cd841055973f55e1e42228831a211adef207bb7329be614", - "state_root": "0x5fa8dfca3d760e4242ab46d529144627aa85348a19173b6e081172c701197a4a", - "body_root": "0x0f34c083b1803666bb1ac5e73fa71582731a2cf37d279ff0a3b0cad5a2ff371e" + "slot": 4320, + "proposer_index": 5, + "parent_root": "0x392451e9e403108d6e770302863c9bee68998a8a295be6e9e37a84f9a4b67361", + "state_root": "0x6b477bcbdeb6fc7cfa297ddfba57961d3f0a99f8de1fb7bd8dd2730a2b9a2f58", + "body_root": "0xb597fe0fc2598ca4b3c99b16757829d9c2a172c8ed2a57efb1ce5896fa8b9b52" }, "finality_branch": [ - "0x1b00000000000000000000000000000000000000000000000000000000000000", + "0x8700000000000000000000000000000000000000000000000000000000000000", "0x10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7", "0x98e9116c6bb7f20de18800dc63e73e689d06d6a47d35b5e2b32cf093d475840d", - "0xf12d9aededc72724e417b518fe6f847684f26f81616243dedf8c551cc7d504f5", - "0x89a85d0907ab3fd6e00ae385f61d456c6191646404ae7b8d23d0e60440cf4d00", - "0x9fc943b6020eb61d780d78bcc6f6102a81d2c868d58f36e61c6e286a2dc4d8c2" + "0x4db2644facd545c22e14258c7ddf7acd7a3ce8267018dac87a981598eee017c8", + "0x57eba5dfef4f9969adecae20dc8b9afd64ffbbf685ba9ea4cab0ea6b2fe52cc7", + "0x201b5843dc1d4a9e7d1afeb1e2b10a74ecde46f1aa58daac898070ccae9994ed" ], - "block_roots_root": "0xb9aab9c388c4e4fcd899b71f62c498fc73406e38e8eb14aa440e9affa06f2a10", + "block_roots_root": "0xeb96512ab79f2db3623e974e42a7083a228e480b2cde553a9435dc462ab013e9", "block_roots_branch": [ - "0x733422bd810895dab74cbbe07c69dd440cbb51f573181ad4dddac30fcdd0f41f", - "0x9b9eca73ab01d14549c325ba1b4610bb20bf1f8ec2dbd649f9d8cc7f3cea75fa", - "0xbcc666ad0ad9f9725cbd682bc95589d35b1b53b2a615f1e6e8dd5e086336becf", - "0x3069b547a08f703a1715016e926cbd64e71f93f64fb68d98d8c8f1ab745c46e5", - "0xc2de7e1097239404e17b263cfa0473533cc41e903cb03440d633bc5c27314cb4" + "0x0e9fe3f0cee24cd93739acb2c3f40cfff8f0f031e77c78d1d3b08daabb8c4709", + "0x716f84dca72470ff71e4d5d435bff588e04497b5c0a777b1397ed9caf2a87c76", + "0x283908513e23fddf75eb6eb50125d9cf68eecfec10280a036bd45dbfc6a5e86b", + "0xc4704c3804d3de847771c498b2f90cb62de1b3f079c5897b58c1e4c410dfbb81", + "0x03ddd20620f208b8465baa1c3cac470479101f320f19ac3541a2f7241e30307d" ], - "execution_header": null, - "execution_branch": null + "execution_header": { + "Deneb": { + "parent_hash": "0x7ba7d91836f0a83994def54b13c320944b685f11f53f7a5b55dbd7717f8282f2", + "fee_recipient": "0x0000000000000000000000000000000000000000", + "state_root": "0x19240d5e896f0135f8d4afd1d38809e40973953466ebe93e5b7907ed33b7f602", + "receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0x02c62f23df88c2683fd9ab9498209d169b97dd508c598c896a29c731a388a170", + "block_number": 4320, + "gas_limit": 30000000, + "gas_used": 0, + "timestamp": 1718203839, + "extra_data": "0xd983010e03846765746888676f312e32322e338664617277696e", + "base_fee_per_gas": 7, + "block_hash": "0xb444aa2b99b54bdfc94488f21d4ae3d90a6bb3c79135f867afa0ecc33671a282", + "transactions_root": "0x7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1", + "withdrawals_root": "0x792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535", + "blob_gas_used": 0, + "excess_blob_gas": 0 + } + }, + "execution_branch": [ + "0x4a6f98b8d0bd23c79e1729184f2fb2d9bba6f3ecacf057b8a176c2ad4e9cbfaf", + "0xb46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb", + "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0xc6a6c8c08db6db2332dfc5cd60e31bfadd8c549cbde1dfc18c431f8569546e59" + ] } \ No newline at end of file diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/inbound-message.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/inbound-message.json index 6589dca5fb45..82d3f6e363b5 100644 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/inbound-message.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/inbound-message.json @@ -9,70 +9,66 @@ "data": "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000" }, "proof": { - "block_hash": "0x6a9810efb9581d30c1a5c9074f27c68ea779a8c1ae31c213241df16225f4e131", - "tx_index": 0, "receipt_proof": { "keys": [ - "0xdccdfceea05036f7b61dcdabadc937945d31e68a8d3dfd4dc85684457988c284", - "0x4a98e45a319168b0fc6005ce6b744ee9bf54338e2c0784b976a8578d241ced0f" + "0x8c24b67e120a15b533ad051c4b5de89736b4334cff9a310cdc9c09a22c86ee68" ], "values": [ - "0xf851a09c01dd6d2d8de951c45af23d3ad00829ce021c04d6c8acbe1612d456ee320d4980808080808080a04a98e45a319168b0fc6005ce6b744ee9bf54338e2c0784b976a8578d241ced0f8080808080808080", - "0xf9028c30b9028802f90284018301d205b9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90179f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000" + "0xf9028e822080b9028802f90284018301e0f9b9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90179f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000" ] }, "execution_proof": { "header": { - "slot": 393, - "proposer_index": 4, - "parent_root": "0x6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef", - "state_root": "0xb62ac34a8cb82497be9542fe2114410c9f6021855b766015406101a1f3d86434", - "body_root": "0x04005fe231e11a5b7b1580cb73b177ae8b338bedd745497e6bb7122126a806db" + "slot": 3315, + "proposer_index": 5, + "parent_root": "0x821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce", + "state_root": "0x6b670b6deb66165307d80a8d3740b22ac529ead8afeb486222715f1a2f0c3301", + "body_root": "0x09d89a4d1a76f840cdf7b081c2d08a88875b452f81201fb251ae31f85e3db547" }, "ancestry_proof": { "header_branch": [ - "0x6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef", - "0xfa84cc88ca53a72181599ff4eb07d8b444bce023fe2347c3b4f51004c43439d3", - "0xcadc8ae211c6f2221c9138e829249adf902419c78eb4727a150baa4d9a02cc9d", - "0x33a89962df08a35c52bd7e1d887cd71fa7803e68787d05c714036f6edf75947c", - "0x2c9760fce5c2829ef3f25595a703c21eb22d0186ce223295556ed5da663a82cf", - "0xe1aa87654db79c8a0ecd6c89726bb662fcb1684badaef5cd5256f479e3c622e1", - "0xaa70d5f314e4a1fbb9c362f3db79b21bf68b328887248651fbd29fc501d0ca97", - "0x160b6c235b3a1ed4ef5f80b03ee1c76f7bf3f591c92fca9d8663e9221b9f9f0f", - "0xf68d7dcd6a07a18e9de7b5d2aa1980eb962e11d7dcb584c96e81a7635c8d2535", - "0x1d5f912dfd6697110dd1ecb5cb8e77952eef57d85deb373572572df62bb157fc", - "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", - "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", - "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f" + "0x821dc472aec3a3cb284a5853cd6b1f2c2c5c40721a73139ef13cd612a0e858ce", + "0x4581c25575c7e00f58dee2272387ea90e2740e7f6da8db900c599f2d508324a6", + "0x2cc1e6c3ebe7e86b47f1bf0c039894e31b4b0dafa6756b54fd3022bb7c61010b", + "0x96b7d5435be00d11587ddbb26327ad9c41294dbbe2c5943514ec4989dd2da812", + "0x50ebfb5e5deee271444106d243563b3de7a9b1d08cbd3e8eaeab7aeb54804a8e", + "0x1c1bec0b29aad780aa6110529359b04d389ad4120b365cb32713fdffb4819cf7", + "0xcb67238ab2373af38548ebacb1d5fb5b0f0f96969308d4ea85e866e8061ca964", + "0x5b53ce8f1b1098fe87cade580965959151da4937811353dfedfc9f9d92f75e0c", + "0xd0aad9b87576b605a7ad13b78a536ef1ddd1ece9004ea584f5c11fe3fc45b13b", + "0xaa4ebb2acc02add1b4611cfe133b19549de088dc19582104ba28174f8e4e594b", + "0xac7cdaaa65f87292f595658ff5812097ad6923b85b3228096c5f013737d004c1", + "0x49eed12837108fb1e1876339acc6cc7c0aaae4ef21cce7537a0ae0deb795ff5c", + "0x76e4f7a89c5148cc2c634756e50c372648bf7735ebcb033417cf7fab52ff15c0" ], - "finalized_block_root": "0x751414cd97c0624f922b3e80285e9f776b08fa22fd5f87391f2ed7ef571a8d46" + "finalized_block_root": "0xc4a7023de9f2c068ff89d0b25860042e3a21a1e5a084cde53a5723b5951783a6" }, "execution_header": { "Deneb": { - "parent_hash": "0x8092290aa21b7751576440f77edd02a94058429ce50e63a92d620951fb25eda2", + "parent_hash": "0x235a9f7885eec82443ebeffb387f5cbfa1ac7880f3934af7d1ed120f35243421", "fee_recipient": "0x0000000000000000000000000000000000000000", - "state_root": "0x96a83e9ddf745346fafcb0b03d57314623df669ed543c110662b21302a0fae8b", - "receipts_root": "0xdccdfceea05036f7b61dcdabadc937945d31e68a8d3dfd4dc85684457988c284", - "logs_bloom": "0x00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000400000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000080000000000000000000000000000040004000000000000002002002000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000080000000000000000000000000000000000100000000000000000200000200000010", - "prev_randao": "0x62e309d4f5119d1f5c783abc20fc1a549efbab546d8d0b25ff1cfd58be524e67", - "block_number": 393, - "gas_limit": 54492273, - "gas_used": 199644, - "timestamp": 1710552813, - "extra_data": "0xd983010d0b846765746888676f312e32312e368664617277696e", + "state_root": "0x4d37354c85482e0062441b5c3aef7821e7bc8fec2cbaccc3c3109a07d0867d2d", + "receipts_root": "0x8c24b67e120a15b533ad051c4b5de89736b4334cff9a310cdc9c09a22c86ee68", + "logs_bloom": "0x00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010", + "prev_randao": "0xf42f6e6ec377f1bd2bb00fdb0b450f9326495444071f1c739ebaea1b95c18ede", + "block_number": 3315, + "gas_limit": 30000000, + "gas_used": 123129, + "timestamp": 1718202834, + "extra_data": "0xd983010e03846765746888676f312e32322e338664617277696e", "base_fee_per_gas": 7, - "block_hash": "0x6a9810efb9581d30c1a5c9074f27c68ea779a8c1ae31c213241df16225f4e131", - "transactions_root": "0x2cfa6ed7327e8807c7973516c5c32a68ef2459e586e8067e113d081c3bd8c07d", + "block_hash": "0x249cbbf7f53da87ba9f38a64bdac502e33a3a6fee5de4b4cdb9dea272ba66af9", + "transactions_root": "0xb85a76005e5d27afcfe8089bb1643d5ef8b93b0af98de881e15b9ddf88d44fd9", "withdrawals_root": "0x792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535", "blob_gas_used": 0, "excess_blob_gas": 0 } }, "execution_branch": [ - "0xa6833fa629f3286b6916c6e50b8bf089fc9126bee6f64d0413b4e59c1265834d", + "0x5b11a468bfdc8f8c658ebd2af2338ecdcce844b60625f437b803c30030910add", "0xb46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb", "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", - "0xd3af7c05c516726be7505239e0b9c7cb53d24abce6b91cdb3b3995f0164a75da" + "0xd57384ee343bcb9fd81bb0c76b12c10e63c7c76acab987b73e780d60daeb3f35" ] } } diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/initial-checkpoint.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/initial-checkpoint.json index a62d646617e4..51cf51e5207d 100755 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/initial-checkpoint.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/initial-checkpoint.json @@ -1,10 +1,10 @@ { "header": { - "slot": 864, - "proposer_index": 4, - "parent_root": "0x614e7672f991ac268cd841055973f55e1e42228831a211adef207bb7329be614", - "state_root": "0x5fa8dfca3d760e4242ab46d529144627aa85348a19173b6e081172c701197a4a", - "body_root": "0x0f34c083b1803666bb1ac5e73fa71582731a2cf37d279ff0a3b0cad5a2ff371e" + "slot": 4320, + "proposer_index": 5, + "parent_root": "0x392451e9e403108d6e770302863c9bee68998a8a295be6e9e37a84f9a4b67361", + "state_root": "0x6b477bcbdeb6fc7cfa297ddfba57961d3f0a99f8de1fb7bd8dd2730a2b9a2f58", + "body_root": "0xb597fe0fc2598ca4b3c99b16757829d9c2a172c8ed2a57efb1ce5896fa8b9b52" }, "current_sync_committee": { "pubkeys": [ @@ -525,18 +525,18 @@ }, "current_sync_committee_branch": [ "0x3ade38d498a062b50880a9409e1ca3a7fd4315d91eeb3bb83e56ac6bfe8d6a59", - "0xa9e90f89e7f90fd5d79a6bbcaf40ba5cfc05ab1b561ac51c84867c32248d5b1e", - "0xbd1a76b03e02402bb24a627de1980a80ab17691980271f597b844b89b497ef75", - "0x07bbcd27c7cad089023db046eda17e8209842b7d97add8b873519e84fe6480e7", - "0x94c11eeee4cb6192bf40810f23486d8c75dfbc2b6f28d988d6f74435ede243b0" + "0x6813365f8806f7df9814298e19bbde59d59efe48e2d854d39423fb1e9ed8368c", + "0xfd2f24d90a2d6c5d909d7170ae8f891e6d330bf6f4122846a15bf819a03de494", + "0x87d49b977225dc785c07deaf3ece44c130af18fef6a5afbbfb87c419339a2246", + "0x8307ddad7440aba5b70536366a2bd56d303be6f7f41106b678eadc1b5e2cf15c" ], "validators_root": "0x270d43e74ce340de4bca2b1936beca0f4f5408d9e78aec4850920baf659d5b69", - "block_roots_root": "0xb9aab9c388c4e4fcd899b71f62c498fc73406e38e8eb14aa440e9affa06f2a10", + "block_roots_root": "0xeb96512ab79f2db3623e974e42a7083a228e480b2cde553a9435dc462ab013e9", "block_roots_branch": [ - "0x733422bd810895dab74cbbe07c69dd440cbb51f573181ad4dddac30fcdd0f41f", - "0x9b9eca73ab01d14549c325ba1b4610bb20bf1f8ec2dbd649f9d8cc7f3cea75fa", - "0xbcc666ad0ad9f9725cbd682bc95589d35b1b53b2a615f1e6e8dd5e086336becf", - "0x3069b547a08f703a1715016e926cbd64e71f93f64fb68d98d8c8f1ab745c46e5", - "0xc2de7e1097239404e17b263cfa0473533cc41e903cb03440d633bc5c27314cb4" + "0x0e9fe3f0cee24cd93739acb2c3f40cfff8f0f031e77c78d1d3b08daabb8c4709", + "0x716f84dca72470ff71e4d5d435bff588e04497b5c0a777b1397ed9caf2a87c76", + "0x283908513e23fddf75eb6eb50125d9cf68eecfec10280a036bd45dbfc6a5e86b", + "0xc4704c3804d3de847771c498b2f90cb62de1b3f079c5897b58c1e4c410dfbb81", + "0x03ddd20620f208b8465baa1c3cac470479101f320f19ac3541a2f7241e30307d" ] } \ No newline at end of file diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-finalized-header-update.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-finalized-header-update.json index d9bf025ad354..60bc531e8f38 100755 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-finalized-header-update.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-finalized-header-update.json @@ -1,38 +1,65 @@ { "attested_header": { - "slot": 8259, - "proposer_index": 0, - "parent_root": "0x877e9b66f04549e4c924ea6aeb4a33bb7d773b341845dd690f5d738145002f86", - "state_root": "0x724b67fde7de071886d930c5c10560896820cff056029f8519d74599ba244e60", - "body_root": "0x6a3cf016e2be639d86994dc76361195a9aec0a67a18978dbb512765adef02297" + "slot": 8289, + "proposer_index": 2, + "parent_root": "0xa43a6dec8bdf619d569ef2a3dd089fab884fbd19ddf0f7d42cbc6d63f29e9e58", + "state_root": "0xbc0d318a875c14ceb2655f3d8af330cb312a061267cf04a30996a557bfb8836a", + "body_root": "0xe270f9310d1f018487532c1392372e06e2da6375cfc4739903df1e4fd90ab84e" }, "sync_aggregate": { - "sync_committee_bits": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "sync_committee_signature": "0xb817cf06ac29aa973099421c61a7d6bf91a2d04b825c4f860a999d59ccb78e4e53e604f6309f08c7ded14e9170e837150ad3a9994eb1c37d334bc03e35ddf9eadef503027485b339f16bcd5b79715a6bbd58bd823429a1a35d1be2d44a1152f1" + "sync_committee_bits": "0x00000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "sync_committee_signature": "0xa7738ecde533002120aad36fc8db28337cb138dd85af37f40f6798973274f1abe89a06b336bc6f79976184ee7129910c00affc5e30122ecf13468b32ba76d4792b65b9dd9deb562fd2938a62ed52d5beda878e3741c664574471c664905d8fac" }, - "signature_slot": 8260, + "signature_slot": 8290, "next_sync_committee_update": null, "finalized_header": { - "slot": 8192, - "proposer_index": 5, - "parent_root": "0x15889c6c548ed2859150a8d46043ce2711f66a4b4bc61cc0185407d84304ad5b", - "state_root": "0x47f766a70bb799a34f9168e05f8e04b38f5a6c84398c519742a51e1fe7224148", - "body_root": "0x57fbc20d80ae3e3c6c837c98baa7885d9c7e016530625d231a58bb8bdeab2404" + "slot": 8224, + "proposer_index": 6, + "parent_root": "0x066bac5f19ddca023be751a8816ee6d9f3e3d1cba538732e2188df00e031ae0a", + "state_root": "0x4cc378015b86439752474b87b834ca38b4fcc23d89784d5c97f964aae34baf24", + "body_root": "0x5038abf847e5ae714deaf964d50ab8c907203c04a9d255ce935df83766e4e464" }, "finality_branch": [ - "0x0001000000000000000000000000000000000000000000000000000000000000", + "0x0101000000000000000000000000000000000000000000000000000000000000", "0x10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7", "0x5e8a7e8804797705fbca4f2c30646ebea1e4a0da5d001a3455de0301a915e96c", - "0x067ba41a97d3634c7d6bcc5944487e35053644ce1cfe11868d27a97eadc6c012", - "0x995a48c6e5f01d6c345135705cdcfccd7e83d6f0f7d506a7ba9a2578a6ccee3a", - "0xaebdc6f600a419d1cdb7889921c93df7381e8dd934a31a448f31a25d6c2a83fa" + "0x161b807cf0a3d3328e5f39c06c9482a02883e8e9a9b162a98ea900b75de20126", + "0x98146381bc41f079002be3469d7f2564babec516ca9dbfc219cc7822e668250f", + "0xabe008c9b3d70ed82e07d2e05f3303e28ec3f375c26935ab45543e92b5338182" ], - "block_roots_root": "0x2fc4d44f8cea295d336a7f3341ea3eaa258533c917c1de3123fb605a5ed938d7", + "block_roots_root": "0x3a99801e385e260c869b8228909f9bc67ab57ef325938b3da5f05438b8fa4093", "block_roots_branch": [ - "0xa94746addf566d1f83eaf46d2a4b78998b22ad7ae9a12b775d23cf8c50acb4ae", - "0x32a148bfd7e07c2ac056bcab18839d6a21227f3a9d96131c8462183dc42006d7", - "0x3ebcc8ac089dee384fab2122309f5aa64209da83dab2ba9985dcf8e146ed83eb", - "0x6588dcf3d33e1f7697a2d964e68c47df637e026a58b094335a133a726c0a063b", - "0x5ba1e52a00ea3dd089557faa97876f3222ee916ffa94437e0cb43c95ddddd0d3" + "0x47b21d91356e1c79a8a5b664f357dad1bf4648d1e531051ffb8edfbc7ac3dd4b", + "0xd2f80e5a3e089f453536f081f01a3cec8f207e937a7c9adf872dfdcbb07ed2af", + "0xe6a2dd8fb04b501030cbf727b3f634ecfc19dcf32fca09b63bb49c06c45c8024", + "0x997b9d214de812594dfa92fa00804579500cd79230865dbfc7102f3eceb8cc94", + "0x2e20defd6b4a31a6eaa0e04c7faeadfb54a6d2626d407f2e9cace286f1a66d5a" + ], + "execution_header": { + "Deneb": { + "parent_hash": "0x99996761ef477e53bc36666faa4af96e4142fc6fb35db29622ab2635f667ffa3", + "fee_recipient": "0x0000000000000000000000000000000000000000", + "state_root": "0xd68273c80390661d72d8d67fdfb37a713ac2e34bce3ec50515142ae56d3d1c8d", + "receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0xd1a8405e485bc6f5c0a123f8ad09c6814c0a4c863a5c0515449804efbac0ab06", + "block_number": 8224, + "gas_limit": 30000000, + "gas_used": 0, + "timestamp": 1718207743, + "extra_data": "0xd983010e03846765746888676f312e32322e338664617277696e", + "base_fee_per_gas": 7, + "block_hash": "0xcae899a3834e3a9d8ea7ba38ea75a63b82f2f7531aaa0bcb228ea96cf8f9b3b2", + "transactions_root": "0x7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1", + "withdrawals_root": "0x792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535", + "blob_gas_used": 0, + "excess_blob_gas": 0 + } + }, + "execution_branch": [ + "0x6e92dd4691a51189f7e547b53434b5662b91751b504d1c171c9be8108c915318", + "0xb46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb", + "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0xf2ee3a6fadca743410959861f7f1d1ebfcec1104b6a1aacd49187c5b9b6dd5e0" ] } \ No newline at end of file diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-sync-committee-update.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-sync-committee-update.json index 4937f66ff0cd..93c028e4976b 100755 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-sync-committee-update.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/next-sync-committee-update.json @@ -2,13 +2,13 @@ "attested_header": { "slot": 8259, "proposer_index": 0, - "parent_root": "0x877e9b66f04549e4c924ea6aeb4a33bb7d773b341845dd690f5d738145002f86", - "state_root": "0x724b67fde7de071886d930c5c10560896820cff056029f8519d74599ba244e60", - "body_root": "0x6a3cf016e2be639d86994dc76361195a9aec0a67a18978dbb512765adef02297" + "parent_root": "0x0c1e7b204ed9e8e81d2079d1888f2bfca2dcad141a9d0e9593158b7de87a9dd0", + "state_root": "0xc373d6b5bcaf2709a41d32d75da756fc123b3ec6a8110682d17aab649e4ec977", + "body_root": "0x397149f563a9350f3cfe8ff862bccef1b5495d5511b5de7ee2ba201d1f27a012" }, "sync_aggregate": { "sync_committee_bits": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "sync_committee_signature": "0xb817cf06ac29aa973099421c61a7d6bf91a2d04b825c4f860a999d59ccb78e4e53e604f6309f08c7ded14e9170e837150ad3a9994eb1c37d334bc03e35ddf9eadef503027485b339f16bcd5b79715a6bbd58bd823429a1a35d1be2d44a1152f1" + "sync_committee_signature": "0xa672b0e048c59293db864090399d4c9a4b0b23f0c931c2ec6810cd35cd6aaf9c854db6dd8d505ec0a5ff403680cde775090b4e1eed882f16e2a03347d4cb29d6f5b5ecaafc151cf5a97246603c66c56083def36ad08d47228ab70f47a19907fc" }, "signature_slot": 8260, "next_sync_committee_update": { @@ -531,33 +531,60 @@ }, "next_sync_committee_branch": [ "0x3ade38d498a062b50880a9409e1ca3a7fd4315d91eeb3bb83e56ac6bfe8d6a59", - "0xcdc4165a88ae33b52f88df39f4620b936e5d23296fb670b22c04774293e8c4a9", - "0x067ba41a97d3634c7d6bcc5944487e35053644ce1cfe11868d27a97eadc6c012", - "0x995a48c6e5f01d6c345135705cdcfccd7e83d6f0f7d506a7ba9a2578a6ccee3a", - "0xaebdc6f600a419d1cdb7889921c93df7381e8dd934a31a448f31a25d6c2a83fa" + "0x66db5596acd0c011e1b935b429432826605a392047d0e4d3977603b049569acf", + "0xb6e852a028b8f133831da276b99bc30f9a058dc8fa9b2966fbfd29fa7b668ece", + "0x90c644c9afcff60cccd6d58ed9ef940256ae756fd9f9148d37a94c3a5999e879", + "0x2631e562cc1a23b8afb66d9443e9f8e278cc719cd19e7a3163431e7f7e8993bb" ] }, "finalized_header": { "slot": 8192, "proposer_index": 5, - "parent_root": "0x15889c6c548ed2859150a8d46043ce2711f66a4b4bc61cc0185407d84304ad5b", - "state_root": "0x47f766a70bb799a34f9168e05f8e04b38f5a6c84398c519742a51e1fe7224148", - "body_root": "0x57fbc20d80ae3e3c6c837c98baa7885d9c7e016530625d231a58bb8bdeab2404" + "parent_root": "0x2af03c0630b5baba7515c25988aece0aab9de6911393d9189dec0dcefcc14358", + "state_root": "0x7bbbd11de7ca90d8dccfd3f24d12923f9a545f7fbf2a43b242468f320892ead5", + "body_root": "0x6bd1a3bce082ce866017802dd7658d8bbacd2036204912dccc4fffafaa50a9d6" }, "finality_branch": [ "0x0001000000000000000000000000000000000000000000000000000000000000", "0x10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7", "0x5e8a7e8804797705fbca4f2c30646ebea1e4a0da5d001a3455de0301a915e96c", - "0x067ba41a97d3634c7d6bcc5944487e35053644ce1cfe11868d27a97eadc6c012", - "0x995a48c6e5f01d6c345135705cdcfccd7e83d6f0f7d506a7ba9a2578a6ccee3a", - "0xaebdc6f600a419d1cdb7889921c93df7381e8dd934a31a448f31a25d6c2a83fa" + "0xb6e852a028b8f133831da276b99bc30f9a058dc8fa9b2966fbfd29fa7b668ece", + "0x90c644c9afcff60cccd6d58ed9ef940256ae756fd9f9148d37a94c3a5999e879", + "0x2631e562cc1a23b8afb66d9443e9f8e278cc719cd19e7a3163431e7f7e8993bb" ], - "block_roots_root": "0x2fc4d44f8cea295d336a7f3341ea3eaa258533c917c1de3123fb605a5ed938d7", + "block_roots_root": "0xdf2f176739f877187caecd6c6ce48fdc5d79a33253b29122ad707527c003d8a3", "block_roots_branch": [ - "0xa94746addf566d1f83eaf46d2a4b78998b22ad7ae9a12b775d23cf8c50acb4ae", - "0x32a148bfd7e07c2ac056bcab18839d6a21227f3a9d96131c8462183dc42006d7", - "0x3ebcc8ac089dee384fab2122309f5aa64209da83dab2ba9985dcf8e146ed83eb", - "0x6588dcf3d33e1f7697a2d964e68c47df637e026a58b094335a133a726c0a063b", - "0x5ba1e52a00ea3dd089557faa97876f3222ee916ffa94437e0cb43c95ddddd0d3" + "0x021910e219602c5b9a4af1e26c0dcff44bb039ff1fa3ca8ebaac698c331edccc", + "0x8003f9b83a69955490780c5394e12f61ebacf39fe311124ce67ca7a2cb9659f7", + "0x76f41985db0bcd43491ee800d54427e06869f3b57a04fa1786d2bb9aca110cbf", + "0x1526102ecbc21694677431ec981adf226514f174330ef24a967c643ec2383027", + "0x982f6aee1a29f7e9e1a61bda803cf6fa0b64121a19d30e247706e1e89a561f8e" + ], + "execution_header": { + "Deneb": { + "parent_hash": "0x797f82ee1be87a4c716b16919a61bb82b74b7e9230fdf351c82fe2bb7bc29041", + "fee_recipient": "0x0000000000000000000000000000000000000000", + "state_root": "0x88b9b112c5020129f5d309e12a08a28df2bc6c7051fb04048d6acccb732d611b", + "receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0xe141ba57a2e0f09e46a4e32da10262909741e7882942b087a8ea01dd5f020a33", + "block_number": 8192, + "gas_limit": 30000000, + "gas_used": 0, + "timestamp": 1718207711, + "extra_data": "0xd983010e03846765746888676f312e32322e338664617277696e", + "base_fee_per_gas": 7, + "block_hash": "0xa5a3ebbb9a8b3ee817939c7b4c3e6c57c91e90f0ca3cc4bb9641c4474349a22d", + "transactions_root": "0x7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1", + "withdrawals_root": "0x792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535", + "blob_gas_used": 0, + "excess_blob_gas": 0 + } + }, + "execution_branch": [ + "0xc71fa62e42aac0396cf433bddc957fd43b4c40442c2b1be1468adf209677d6be", + "0xb46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb", + "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0xbed4eeadcf255164ab9b35853d2f3a1e3227da9223e30209b7d3eabc3ba03397" ] } \ No newline at end of file diff --git a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/sync-committee-update.json b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/sync-committee-update.json index 4d601d7d8f0b..3fd529685260 100755 --- a/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/sync-committee-update.json +++ b/bridges/snowbridge/pallets/ethereum-client/tests/fixtures/sync-committee-update.json @@ -2,13 +2,13 @@ "attested_header": { "slot": 129, "proposer_index": 5, - "parent_root": "0xc2def03fe44a2802130ca1a6d8406e4ccf4f344fec7075d4d84431cd4a8b0904", - "state_root": "0xfa62cde6666add7353d7aedcb61ebe3c6c84b5361e34f814825b1250affb5be4", - "body_root": "0x0f9c69f243fe7b5fa5860396c66c720a9e8b1e526e7914188930497cc4a9134c" + "parent_root": "0x1260041a3519aede50ac472d2d96b0925f3433a016c3ced1d713ba827219f58d", + "state_root": "0x46d9bf0cc73d4c17517b42482e1676b9e287a517241f5f14433519574537fe29", + "body_root": "0x46f556950f1bc1674e22fad298ea49787108fac67c7fe55948d92144817a5457" }, "sync_aggregate": { "sync_committee_bits": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "sync_committee_signature": "0x810cfde2afea3e276256c09bdf1cd321c33dcadeefddcfd24f488e6f756d917cfda90b5b437b3a4b4ef880985afa28a40cf565ec0a82877ddee36adc01d55d9d4a911ae3e22556e4c2636f1c707366fba019fb49450440fcd263d0b054b04bf0" + "sync_committee_signature": "0xa3527a0332ff8a64deef812f1942bf15009de17cc64d80e91735711b7f21289dab52e88ea41148f667905c7a73ba065600354ed5e505ad11020ba325975b464afa6c21d206f2c28da0be2721c428f07c210ab5b7d219c7ded5d80eae303bad3a" }, "signature_slot": 130, "next_sync_committee_update": { @@ -531,35 +531,60 @@ }, "next_sync_committee_branch": [ "0x3ade38d498a062b50880a9409e1ca3a7fd4315d91eeb3bb83e56ac6bfe8d6a59", - "0x43276bee17fc9fba3f4866e902f0e5b5b308d79db91154bb8bf819973837a7d9", - "0x5572348e13ce59446ca0ea7cfeed07579da05f121920a76559e19bda94dd81cd", - "0x2d58adca9f3c742530de037f1933d6de1920ea4b68581613d4bc32b71547f221", - "0x7072b3c6577cd5a89b3234968f316f54630bb97eafbdb59e5b61637a9640255f" + "0x9ba18fe4e8bbf1c4206159dcc7892fbf4bab4c98ec899f7c59dfb6e8a9dbd1a5", + "0x90c9bf4594fa3df03a7492beea4901df5701371e59fa475e670b7d0ffc3efd18", + "0x2889eeff56882ba62ded394b013ce7e8f91fb421490e8d72b8bdfa709f6dee16", + "0xeeb6862f1c0f1d2c2044d8a81402025331d1c87fd74beb2ae75b7a6157adaedc" ] }, "finalized_header": { "slot": 64, "proposer_index": 4, - "parent_root": "0xa876486aaad7ddb897f369fd22d0a9903cd61d00c9e0dfe7998dd68d1008c678", - "state_root": "0x818e21c3388575f8ccc9ff17ec79d5a57915bcd31bccf47770f65a18e068416b", - "body_root": "0x1d1f73b864b3bb7e11ff91b56ca1381e0f9ca8122b2c542db88243604c763019" + "parent_root": "0x5d7e31bfa881e957b4b304b4db4a77fb54c0bcc57df1f2c1c224686485f24a6b", + "state_root": "0x9ede0f25442def7371df4dae47efd8fd85246c07b59748b5f12ea660d27e19a6", + "body_root": "0xdb4479e8a7c1eb0f2633caa0495873a3155fe296317cacc6307d290e9ae7bd1d" }, "finality_branch": [ "0x0200000000000000000000000000000000000000000000000000000000000000", "0x10c726fac935bf9657cc7476d3cfa7bedec5983dcfb59e8a7df6d0a619e108d7", "0x98e9116c6bb7f20de18800dc63e73e689d06d6a47d35b5e2b32cf093d475840d", - "0x5572348e13ce59446ca0ea7cfeed07579da05f121920a76559e19bda94dd81cd", - "0x2d58adca9f3c742530de037f1933d6de1920ea4b68581613d4bc32b71547f221", - "0x7072b3c6577cd5a89b3234968f316f54630bb97eafbdb59e5b61637a9640255f" + "0x90c9bf4594fa3df03a7492beea4901df5701371e59fa475e670b7d0ffc3efd18", + "0x2889eeff56882ba62ded394b013ce7e8f91fb421490e8d72b8bdfa709f6dee16", + "0xeeb6862f1c0f1d2c2044d8a81402025331d1c87fd74beb2ae75b7a6157adaedc" ], - "block_roots_root": "0x715b08694bef183a6d94b3113d16a7129f89fc3edec85a7e0eaf6ef9153552ef", + "block_roots_root": "0x5d51b82acb0723f82aa9a26135c6416b722f35de9f25a2d8353f15dd31b7ce42", "block_roots_branch": [ - "0x4028c72c71b6ce80ea7d18b2c9471f4e4fa39746261a9921e832a4a2f9bdf7bb", - "0x75f98062661785d3290b7bd998b64446582baa49210733fd4603e1a97cd45a44", - "0x6fb757f44052f30c464810f01b0132adfa1a5446d8715b41e9af88eee1ee3e65", + "0xec42bbdf7abaf34e7279722abbd117dbe778e04131d6a7948c358023ac58f802", + "0x00a1edb40170a804bfbca2b849e6b0792b2f2238f5a9eeefa31549774644bbae", + "0xe2f9426422c48479e95156519d910e3abbe669b15e81ee68b9d67beadfcbbc7e", "0x5340ad5877c72dca689ca04bc8fedb78d67a4801d99887937edd8ccd29f87e82", - "0xf2b3cb56753939a728ccad399a434ca490f018f2f331529ec0d8b2d59c509271" + "0x235b0961213d02e78a9fc07cc5f63530f7b00ed18c6890d32bb8ba7c0becb160" ], - "execution_header": null, - "execution_branch": null + "execution_header": { + "Deneb": { + "parent_hash": "0x45a7ebb5280cbc140b6a1c8b834dea2cffd67ec763eaefc0352aae3a4d730608", + "fee_recipient": "0x0000000000000000000000000000000000000000", + "state_root": "0x4af04a75faa4b87ae218ffe959acda66227b2ef6d8816ea18e7729f93aeb5976", + "receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "prev_randao": "0xfb2d4f65540fceef0cea5fc6213dddec29b1c7cdad4183ad20cc97d91a2ede9b", + "block_number": 64, + "gas_limit": 75150842, + "gas_used": 0, + "timestamp": 1718199583, + "extra_data": "0xd983010e03846765746888676f312e32322e338664617277696e", + "base_fee_per_gas": 203491, + "block_hash": "0x56db9ccb1521a3234366d83aa672f5a30c37d2105031d913dbb03d286536572e", + "transactions_root": "0x7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1", + "withdrawals_root": "0x792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535", + "blob_gas_used": 0, + "excess_blob_gas": 0 + } + }, + "execution_branch": [ + "0x0af737aaf89b87d2b5dc6f1e018d8d0e4a56d875579cbdaada559b13fdb523cf", + "0xb46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb", + "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0x723d3769a1e23e40d9885ae54882d6776cd84b5c44fee1637876a8a7108ad80b" + ] } \ No newline at end of file diff --git a/bridges/snowbridge/pallets/gas-price/Cargo.toml b/bridges/snowbridge/pallets/gas-price/Cargo.toml new file mode 100644 index 000000000000..8767b1bf7ce0 --- /dev/null +++ b/bridges/snowbridge/pallets/gas-price/Cargo.toml @@ -0,0 +1,59 @@ +[package] +name = "snowbridge-pallet-gas-price" +description = "Snowbridge Gas Price Pallet" +version = "0.1.0" +authors = ["Snowfork "] +edition.workspace = true +repository.workspace = true +license = "Apache-2.0" +categories = ["cryptography::cryptocurrencies"] + +[lints] +workspace = true + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +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"] } +log = { workspace = true } + +frame-benchmarking = { path = "../../../../substrate/frame/benchmarking", default-features = false, optional = true } +frame-support = { path = "../../../../substrate/frame/support", default-features = false } +frame-system = { path = "../../../../substrate/frame/system", default-features = false } +sp-core = { path = "../../../../substrate/primitives/core", default-features = false } +sp-std = { path = "../../../../substrate/primitives/std", default-features = false } +sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false } +sp-io = { path = "../../../../substrate/primitives/io", default-features = false, optional = true } +sp-arithmetic = { path = "../../../../substrate/primitives/arithmetic", default-features = false } +snowbridge-core = { path = "../../primitives/core", default-features = false } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-support/std", + "frame-system/std", + "log/std", + "scale-info/std", + "snowbridge-core/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + 'frame-benchmarking/std', +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "snowbridge-core/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/bridges/snowbridge/pallets/gas-price/README.md b/bridges/snowbridge/pallets/gas-price/README.md new file mode 100644 index 000000000000..aef248a3caf5 --- /dev/null +++ b/bridges/snowbridge/pallets/gas-price/README.md @@ -0,0 +1,3 @@ +# Gas Price + +Pallet to hold and provide Ethereum gas price. diff --git a/bridges/snowbridge/pallets/gas-price/src/ema.rs b/bridges/snowbridge/pallets/gas-price/src/ema.rs new file mode 100644 index 000000000000..8ea116e6d2ea --- /dev/null +++ b/bridges/snowbridge/pallets/gas-price/src/ema.rs @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork +//! Exponential Moving Average +use sp_arithmetic::traits::One; +use sp_runtime::{FixedU128, Saturating}; + +/// Perform one iteration of the EMA filter defined by: +/// ```text +/// ema_1 = weighting_factor * value + ema_0 * (1 - weighting_factor) +/// ``` +pub fn step(weighting_factor: FixedU128, ema: FixedU128, value: FixedU128) -> FixedU128 { + weighting_factor + .saturating_mul(value) + .saturating_add(ema.saturating_mul(FixedU128::one().saturating_sub(weighting_factor))) +} + +#[cfg(test)] +mod test { + use super::*; + use snowbridge_core::GWEI; + use sp_arithmetic::traits::{One, Zero}; + + #[test] + pub fn ema_step() { + let weighting_factor = FixedU128::from_rational(2, 10); + let ema0 = FixedU128::from_inner(60 * GWEI); + let value = FixedU128::from_inner(90 * GWEI); + assert_eq!(step(weighting_factor, ema0, value).into_inner(), 66 * GWEI); + } + + #[test] + pub fn ema_step_with_weighting_factor_at_bounds() { + let weighting_factor = FixedU128::zero(); + let ema0 = FixedU128::from_inner(60 * GWEI); + let value = FixedU128::from_inner(90 * GWEI); + assert_eq!(step(weighting_factor, ema0, value).into_inner(), 60 * GWEI); + + let weighting_factor = FixedU128::one(); + let ema0 = FixedU128::from_inner(60 * GWEI); + let value = FixedU128::from_inner(90 * GWEI); + assert_eq!(step(weighting_factor, ema0, value).into_inner(), 90 * GWEI); + } +} diff --git a/bridges/snowbridge/pallets/gas-price/src/lib.rs b/bridges/snowbridge/pallets/gas-price/src/lib.rs new file mode 100644 index 000000000000..4ab87c000c9f --- /dev/null +++ b/bridges/snowbridge/pallets/gas-price/src/lib.rs @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork +#![cfg_attr(not(feature = "std"), no_std)] + +mod ema; +#[cfg(test)] +pub mod mock; +#[cfg(test)] +mod test; + +pub use pallet::*; +use snowbridge_core::{GasPriceEstimator, GWEI}; +use sp_arithmetic::traits::One; +use sp_core::Get; +use sp_runtime::{FixedU128, Saturating}; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + /// The weighting factor used to compute the EMA of the EIP-1559 `BaseFeePerGas` variable. + #[pallet::constant] + type WeightingFactor: Get; + + /// The multiplier used to compute an estimate of the EIP-1559 `MaxFeePerGas` variable + #[pallet::constant] + type BaseFeeMultiplier: Get; + } + + #[pallet::event] + #[pallet::generate_deposit(pub (super) fn deposit_event)] + pub enum Event { + /// The average base fee has been updated + Updated { average_base_fee: u128 }, + } + + #[pallet::error] + pub enum Error {} + + #[pallet::type_value] + pub fn InitialBaseFee() -> u128 { + 20.saturating_mul(GWEI) + } + + #[pallet::storage] + pub(super) type AverageBaseFee = StorageValue<_, u128, ValueQuery, InitialBaseFee>; + + #[pallet::hooks] + impl Hooks> for Pallet { + fn integrity_test() { + assert!(T::WeightingFactor::get() <= FixedU128::one()); + assert!(T::BaseFeeMultiplier::get() >= FixedU128::one()); + } + } + + impl Pallet { + /// Estimate the EIP-1559 `MaxFeePerGas` variable + fn estimate_max_fee() -> u128 { + let average_base_fee = FixedU128::from_inner(AverageBaseFee::::get()); + T::BaseFeeMultiplier::get().saturating_mul(average_base_fee).into_inner() + } + + /// Update the EMA of the EIP-1559 `BaseFeePerGas` variable + fn do_update(base_fee: u128) { + let average_base_fee = ema::step( + T::WeightingFactor::get(), + FixedU128::from_inner(AverageBaseFee::::get()), + FixedU128::from_inner(base_fee), + ) + .into_inner(); + + AverageBaseFee::::put(average_base_fee); + + Self::deposit_event(Event::Updated { average_base_fee }); + } + } + + impl GasPriceEstimator for Pallet { + fn update(base_fee_per_gas: u128) { + Self::do_update(base_fee_per_gas) + } + + fn max_fee() -> u128 { + Self::estimate_max_fee() + } + + fn base_fee() -> u128 { + AverageBaseFee::::get() + } + } +} diff --git a/bridges/snowbridge/pallets/gas-price/src/mock.rs b/bridges/snowbridge/pallets/gas-price/src/mock.rs new file mode 100644 index 000000000000..6aa2aa5bf936 --- /dev/null +++ b/bridges/snowbridge/pallets/gas-price/src/mock.rs @@ -0,0 +1,36 @@ +use frame_support::{derive_impl, parameter_types}; +use frame_system as system; +use sp_runtime::{BuildStorage, FixedU128}; + +type Block = frame_system::mocking::MockBlock; + +// Configure a mock runtime to test the pallet. +frame_support::construct_runtime!( + pub enum Test + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + GasPrice: crate::{Pallet, Storage, Event}, + } +); + +parameter_types! { + pub const SS58Prefix: u8 = 42; + pub const WeightingFactor: FixedU128 = FixedU128::from_rational(2, 10); + pub const BaseFeeMultiplier: FixedU128 = FixedU128::from_rational(4, 3); +} + +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] +impl system::Config for Test { + type Block = Block; +} + +impl crate::Config for Test { + type RuntimeEvent = RuntimeEvent; + type WeightingFactor = WeightingFactor; + type BaseFeeMultiplier = BaseFeeMultiplier; +} + +// Build genesis storage according to the mock runtime. +pub fn new_test_ext() -> sp_io::TestExternalities { + system::GenesisConfig::::default().build_storage().unwrap().into() +} diff --git a/bridges/snowbridge/pallets/gas-price/src/test.rs b/bridges/snowbridge/pallets/gas-price/src/test.rs new file mode 100644 index 000000000000..624f99c6f83e --- /dev/null +++ b/bridges/snowbridge/pallets/gas-price/src/test.rs @@ -0,0 +1,23 @@ +use super::*; +use crate::mock::*; + +#[test] +fn estimate_max_fee() { + new_test_ext().execute_with(|| { + AverageBaseFee::::put(60 * GWEI); + assert_eq!(GasPrice::max_fee(), 79999999999); + }); +} + +#[test] +fn update_base_fee() { + new_test_ext().execute_with(|| { + AverageBaseFee::::put(60 * GWEI); + + GasPrice::update(90 * GWEI); + assert_eq!(GasPrice::base_fee(), 66000000000); + + GasPrice::update(90 * GWEI); + assert_eq!(GasPrice::base_fee(), 70800000000); + }); +} diff --git a/bridges/snowbridge/pallets/inbound-queue/Cargo.toml b/bridges/snowbridge/pallets/inbound-queue/Cargo.toml index d63398770f20..5a7e2a85e8bd 100644 --- a/bridges/snowbridge/pallets/inbound-queue/Cargo.toml +++ b/bridges/snowbridge/pallets/inbound-queue/Cargo.toml @@ -39,6 +39,7 @@ snowbridge-core = { path = "../../primitives/core", default-features = false } snowbridge-router-primitives = { path = "../../primitives/router", default-features = false } snowbridge-beacon-primitives = { path = "../../primitives/beacon", default-features = false } snowbridge-pallet-inbound-queue-fixtures = { path = "fixtures", default-features = false, optional = true } +snowbridge-pallet-gas-price = { path = "../gas-price", default-features = false } [dev-dependencies] frame-benchmarking = { path = "../../../../substrate/frame/benchmarking" } @@ -46,6 +47,7 @@ sp-keyring = { path = "../../../../substrate/primitives/keyring" } snowbridge-pallet-ethereum-client = { path = "../ethereum-client" } hex-literal = { version = "0.4.1" } + [features] default = ["std"] std = [ @@ -61,6 +63,7 @@ std = [ "serde", "snowbridge-beacon-primitives/std", "snowbridge-core/std", + "snowbridge-pallet-gas-price/std", "snowbridge-pallet-inbound-queue-fixtures?/std", "snowbridge-router-primitives/std", "sp-core/std", @@ -79,6 +82,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "snowbridge-pallet-ethereum-client/runtime-benchmarks", + "snowbridge-pallet-gas-price/runtime-benchmarks", "snowbridge-pallet-inbound-queue-fixtures/runtime-benchmarks", "snowbridge-router-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -89,5 +93,6 @@ try-runtime = [ "frame-system/try-runtime", "pallet-balances/try-runtime", "snowbridge-pallet-ethereum-client/try-runtime", + "snowbridge-pallet-gas-price/try-runtime", "sp-runtime/try-runtime", ] diff --git a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs index 05481ca2f6b4..c8e79ee3ae89 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs @@ -12,7 +12,6 @@ use snowbridge_beacon_primitives::{ types::deneb, BeaconHeader, ExecutionProof, Fork, ForkVersions, VersionedExecutionPayloadHeader, }; use snowbridge_core::{ - gwei, inbound::{Log, Proof, VerificationError}, meth, Channel, ChannelId, PricingParameters, Rewards, StaticLookup, }; @@ -110,6 +109,7 @@ parameter_types! { impl snowbridge_pallet_ethereum_client::Config for Test { type RuntimeEvent = RuntimeEvent; type ForkVersions = ChainForkVersions; + type GasPrice = (); type WeightInfo = (); } @@ -127,7 +127,7 @@ const GATEWAY_ADDRESS: [u8; 20] = hex!["eda338e4dc46038493b885327842fd3e301cab39 parameter_types! { pub const EthereumNetwork: xcm::v3::NetworkId = xcm::v3::NetworkId::Ethereum { chain_id: 11155111 }; pub const GatewayAddress: H160 = H160(GATEWAY_ADDRESS); - pub const CreateAssetCall: [u8;2] = [53, 0]; + pub const CreateAssetCall: [u8; 2] = [53, 0]; pub const CreateAssetExecutionFee: u128 = 2_000_000_000; pub const CreateAssetDeposit: u128 = 100_000_000_000; pub const SendTokenExecutionFee: u128 = 1_000_000_000; @@ -171,7 +171,6 @@ parameter_types! { pub const OwnParaId: ParaId = ParaId::new(1013); pub Parameters: PricingParameters = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), - fee_per_gas: gwei(20), rewards: Rewards { local: DOT, remote: meth(1) }, multiplier: FixedU128::from_rational(1, 1), }; diff --git a/bridges/snowbridge/pallets/outbound-queue/Cargo.toml b/bridges/snowbridge/pallets/outbound-queue/Cargo.toml index 15c6c3a5b32b..3911a6afbbb1 100644 --- a/bridges/snowbridge/pallets/outbound-queue/Cargo.toml +++ b/bridges/snowbridge/pallets/outbound-queue/Cargo.toml @@ -33,6 +33,7 @@ bridge-hub-common = { path = "../../../../cumulus/parachains/runtimes/bridge-hub snowbridge-core = { path = "../../primitives/core", default-features = false, features = ["serde"] } snowbridge-outbound-queue-merkle-tree = { path = "merkle-tree", default-features = false } ethabi = { package = "ethabi-decode", version = "1.0.0", default-features = false } +snowbridge-pallet-gas-price = { path = "../gas-price", default-features = false } [dev-dependencies] pallet-message-queue = { path = "../../../../substrate/frame/message-queue", default-features = false } @@ -52,6 +53,7 @@ std = [ "serde/std", "snowbridge-core/std", "snowbridge-outbound-queue-merkle-tree/std", + "snowbridge-pallet-gas-price/std", "sp-arithmetic/std", "sp-core/std", "sp-io/std", @@ -66,11 +68,13 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", + "snowbridge-pallet-gas-price/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-message-queue/try-runtime", + "snowbridge-pallet-gas-price/try-runtime", "sp-runtime/try-runtime", ] diff --git a/bridges/snowbridge/pallets/outbound-queue/src/lib.rs b/bridges/snowbridge/pallets/outbound-queue/src/lib.rs index 0037f537c480..4eed41aa6be0 100644 --- a/bridges/snowbridge/pallets/outbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/outbound-queue/src/lib.rs @@ -112,7 +112,7 @@ use frame_support::{ }; use snowbridge_core::{ outbound::{Fee, GasMeter, QueuedMessage, VersionedQueuedMessage, ETHER_DECIMALS}, - BasicOperatingMode, ChannelId, + BasicOperatingMode, ChannelId, PricingParameters, }; use snowbridge_outbound_queue_merkle_tree::merkle_root; pub use snowbridge_outbound_queue_merkle_tree::MerkleProof; @@ -132,7 +132,7 @@ pub mod pallet { use super::*; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - use snowbridge_core::PricingParameters; + use snowbridge_core::GasPriceEstimator; use sp_arithmetic::FixedU128; #[pallet::pallet] @@ -171,6 +171,9 @@ pub mod pallet { /// Convert a weight value into a deductible fee based. type WeightToFee: WeightToFee; + /// Provider for the latest base fee per gas from Ethereum. + type GasPrice: GasPriceEstimator; + /// Weight information for extrinsics in this pallet type WeightInfo: WeightInfo; } @@ -347,10 +350,7 @@ pub mod pallet { command, params, max_dispatch_gas, - max_fee_per_gas: pricing_params - .fee_per_gas - .try_into() - .defensive_unwrap_or(u128::MAX), + max_fee_per_gas: T::GasPrice::max_fee(), reward: reward.try_into().defensive_unwrap_or(u128::MAX), id: queued_message.id, }; @@ -380,7 +380,7 @@ pub mod pallet { // Remote fee in ether let fee = Self::calculate_remote_fee( gas_used_at_most, - params.fee_per_gas, + T::GasPrice::max_fee().into(), params.rewards.remote, ); diff --git a/bridges/snowbridge/pallets/outbound-queue/src/mock.rs b/bridges/snowbridge/pallets/outbound-queue/src/mock.rs index d65a96e2702d..c4951aa61f66 100644 --- a/bridges/snowbridge/pallets/outbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/outbound-queue/src/mock.rs @@ -9,7 +9,7 @@ use frame_support::{ }; use snowbridge_core::{ - gwei, meth, + meth, outbound::*, pricing::{PricingParameters, Rewards}, ParaId, PRIMARY_GOVERNANCE_CHANNEL, @@ -30,6 +30,7 @@ frame_support::construct_runtime!( System: frame_system::{Pallet, Call, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, OutboundQueue: crate::{Pallet, Storage, Event}, + GasPrice: snowbridge_pallet_gas_price::{Pallet, Storage, Event}, } ); @@ -72,7 +73,6 @@ parameter_types! { pub const OwnParaId: ParaId = ParaId::new(1013); pub Parameters: PricingParameters = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), - fee_per_gas: gwei(20), rewards: Rewards { local: DOT, remote: meth(1) }, multiplier: FixedU128::from_rational(4, 3), }; @@ -93,6 +93,19 @@ impl crate::Config for Test { type Channels = Everything; type WeightToFee = IdentityFee; type WeightInfo = (); + type GasPrice = GasPrice; +} + +parameter_types! { + pub const SS58Prefix: u8 = 42; + pub const WeightingFactor: FixedU128 = FixedU128::from_rational(2, 10); + pub const BaseFeeMultiplier: FixedU128 = FixedU128::from_rational(4, 3); +} + +impl snowbridge_pallet_gas_price::Config for Test { + type RuntimeEvent = RuntimeEvent; + type WeightingFactor = WeightingFactor; + type BaseFeeMultiplier = BaseFeeMultiplier; } fn setup() { diff --git a/bridges/snowbridge/pallets/outbound-queue/src/test.rs b/bridges/snowbridge/pallets/outbound-queue/src/test.rs index 4e9ea36e24bc..f83908e0a06a 100644 --- a/bridges/snowbridge/pallets/outbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/outbound-queue/src/test.rs @@ -273,13 +273,12 @@ fn test_calculate_fees_with_unit_multiplier() { let gas_used: u64 = 250000; let price_params: PricingParameters<::Balance> = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), - fee_per_gas: 10000_u32.into(), rewards: Rewards { local: 1_u32.into(), remote: 1_u32.into() }, multiplier: FixedU128::from_rational(1, 1), }; let fee = OutboundQueue::calculate_fee(gas_used, price_params); assert_eq!(fee.local, 698000000); - assert_eq!(fee.remote, 1000000); + assert_eq!(fee.remote, 2666666666600); }); } @@ -289,30 +288,11 @@ fn test_calculate_fees_with_multiplier() { let gas_used: u64 = 250000; let price_params: PricingParameters<::Balance> = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), - fee_per_gas: 10000_u32.into(), rewards: Rewards { local: 1_u32.into(), remote: 1_u32.into() }, multiplier: FixedU128::from_rational(4, 3), }; let fee = OutboundQueue::calculate_fee(gas_used, price_params); assert_eq!(fee.local, 698000000); - assert_eq!(fee.remote, 1333333); - }); -} - -#[test] -fn test_calculate_fees_with_valid_exchange_rate_but_remote_fee_calculated_as_zero() { - new_tester().execute_with(|| { - let gas_used: u64 = 250000; - let price_params: PricingParameters<::Balance> = PricingParameters { - exchange_rate: FixedU128::from_rational(1, 1), - fee_per_gas: 1_u32.into(), - rewards: Rewards { local: 1_u32.into(), remote: 1_u32.into() }, - multiplier: FixedU128::from_rational(1, 1), - }; - let fee = OutboundQueue::calculate_fee(gas_used, price_params.clone()); - assert_eq!(fee.local, 698000000); - // Though none zero pricing params the remote fee calculated here is invalid - // which should be avoided - assert_eq!(fee.remote, 0); + assert_eq!(fee.remote, 3555555555466); }); } diff --git a/bridges/snowbridge/pallets/system/src/mock.rs b/bridges/snowbridge/pallets/system/src/mock.rs index d7fc4152b371..4fbd6e92b9f7 100644 --- a/bridges/snowbridge/pallets/system/src/mock.rs +++ b/bridges/snowbridge/pallets/system/src/mock.rs @@ -11,7 +11,7 @@ use sp_core::H256; use xcm_executor::traits::ConvertLocation; use snowbridge_core::{ - gwei, meth, outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, AllowSiblingsOnly, + meth, outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, AllowSiblingsOnly, ParaId, PricingParameters, Rewards, }; use sp_runtime::{ @@ -91,7 +91,7 @@ frame_support::construct_runtime!( XcmOrigin: pallet_xcm_origin::{Pallet, Origin}, OutboundQueue: snowbridge_pallet_outbound_queue::{Pallet, Call, Storage, Event}, EthereumSystem: snowbridge_system, - MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event} + MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, } ); @@ -168,6 +168,7 @@ impl snowbridge_pallet_outbound_queue::Config for Test { type Balance = u128; type PricingParameters = EthereumSystem; type Channels = EthereumSystem; + type GasPrice = (); type WeightToFee = IdentityFee; type WeightInfo = (); } @@ -192,7 +193,6 @@ parameter_types! { pub TestParaId: u32 = 2000; pub Parameters: PricingParameters = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), - fee_per_gas: gwei(20), rewards: Rewards { local: DOT, remote: meth(1) }, multiplier: FixedU128::from_rational(4, 3) }; diff --git a/bridges/snowbridge/pallets/system/src/tests.rs b/bridges/snowbridge/pallets/system/src/tests.rs index 09f24195a30a..5308926f8980 100644 --- a/bridges/snowbridge/pallets/system/src/tests.rs +++ b/bridges/snowbridge/pallets/system/src/tests.rs @@ -186,11 +186,7 @@ fn set_pricing_parameters_invalid() { Error::::InvalidPricingParameters ); params = Parameters::get(); - params.fee_per_gas = sp_core::U256::zero(); - assert_noop!( - EthereumSystem::set_pricing_parameters(origin.clone(), params), - Error::::InvalidPricingParameters - ); + assert_ok!(EthereumSystem::set_pricing_parameters(origin.clone(), params)); params = Parameters::get(); params.rewards.local = 0; assert_noop!( diff --git a/bridges/snowbridge/primitives/beacon/src/types.rs b/bridges/snowbridge/primitives/beacon/src/types.rs index 9a699a1755cc..92d73df65c1b 100644 --- a/bridges/snowbridge/primitives/beacon/src/types.rs +++ b/bridges/snowbridge/primitives/beacon/src/types.rs @@ -408,6 +408,21 @@ impl VersionedExecutionPayloadHeader { execution_payload_header.receipts_root, } } + + pub fn base_fee_per_gas(&self) -> U256 { + match self { + VersionedExecutionPayloadHeader::Capella(execution_payload_header) => + execution_payload_header.base_fee_per_gas, + VersionedExecutionPayloadHeader::Deneb(execution_payload_header) => + execution_payload_header.base_fee_per_gas, + } + } +} + +impl Default for VersionedExecutionPayloadHeader { + fn default() -> Self { + VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader::default()) + } } #[derive(Encode, Decode, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo)] diff --git a/bridges/snowbridge/primitives/beacon/src/updates.rs b/bridges/snowbridge/primitives/beacon/src/updates.rs index ca651b5806f2..5941cf3602bb 100644 --- a/bridges/snowbridge/primitives/beacon/src/updates.rs +++ b/bridges/snowbridge/primitives/beacon/src/updates.rs @@ -6,7 +6,7 @@ use scale_info::TypeInfo; use sp_core::H256; use sp_std::prelude::*; -use crate::types::{BeaconHeader, SyncAggregate, SyncCommittee}; +use crate::types::{BeaconHeader, SyncAggregate, SyncCommittee, VersionedExecutionPayloadHeader}; #[derive(Encode, Decode, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo)] #[cfg_attr( @@ -51,6 +51,10 @@ pub struct Update pub block_roots_root: H256, /// The merkle path to prove the `block_roots_root` value. pub block_roots_branch: Vec, + /// The execution header to be imported + pub execution_header: VersionedExecutionPayloadHeader, + /// The merkle proof for the execution_header + pub execution_branch: Vec, } #[derive( diff --git a/bridges/snowbridge/primitives/core/src/inbound.rs b/bridges/snowbridge/primitives/core/src/inbound.rs index 9e8ed789ab50..cd6e8f6aa246 100644 --- a/bridges/snowbridge/primitives/core/src/inbound.rs +++ b/bridges/snowbridge/primitives/core/src/inbound.rs @@ -59,7 +59,7 @@ pub struct Log { impl Log { pub fn validate(&self) -> Result<(), LogValidationError> { if self.topics.len() > MAX_TOPICS { - return Err(LogValidationError::TooManyTopics) + return Err(LogValidationError::TooManyTopics); } Ok(()) } diff --git a/bridges/snowbridge/primitives/core/src/lib.rs b/bridges/snowbridge/primitives/core/src/lib.rs index ed1af4225d24..be87af3e8b0a 100644 --- a/bridges/snowbridge/primitives/core/src/lib.rs +++ b/bridges/snowbridge/primitives/core/src/lib.rs @@ -51,8 +51,10 @@ impl Contains for AllowSiblingsOnly { } } +pub const GWEI: u128 = 1_000_000_000u128; + pub fn gwei(x: u128) -> U256 { - U256::from(1_000_000_000u128).saturating_mul(x.into()) + U256::from(GWEI).saturating_mul(x.into()) } pub fn meth(x: u128) -> U256 { @@ -164,3 +166,26 @@ impl DescribeLocation for DescribeHere { /// Creates an AgentId from a Location. An AgentId is a unique mapping to a Agent contract on /// Ethereum which acts as the sovereign account for the Location. pub type AgentIdOf = HashedDescription)>; + +/// A trait for retrieving the base fee per gas. +pub trait GasPriceEstimator { + /// Estimate the EIP-1559 maximum fee + fn max_fee() -> u128; + /// Estimate the EIP-1559 base fee + fn base_fee() -> u128; + /// Improve the estimated fees by adding EIP-1559 `BaseFeePerGas` values. + fn update(base_fee_per_gas: u128); +} + +#[cfg(feature = "std")] +impl GasPriceEstimator for () { + fn max_fee() -> u128 { + 0 + } + + fn base_fee() -> u128 { + 0 + } + + fn update(_: u128) {} +} diff --git a/bridges/snowbridge/primitives/core/src/pricing.rs b/bridges/snowbridge/primitives/core/src/pricing.rs index 0f392c7ad4bd..532dbc7252ea 100644 --- a/bridges/snowbridge/primitives/core/src/pricing.rs +++ b/bridges/snowbridge/primitives/core/src/pricing.rs @@ -11,8 +11,6 @@ pub struct PricingParameters { pub exchange_rate: FixedU128, /// Relayer rewards pub rewards: Rewards, - /// Ether (wei) fee per gas unit - pub fee_per_gas: U256, /// Fee multiplier pub multiplier: FixedU128, } @@ -36,9 +34,6 @@ where if self.exchange_rate == FixedU128::zero() { return Err(InvalidPricingParameters) } - if self.fee_per_gas == U256::zero() { - return Err(InvalidPricingParameters) - } if self.rewards.local.is_zero() { return Err(InvalidPricingParameters) } diff --git a/bridges/snowbridge/templates/beacon-fixtures.mustache b/bridges/snowbridge/templates/beacon-fixtures.mustache index 5942be056321..3d7cf475cb2a 100644 --- a/bridges/snowbridge/templates/beacon-fixtures.mustache +++ b/bridges/snowbridge/templates/beacon-fixtures.mustache @@ -98,6 +98,30 @@ pub fn make_sync_committee_update() -> Box { hex!("{{.}}").into(), {{/SyncCommitteeUpdate.BlockRootsBranch}} ], + execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { + parent_hash: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.ParentHash}}").into(), + fee_recipient: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.FeeRecipient}}").into(), + state_root: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.StateRoot}}").into(), + receipts_root: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.ReceiptsRoot}}").into(), + logs_bloom: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.LogsBloom}}").into(), + prev_randao: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.PrevRandao}}").into(), + block_number: {{SyncCommitteeUpdate.ExecutionHeader.Deneb.BlockNumber}}, + gas_limit: {{SyncCommitteeUpdate.ExecutionHeader.Deneb.GasLimit}}, + gas_used: {{SyncCommitteeUpdate.ExecutionHeader.Deneb.GasUsed}}, + timestamp: {{SyncCommitteeUpdate.ExecutionHeader.Deneb.Timestamp}}, + extra_data: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.ExtraData}}").into(), + base_fee_per_gas: U256::from({{SyncCommitteeUpdate.ExecutionHeader.Deneb.BaseFeePerGas}}u64), + block_hash: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.BlockHash}}").into(), + transactions_root: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.TransactionsRoot}}").into(), + withdrawals_root: hex!("{{SyncCommitteeUpdate.ExecutionHeader.Deneb.WithdrawalsRoot}}").into(), + blob_gas_used: {{SyncCommitteeUpdate.ExecutionHeader.Deneb.BlobGasUsed}}, + excess_blob_gas: {{SyncCommitteeUpdate.ExecutionHeader.Deneb.ExcessBlobGas}}, + }), + execution_branch: vec![ + {{#SyncCommitteeUpdate.ExecutionBranch}} + hex!("{{.}}").into(), + {{/SyncCommitteeUpdate.ExecutionBranch}} + ], }) } @@ -133,7 +157,31 @@ pub fn make_finalized_header_update() -> Box { {{#FinalizedHeaderUpdate.BlockRootsBranch}} hex!("{{.}}").into(), {{/FinalizedHeaderUpdate.BlockRootsBranch}} - ] + ], + execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { + parent_hash: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.ParentHash}}").into(), + fee_recipient: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.FeeRecipient}}").into(), + state_root: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.StateRoot}}").into(), + receipts_root: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.ReceiptsRoot}}").into(), + logs_bloom: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.LogsBloom}}").into(), + prev_randao: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.PrevRandao}}").into(), + block_number: {{FinalizedHeaderUpdate.ExecutionHeader.Deneb.BlockNumber}}, + gas_limit: {{FinalizedHeaderUpdate.ExecutionHeader.Deneb.GasLimit}}, + gas_used: {{FinalizedHeaderUpdate.ExecutionHeader.Deneb.GasUsed}}, + timestamp: {{FinalizedHeaderUpdate.ExecutionHeader.Deneb.Timestamp}}, + extra_data: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.ExtraData}}").into(), + base_fee_per_gas: U256::from({{FinalizedHeaderUpdate.ExecutionHeader.Deneb.BaseFeePerGas}}u64), + block_hash: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.BlockHash}}").into(), + transactions_root: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.TransactionsRoot}}").into(), + withdrawals_root: hex!("{{FinalizedHeaderUpdate.ExecutionHeader.Deneb.WithdrawalsRoot}}").into(), + blob_gas_used: {{FinalizedHeaderUpdate.ExecutionHeader.Deneb.BlobGasUsed}}, + excess_blob_gas: {{FinalizedHeaderUpdate.ExecutionHeader.Deneb.ExcessBlobGas}}, + }), + execution_branch: vec![ + {{#FinalizedHeaderUpdate.ExecutionBranch}} + hex!("{{.}}").into(), + {{/FinalizedHeaderUpdate.ExecutionBranch}} + ], }) } @@ -199,8 +247,6 @@ pub fn make_inbound_fixture() -> InboundQueueFixture { data: hex!("{{InboundMessage.EventLog.Data}}").into(), }, proof: Proof { - block_hash: hex!("{{InboundMessage.Proof.BlockHash}}").into(), - tx_index: {{InboundMessage.Proof.TxIndex}}, receipt_proof: (vec![ {{#InboundMessage.Proof.ReceiptProof.Keys}} hex!("{{.}}").to_vec(), diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 8856fe8eca51..4154c4502ed1 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -501,7 +501,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() { events.iter().any(|event| matches!( event, RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount }) - if *who == assethub_sovereign && *amount == 2680000000000, + if *who == assethub_sovereign && *amount == 3439999999924, )), "AssetHub sovereign takes remote fee." ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 664d2b9c9dd5..1813552e891d 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -639,7 +639,7 @@ pub mod bridging { /// (initially was calculated by test `OutboundQueue::calculate_fees` - ETH/ROC 1/400 and fee_per_gas 20 GWEI = 2200698000000 + *25%) /// Needs to be more than fee calculated from DefaultFeeConfig FeeConfigRecord in snowbridge:parachain/pallets/outbound-queue/src/lib.rs /// Polkadot uses 10 decimals, Kusama and Rococo 12 decimals. - pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000; + pub const DefaultBridgeHubEthereumBaseFee: Balance = 5_000_000_000_000; pub storage BridgeHubEthereumBaseFee: Balance = DefaultBridgeHubEthereumBaseFee::get(); pub SiblingBridgeHubWithEthereumInboundQueueInstance: Location = Location::new( 1, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 436f3ca0228e..9c4b1b9a8477 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -113,6 +113,7 @@ snowbridge-pallet-system = { path = "../../../../../bridges/snowbridge/pallets/s snowbridge-system-runtime-api = { path = "../../../../../bridges/snowbridge/pallets/system/runtime-api", default-features = false } snowbridge-core = { path = "../../../../../bridges/snowbridge/primitives/core", default-features = false } snowbridge-pallet-ethereum-client = { path = "../../../../../bridges/snowbridge/pallets/ethereum-client", default-features = false } +snowbridge-pallet-gas-price = { path = "../../../../../bridges/snowbridge/pallets/gas-price", default-features = false } snowbridge-pallet-inbound-queue = { path = "../../../../../bridges/snowbridge/pallets/inbound-queue", default-features = false } snowbridge-pallet-outbound-queue = { path = "../../../../../bridges/snowbridge/pallets/outbound-queue", default-features = false } snowbridge-outbound-queue-runtime-api = { path = "../../../../../bridges/snowbridge/pallets/outbound-queue/runtime-api", default-features = false } @@ -197,6 +198,7 @@ std = [ "snowbridge-core/std", "snowbridge-outbound-queue-runtime-api/std", "snowbridge-pallet-ethereum-client/std", + "snowbridge-pallet-gas-price/std", "snowbridge-pallet-inbound-queue/std", "snowbridge-pallet-outbound-queue/std", "snowbridge-pallet-system/std", @@ -256,6 +258,7 @@ runtime-benchmarks = [ "polkadot-runtime-common/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "snowbridge-pallet-ethereum-client/runtime-benchmarks", + "snowbridge-pallet-gas-price/runtime-benchmarks", "snowbridge-pallet-inbound-queue/runtime-benchmarks", "snowbridge-pallet-outbound-queue/runtime-benchmarks", "snowbridge-pallet-system/runtime-benchmarks", @@ -296,6 +299,7 @@ try-runtime = [ "parachain-info/try-runtime", "polkadot-runtime-common/try-runtime", "snowbridge-pallet-ethereum-client/try-runtime", + "snowbridge-pallet-gas-price/try-runtime", "snowbridge-pallet-inbound-queue/try-runtime", "snowbridge-pallet-outbound-queue/try-runtime", "snowbridge-pallet-system/try-runtime", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs index 53a536655408..39ac4c327c75 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs @@ -17,13 +17,13 @@ #[cfg(not(feature = "runtime-benchmarks"))] use crate::XcmRouter; use crate::{ - xcm_config, xcm_config::UniversalLocation, Balances, EthereumInboundQueue, + xcm_config, xcm_config::UniversalLocation, Balances, EthereumGasPrice, EthereumInboundQueue, EthereumOutboundQueue, EthereumSystem, MessageQueue, Runtime, RuntimeEvent, TransactionByteFee, TreasuryAccount, }; use parachains_common::{AccountId, Balance}; use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_core::{gwei, meth, AllowSiblingsOnly, PricingParameters, Rewards}; +use snowbridge_core::{meth, AllowSiblingsOnly, PricingParameters, Rewards}; use snowbridge_router_primitives::{inbound::MessageToXcm, outbound::EthereumBlobExporter}; use sp_core::H160; use testnet_parachains_constants::rococo::{ @@ -59,7 +59,6 @@ parameter_types! { pub const CreateAssetDeposit: u128 = (UNITS / 10) + EXISTENTIAL_DEPOSIT; pub Parameters: PricingParameters = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), - fee_per_gas: gwei(20), rewards: Rewards { local: 1 * UNITS, remote: meth(1) }, multiplier: FixedU128::from_rational(1, 1), }; @@ -105,6 +104,7 @@ impl snowbridge_pallet_outbound_queue::Config for Runtime { type WeightInfo = crate::weights::snowbridge_pallet_outbound_queue::WeightInfo; type PricingParameters = EthereumSystem; type Channels = EthereumSystem; + type GasPrice = EthereumGasPrice; } #[cfg(any(feature = "std", feature = "fast-runtime", feature = "runtime-benchmarks", test))] @@ -162,6 +162,7 @@ parameter_types! { impl snowbridge_pallet_ethereum_client::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ForkVersions = ChainForkVersions; + type GasPrice = EthereumGasPrice; type WeightInfo = crate::weights::snowbridge_pallet_ethereum_client::WeightInfo; } @@ -179,6 +180,17 @@ impl snowbridge_pallet_system::Config for Runtime { type InboundDeliveryCost = EthereumInboundQueue; } +parameter_types! { + pub const WeightingFactor: FixedU128 = FixedU128::from_rational(2, 10); + pub const BaseFeeMultiplier: FixedU128 = FixedU128::from_rational(4, 3); +} + +impl snowbridge_pallet_gas_price::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightingFactor = WeightingFactor; + type BaseFeeMultiplier = BaseFeeMultiplier; +} + #[cfg(feature = "runtime-benchmarks")] pub mod benchmark_helpers { use crate::{EthereumBeaconClient, Runtime, RuntimeOrigin}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index ad3055f026a7..cb4fdc85356d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -587,6 +587,7 @@ construct_runtime!( EthereumOutboundQueue: snowbridge_pallet_outbound_queue = 81, EthereumBeaconClient: snowbridge_pallet_ethereum_client = 82, EthereumSystem: snowbridge_pallet_system = 83, + EthereumGasPrice: snowbridge_pallet_gas_price = 84, // Message Queue. Importantly, is registered last so that messages are processed after // the `on_initialize` hooks of bridging pallets. diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/snowbridge.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/snowbridge.rs index 5960ab7b5505..d312c23755d1 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/snowbridge.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/snowbridge.rs @@ -37,7 +37,7 @@ use sp_runtime::{ }; parameter_types! { - pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000; + pub const DefaultBridgeHubEthereumBaseFee: Balance = 5_000_000_000_000; } fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys {