Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowbridge - Fix benchmarks, add fee multipler and move config to Ethereum module #252

Merged

Conversation

claravanstaden
Copy link
Contributor

The Snowbridge Inbound Queue pallet benchmarks are failing:

2024-03-21 13:50:40 Running  benchmark: snowbridge_pallet_ethereum_client.submit_execution_header(0 args) 1/1 1/1    
Running benchmarks for snowbridge_pallet_inbound_queue to ./bridge-hub-kusama-weights/
2024-03-21 13:50:41 Starting benchmark: snowbridge_pallet_inbound_queue::submit    
2024-03-21 13:50:41 💫 Verifying message with block hash 0x3921…3a3f    
2024-03-21 13:50:41 💫 Receipt verification successful for 0x3921…3a3f    
2024-03-21 13:50:41 panicked at /home/bparity/.cargo/registry/src/index.crates.io-6f17d22bba15001f/snowbridge-pallet-inbound-queue-0.1.0/src/benchmarking/mod.rs:43:13:
Expected Ok(_). Got Err(
    Module(
        ModuleError {
            index: 80,
            error: [
                0,
                0,
                0,
                0,
            ],
            message: Some(
                "InvalidGateway",
            ),
        },
    ),
)    
Error: 
   0: Invalid input: Error executing and verifying runtime benchmark: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
      WASM backtrace:
      error while executing at wasm backtrace:
          0: 0x436fa6 - <unknown>!rust_begin_unwind
          1: 0x2969 - <unknown>!core::panicking::panic_fmt::hbb0c5dd9c7ebab99
          2: 0x329f54 - <unknown>!core::ops::function::FnOnce::call_once{{vtable.shim}}::h0374b352d74ea114
          3: 0x300e24 - <unknown>!<bridge_hub_kusama_runtime::Runtime as frame_benchmarking::utils::runtime_decl_for_benchmark::BenchmarkV1<sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<u32,sp_runtime::traits::BlakeTwo256>,sp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic<sp_runtime::multiaddress::MultiAddress<<<sp_runtime::MultiSignature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId,()>,bridge_hub_kusama_runtime::RuntimeCall,sp_runtime::MultiSignature,(frame_system::extensions::check_non_zero_sender::CheckNonZeroSender<bridge_hub_kusama_runtime::Runtime>,frame_system::extensions::check_spec_version::CheckSpecVersion<bridge_hub_kusama_runtime::Runtime>,frame_system::extensions::check_tx_version::CheckTxVersion<bridge_hub_kusama_runtime::Runtime>,frame_system::extensions::check_genesis::CheckGenesis<bridge_hub_kusama_runtime::Runtime>,frame_system::extensions::check_mortality::CheckMortality<bridge_hub_kusama_runtime::Runtime>,frame_system::extensions::check_nonce::CheckNonce<bridge_hub_kusama_runtime::Runtime>,frame_system::extensions::check_weight::CheckWeight<bridge_hub_kusama_runtime::Runtime>,pallet_transaction_payment::ChargeTransactionPayment<bridge_hub_kusama_runtime::Runtime>,bridge_hub_kusama_runtime::BridgeRejectObsoleteHeadersAndMessages,bridge_runtime_common::refund_relayer_extension::RefundSignedExtensionAdapter<bridge_runtime_common::refund_relayer_extension::RefundBridgedParachainMessages<bridge_hub_kusama_runtime::Runtime,bridge_runtime_common::refund_relayer_extension::RefundableParachain<frame_support::instances::Instance1,bp_bridge_hub_polkadot::BridgeHubPolkadot>,bridge_runtime_common::refund_relayer_extension::RefundableMessagesLane<frame_support::instances::Instance1,bridge_hub_kusama_runtime::bridge_to_polkadot_config::AssetHubKusamaToAssetHubPolkadotMessagesLane>,bridge_runtime_common::refund_relayer_extension::ActualFeeRefund<bridge_hub_kusama_runtime::Runtime>,bridge_hub_kusama_runtime::bridge_to_polkadot_config::PriorityBoostPerMessage,bridge_hub_kusama_runtime::bridge_to_polkadot_config::StrRefundBridgeHubPolkadotMessages>>)>>>>::dispatch_benchmark::h500c8f48422e47bd
          4: 0x3c0b6a - <unknown>!Benchmark_dispatch_benchmark

This PR fixes the error (the Ethereum gateway contract address should be set in the benchmarks since it is verified in the inbound queue when a message is submitted) and moves the benchmark config into bridge_to_ethereum_config.rs.

  • Does not require a CHANGELOG entry

@bkontur bkontur mentioned this pull request Mar 22, 2024
19 tasks
@claravanstaden claravanstaden marked this pull request as ready for review March 22, 2024 14:03
snowbridge-core v0.1.0 -> v0.1.1
snowbridge-outbound-queue-runtime-api v0.1.0 -> v0.1.1
snowbridge-pallet-ethereum-client v0.1.0 -> v0.1.1
snowbridge-pallet-inbound-queue v0.1.0 -> v0.1.1
snowbridge-pallet-outbound-queue v0.1.0 -> v0.1.1
snowbridge-pallet-system v0.1.0 -> v0.1.1
pallet-xcm v8.0.3 -> v8.0.4
@acatangiu
Copy link
Contributor

Snowfork#5 for bringing in latest fixes

claravanstaden and others added 3 commits March 23, 2024 13:37
bump snowfork and pallet-xcm deps
# Conflicts:
#	integration-tests/emulated/tests/assets/asset-hub-kusama/Cargo.toml
@claravanstaden
Copy link
Contributor Author

claravanstaden commented Mar 25, 2024

@bkontur @acatangiu I just need to fix the failing bridge-hub-kusama integration test quick before we merge.

@claravanstaden claravanstaden changed the title Fix Snowbridge benchmarks Snowbridge - Fix benchmarks, add fee multipler and move config to Ethereum module Mar 25, 2024
Copy link
Contributor

@eskimor eskimor left a comment

Choose a reason for hiding this comment

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

Looks good, left a few nits/remarks.

>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type MaxMessageSize = ConstU32<2048>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number? At least some docs/comment about the reasoning would be good.

type Hashing = Keccak256;
type MessageQueue = MessageQueue;
type Decimals = ConstU8<12>;
type MaxMessagePayloadSize = ConstU32<2048>;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this has to be the same as the MaxMessageSize, maybe a constant would be good?

Copy link
Contributor

@vgeddes vgeddes Mar 25, 2024

Choose a reason for hiding this comment

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

Definitely agree that the magic numbers needs to be hoisted into documented constants. Though MaxMessagePayloadSize does have a different purpose to snowbridge_pallet_inbound_queue::MaxMessageSize.

  • inbound_queue::MaxMessageSize: Worst case message size (including proofs), used as a pricing parameter to ultimately determine bridging fees on the Ethereum side of the bridge.
  • outbound_queue::MaxMessagePayloadSize: Maximum allowed size of encoded message payload that is committed for delivery to Ethereum

type MessageQueue = MessageQueue;
type Decimals = ConstU8<12>;
type MaxMessagePayloadSize = ConstU32<2048>;
type MaxMessagesPerBlock = ConstU32<32>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Another magic number.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, we should make this a documented comment. MaxMessagesPerBlock refers to the maximum number of outbound messages to Ethereum that can be committed per block.

@bkchr
Copy link
Contributor

bkchr commented Mar 25, 2024

@claravanstaden tests are now failing. Are you working on fixing this?

@bkontur
Copy link
Contributor

bkontur commented Mar 25, 2024

@claravanstaden @vgeddes my guess is that, these fee amounts here and here are weight-dependent, I would maybe remove those amount checks e.g. && *amount == 50710000, because we will have to adjust them on every runtime upgrade or weights change.

(But checking locally, if it is about that)

@vgeddes
Copy link
Contributor

vgeddes commented Mar 25, 2024

@claravanstaden tests are now failing. Are you working on fixing this?

About to push a fix, just waiting on tests to run..

@bkontur
Copy link
Contributor

bkontur commented Mar 25, 2024

@claravanstaden @vgeddes my guess is that, these fee amounts here and here are weight-dependent, I would maybe remove those amount checks e.g. && *amount == 50710000, because we will have to adjust them on every runtime upgrade or weights change.

(But checking locally, if it is about that)

here is my suggestion with working tests: Snowfork#8

@ggwpez
Copy link
Member

ggwpez commented Mar 25, 2024

We dont have a CI check for benchmarks? We have some on the SDK, should probably have them here as well.

@bkontur
Copy link
Contributor

bkontur commented Mar 25, 2024

We dont have a CI check for benchmarks? We have some on the SDK, should probably have them here as well.

#197

@bkchr
Copy link
Contributor

bkchr commented Mar 25, 2024

@vgeddes please run cargo fmt --all

@claravanstaden
Copy link
Contributor Author

/merge

@fellowship-merge-bot
Copy link
Contributor

Enabled auto-merge in Pull Request

Available commands
  • /merge: Enables auto-merge for Pull Request
  • /merge cancel: Cancels auto-merge for Pull Request
  • /merge help: Shows this menu

For more information see the documentation

@fellowship-merge-bot fellowship-merge-bot bot enabled auto-merge (squash) March 25, 2024 18:40
@acatangiu
Copy link
Contributor

migration CI jobs were automatically cancelled for no apparent reason 🤷 let's see if it goes ahead with the merge or needs manual intervention from some gh polkadot-fellows org member

@fellowship-merge-bot fellowship-merge-bot bot merged commit bc9491d into polkadot-fellows:main Mar 25, 2024
33 of 34 checks passed
@claravanstaden claravanstaden deleted the fix-snowbridge-benchmarks branch March 26, 2024 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants