Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
64f03aaa
Commit
64f03aaa
authored
2 years ago
by
Serban Iorga
Committed by
Bastian Köcher
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve relayer initialization behaviour (#1743)
Wait until the initialization transaction is finalized/lost.
parent
f82372e8
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bridges/relays/lib-substrate-relay/src/finality/initialize.rs
+29
-12
29 additions, 12 deletions
...ges/relays/lib-substrate-relay/src/finality/initialize.rs
with
29 additions
and
12 deletions
bridges/relays/lib-substrate-relay/src/finality/initialize.rs
+
29
−
12
View file @
64f03aaa
...
...
@@ -24,10 +24,12 @@
use
crate
::{
error
::
Error
,
finality
::
engine
::
Engine
};
use
sp_core
::
Pair
;
use
bp_runtime
::
HeaderIdOf
;
use
relay_substrate_client
::{
AccountKeyPairOf
,
Chain
,
ChainWithTransactions
,
Client
,
Error
as
SubstrateError
,
UnsignedTransaction
,
};
use
relay_utils
::{
TrackedTransactionStatus
,
TransactionTracker
};
use
sp_runtime
::
traits
::
Header
as
HeaderT
;
/// Submit headers-bridge initialization transaction.
...
...
@@ -61,13 +63,26 @@ pub async fn initialize<
.await
;
match
result
{
Ok
(
Some
(
tx_hash
))
=>
log
::
info!
(
target
:
"bridge"
,
"Successfully submitted {}-headers bridge initialization transaction to {}: {:?}"
,
SourceChain
::
NAME
,
TargetChain
::
NAME
,
tx_hash
,
),
Ok
(
Some
(
tx_status
))
=>
match
tx_status
{
TrackedTransactionStatus
::
Lost
=>
{
log
::
error!
(
target
:
"bridge"
,
"Failed to execute {}-headers bridge initialization transaction on {}: {:?}."
,
SourceChain
::
NAME
,
TargetChain
::
NAME
,
tx_status
)
},
TrackedTransactionStatus
::
Finalized
(
_
)
=>
{
log
::
info!
(
target
:
"bridge"
,
"Successfully executed {}-headers bridge initialization transaction on {}: {:?}."
,
SourceChain
::
NAME
,
TargetChain
::
NAME
,
tx_status
)
},
},
Ok
(
None
)
=>
(),
Err
(
err
)
=>
log
::
error!
(
target
:
"bridge"
,
...
...
@@ -92,7 +107,7 @@ async fn do_initialize<
prepare_initialize_transaction
:
F
,
dry_run
:
bool
,
)
->
Result
<
Option
<
TargetChain
::
Hash
>
,
Option
<
TrackedTransactionStatus
<
HeaderIdOf
<
TargetChain
>>
>
,
Error
<
SourceChain
::
Hash
,
<
SourceChain
::
Header
as
HeaderT
>
::
Number
>
,
>
where
...
...
@@ -128,8 +143,8 @@ where
initialization_data
,
);
let
initialization_tx_hash
=
target_client
.submit_signed_extrinsic
(
&
target_signer
,
move
|
_
,
transaction_nonce
|
{
let
tx_status
=
target_client
.submit_
and_watch_
signed_extrinsic
(
&
target_signer
,
move
|
_
,
transaction_nonce
|
{
let
tx
=
prepare_initialize_transaction
(
transaction_nonce
,
initialization_data
);
if
dry_run
{
Err
(
SubstrateError
::
Custom
(
...
...
@@ -140,7 +155,9 @@ where
}
})
.await
.map_err
(|
err
|
Error
::
SubmitTransaction
(
TargetChain
::
NAME
,
err
))
?
;
.map_err
(|
err
|
Error
::
SubmitTransaction
(
TargetChain
::
NAME
,
err
))
?
.wait
()
.await
;
Ok
(
Some
(
initialization_tx_hash
))
Ok
(
Some
(
tx_status
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment