-
Notifications
You must be signed in to change notification settings - Fork 131
Fix on-different-forks metrics during initialization #1468
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
Changes from all commits
1fbcd0c
b10f341
8c5f904
3f6ca6c
d799c64
d16260b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -795,33 +795,28 @@ impl_runtime_apis! { | |
| } | ||
|
|
||
| impl bp_rialto::RialtoFinalityApi<Block> for Runtime { | ||
| fn best_finalized() -> (bp_rialto::BlockNumber, bp_rialto::Hash) { | ||
| let header = BridgeRialtoGrandpa::best_finalized(); | ||
| (header.number, header.hash()) | ||
| fn best_finalized() -> Option<(bp_rialto::BlockNumber, bp_rialto::Hash)> { | ||
| BridgeRialtoGrandpa::best_finalized().map(|header| (header.number, header.hash())) | ||
| } | ||
| } | ||
|
|
||
| impl bp_westend::WestendFinalityApi<Block> for Runtime { | ||
| fn best_finalized() -> (bp_westend::BlockNumber, bp_westend::Hash) { | ||
| let header = BridgeWestendGrandpa::best_finalized(); | ||
| (header.number, header.hash()) | ||
| fn best_finalized() -> Option<(bp_westend::BlockNumber, bp_westend::Hash)> { | ||
| BridgeWestendGrandpa::best_finalized().map(|header| (header.number, header.hash())) | ||
| } | ||
| } | ||
|
|
||
| impl bp_rialto_parachain::RialtoParachainFinalityApi<Block> for Runtime { | ||
| fn best_finalized() -> (bp_rialto::BlockNumber, bp_rialto::Hash) { | ||
| fn best_finalized() -> Option<(bp_rialto::BlockNumber, bp_rialto::Hash)> { | ||
| // the parachains finality pallet is never decoding parachain heads, so it is | ||
| // only done in the integration code | ||
| use bp_rialto_parachain::RIALTO_PARACHAIN_ID; | ||
| let best_rialto_parachain_head = pallet_bridge_parachains::Pallet::< | ||
| let encoded_head = pallet_bridge_parachains::Pallet::< | ||
| Runtime, | ||
| WithRialtoParachainsInstance, | ||
| >::best_parachain_head(RIALTO_PARACHAIN_ID.into()) | ||
| .and_then(|encoded_header| bp_rialto_parachain::Header::decode(&mut &encoded_header.0[..]).ok()); | ||
| match best_rialto_parachain_head { | ||
| Some(head) => (*head.number(), head.hash()), | ||
| None => (Default::default(), Default::default()), | ||
| } | ||
| >::best_parachain_head(RIALTO_PARACHAIN_ID.into())?; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I would use |
||
| let head = bp_rialto_parachain::Header::decode(&mut &encoded_head.0[..]).ok()?; | ||
| Some((*head.number(), head.hash())) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,8 @@ rand_sleep() { | |
|
|
||
| # last time when we have been asking for conversion rate update | ||
| LAST_CONVERSION_RATE_UPDATE_TIME=0 | ||
| # current conversion rate | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All these scripts look very similar. I wonder if we could move the common logic in a function that's accessible to all. Just saying, but probably it's not worth doing now.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - it has became complicated with that conversion rate override stuff, but we'll probably would need to remove it soon (it isn't usable in the XCM infra). But overall idea looks good (if there's enough code that may be shared)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created #1526 for this |
||
| CONVERSION_RATE=metric | ||
| # conversion rate override argument | ||
| CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric" | ||
|
|
||
| # start sending large messages immediately | ||
| LARGE_MESSAGES_TIME=0 | ||
|
|
@@ -46,30 +46,32 @@ do | |
| # ask for latest conversion rate. We're doing that because otherwise we'll be facing | ||
| # bans from the conversion rate provider | ||
| if [ $SECONDS -ge $LAST_CONVERSION_RATE_UPDATE_TIME ]; then | ||
| CONVERSION_RATE=metric | ||
| LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + 300)) | ||
| CONVERSION_RATE_OVERRIDE="--conversion-rate-override metric" | ||
| CONVERSION_RATE_UPDATE_DELAY=`shuf -i 300-600 -n 1` | ||
| LAST_CONVERSION_RATE_UPDATE_TIME=$((SECONDS + $CONVERSION_RATE_UPDATE_DELAY)) | ||
| fi | ||
|
|
||
| # send regular message | ||
| echo "Sending Message from Rialto to Millau" | ||
| SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE --conversion-rate-override $CONVERSION_RATE raw 010109030419A8 2>&1` | ||
| SEND_MESSAGE_OUTPUT=`$SEND_MESSAGE --lane $MESSAGE_LANE $CONVERSION_RATE_OVERRIDE raw 010109030419A8 2>&1` | ||
| echo $SEND_MESSAGE_OUTPUT | ||
| if [ "$CONVERSION_RATE" = "metric" ]; then | ||
| if [ "$CONVERSION_RATE_OVERRIDE" = "--conversion-rate-override metric" ]; then | ||
| ACTUAL_CONVERSION_RATE_REGEX="conversion rate override: ([0-9\.]+)" | ||
| if [[ $SEND_MESSAGE_OUTPUT =~ $ACTUAL_CONVERSION_RATE_REGEX ]]; then | ||
| CONVERSION_RATE=${BASH_REMATCH[1]} | ||
| echo "Read updated conversion rate: $CONVERSION_RATE" | ||
| CONVERSION_RATE_OVERRIDE="--conversion-rate-override $CONVERSION_RATE" | ||
| else | ||
| echo "Unable to find conversion rate in send-message output" | ||
| exit 1 | ||
| echo "Error: unable to find conversion rate in send-message output. Will keep using on-chain rate" | ||
| CONVERSION_RATE_OVERRIDE="" | ||
| fi | ||
| fi | ||
|
|
||
| if [ ! -z $SECONDARY_MESSAGE_LANE ]; then | ||
| echo "Sending Message from Rialto to Millau using secondary lane: $SECONDARY_MESSAGE_LANE" | ||
| $SEND_MESSAGE \ | ||
| --lane $SECONDARY_MESSAGE_LANE \ | ||
| --conversion-rate-override $CONVERSION_RATE \ | ||
| $CONVERSION_RATE_OVERRIDE \ | ||
| raw 010109030419A8 | ||
| fi | ||
|
|
||
|
|
@@ -81,7 +83,7 @@ do | |
| echo "Sending Maximal Size Message from Rialto to Millau" | ||
| $SEND_MESSAGE \ | ||
| --lane $MESSAGE_LANE \ | ||
| --conversion-rate-override $CONVERSION_RATE \ | ||
| $CONVERSION_RATE_OVERRIDE \ | ||
| sized max | ||
| fi | ||
|
|
||
|
|
@@ -93,7 +95,7 @@ do | |
| do | ||
| $SEND_MESSAGE \ | ||
| --lane $MESSAGE_LANE \ | ||
| --conversion-rate-override $CONVERSION_RATE \ | ||
| $CONVERSION_RATE_OVERRIDE \ | ||
| raw 010109030419A8 | ||
| done | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think we could use the new
HeaderIdProvider::id()in these implementations. Could we also return anOption<HeaderId>here ? Or are we limited to basic types like tuples for the values returned by the API methods ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I think it could be done. Thank you!