darwinia-network / bridger Goto Github PK
View Code? Open in Web Editor NEWRelayer client implementation for Darwinia LCMP protocols.
Home Page: https://rust-docs.darwinia.network/bridger
License: GNU General Public License v3.0
Relayer client implementation for Darwinia LCMP protocols.
Home Page: https://rust-docs.darwinia.network/bridger
License: GNU General Public License v3.0
bridger should receive an answer from shadow about its status such as its latest block when error. not just pop up a json error.
[2021-01-05T09:05:55Z ERROR darwinia_bridger::service::relay] Error {
context: "Fail to get parcel from shadow when affirming ethereum block 9401625",
source: Error {
context: "Fail to parse json to MMRRootJson: https://testnet.shadow.darwinia.network/ethereum/parent_mmr_root/9401626",
source: reqwest::Error {
kind: Decode,
source: Error("missing field `mmr_root`", line: 1, column: 49),
},
},
}
[2020-10-24T09:49:32Z TRACE darwinia_bridger::service::redeem] Looking for redeemable ethereum transactions...
[2020-10-24T09:49:32Z TRACE darwinia_bridger::service::redeem] Currently we have 14 txs might need to be redeemed
[2020-10-24T09:49:39Z INFO darwinia_bridger::service::redeem] Redeemed tx 0x40f96d27265e851fc8bbd01360a775cf2f278e13a6c5f6c0f38babcd72f475c0
[2020-10-24T09:49:40Z INFO darwinia_bridger::service::redeem] Redeemed tx 0x1f4da58dd08c2d2370cebbbf1c0705273b15c4223ed3c32a64b7588e39a6dd7e
[2021-01-06T05:47:12Z ERROR darwinia_bridger::service::subscribe] Encounter error when handle events of block 3413001: Scale codec error: Error decoding field AccountId32.0
[2020-10-21T07:28:31Z ERROR jsonrpsee::client] Client Error: Inner(Ws(Closed))
Line 97 in f327846
If set darwinia start back, it will re sign and send root or new authorities extrinsic.
> bridger run -d
> bridger status
ID SERVICE NAME STATUS
1 ethereum to darwinia relay runing
2 ethereum to darwinia redeem stopped
3 ethereum to darwinia guard stopped
4 ethereum tracking runing
5 darwinia tracking runing
> bridger start 2
> bridger stop 2
๐บ ./target/debug/bridger keys
sudo key: d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...)
technical committee members: [d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...)]
๐บ ./target/debug/bridger guard
[2020-10-26T16:00:16Z INFO darwinia_bridger::cmd::guard] Init API succeed!
[2020-10-26T16:00:16Z ERROR darwinia_bridger::cmd::guard] Bridger("Guard service is not running because the relayer is not a member of the technical committee!!!")
And why using !!!
here? A bridger is not a technical committee that might be a common situation.
Could cause redeem service stop running?
For example, change the rpc
in [eth]
to a non-existent node address:
# ...
[eth]
rpc = 'https://mainnet.infura.ioabcd/v3/...'
start = 11149205
# ...
Bridger should report an error if it's not able to connect to the rpc endpoint. Please do not check the address ourselves, instead, it is better just throwing out the error from the HTTP client, as this is just an example case to let you easily reproduce the issue. We have tons of possibilities of different errors, like connection refused
if the port is misconfigured, no route to the host
if the IP is misconfigured, or missing CA certificates
if we don't have ca-certificates
installed, etc...
Line 53 in b4bcc5e
The error!()
should print logs actually out of our expectations, and the fail of relayable check are in expect, they should be warn!()
, different from the real error.
[2020-10-26T08:05:19Z ERROR darwinia_bridger::service::relay] Bridger("The target block 8779869 is pending")
[2020-10-26T08:06:19Z ERROR darwinia_bridger::service::relay] Bridger("The target block 8779869 is pending")
[2020-10-26T08:07:20Z INFO darwinia_bridger::service::relay] Affirmed ethereum block 8779869 in extrinsic 0x0c097555e3bc30bbe0a25ee903aa44185fa1deb398e19cd4152c6a961f956172
[2020-10-26T08:08:20Z INFO darwinia_bridger::service::relay] Affirmed ethereum block 8779869 in extrinsic 0x4d79529ddb27026718bb3970697c02feb020bb4429225143aa91b10600013197
[2020-10-26T08:09:20Z ERROR darwinia_bridger::service::relay] Bridger("The target block 8779869 is pending")
[2020-10-26T08:10:21Z ERROR darwinia_bridger::service::relay] Bridger("The target block 8779869 is pending")
[2020-10-26T08:13:23Z ERROR darwinia_bridger::service::relay] Bridger("The target block 8779869 is pending")
A refactor is required to do later.
In current chain protocol, headers must be confirmed increasingly.
This approve extrinsic will fail, these pending headers will be cleaned by system in confirm end block.
Prevent transactions with the same nonce from being sent
There were redeem examples, recent example is guard:
When handling the Darwinia event, this error will appear repeatedly, but it will not cause a problem.
[2020-12-30T13:19:19Z ERROR darwinia_bridger::service::subscribe] Encounter error when handle events of block 378287: Scale codec error: No such variant in enum Phase
Lines 39 to 40 in f327846
Lines 83 to 90 in f327846
The darwinia-bridge-primitives
crate already implemented the same function
bridger/primitives/src/byte.rs
Lines 24 to 39 in f327846
Currently, there is a relayer
key in config which is only used when proxy account is open.
A minor suggestion would be.
real
proxy
tag to define keys only for proxyseed = ""
[proxy]
real = ""
e.g.
They have different proxytypes:
Crab: https://github.com/darwinia-network/darwinia/blob/master/runtime/crab/src/lib.rs#L738
Darwinia: https://github.com/darwinia-network/darwinia/blob/master/runtime/darwinia/src/lib.rs#L709
In the startup information, add whether the current relay account is a sudo account or a member of the technical committee.
Since I'm using Kubernetes to deploy the bridger, probably adding the version to logs at the time when bridger launches would be nice. That way, operators like me will be able to know the version of current running bridger, by just inspecting log output without running another command in the container.
Could not build futures-macro
using sccache
wrapper.
Stop the sccache
backend server solved the problem on my machine temporarily
Part of the logs:
darwinia-bridger-ws-codec-reserved-op-code.log
The size of full logs is about 6 GiB, so I'd have to upload only a part of it. I believe those left logs contain no valuable info but only the error "Client Error: Inner(Ws(Codec(ReservedOpCode)))".
[2020-10-29T09:04:41Z TRACE darwinia_bridger::service::ethereum] Scanning on ethereum for new cross-chain transactions...
[2020-10-29T09:05:12Z TRACE darwinia_bridger::service::ethereum] Scanning on ethereum for new cross-chain transactions...
[2020-10-29T09:05:20Z TRACE darwinia_bridger::service::redeem] Looking for redeemable ethereum transactions...
[2020-10-29T09:05:20Z TRACE darwinia_bridger::service::redeem] Currently we have 1 txs might need to be redeemed
[2020-10-29T09:05:20Z INFO darwinia_bridger::service::guard] Last confirmed ethereum block number is 8968590
[2020-10-29T09:05:20Z TRACE darwinia_bridger::service::guard] Checking pending headers...
[2020-10-29T09:05:21Z TRACE darwinia_bridger::service::relay] Prepare to affirm ethereum block: 8970243
[2020-10-29T09:05:21Z TRACE darwinia_bridger::api::darwinia] Proxy call `affirm` for cec66c9be4c0500c5da90cb87d1d0af693da4d5fc9bf0e43ec6195cf7ee4d650 (5GjpfZkb...)
[2020-10-29T09:05:21Z ERROR darwinia_bridger::service::relay] Subxt("Rpc error: Server responded to our request with an error: Error { code: ServerError(1010), message: \"Invalid Transaction\", data: Some(String(\"Transaction has a bad signature\")) }")
If mmr is 0x0, it means shadow is not ready yet, maybe guard should wait for a while to vote.
In another aspect, shadow service's real time performance is important for guard to make decision.
bridger/src/service/subscribe/mod.rs
Line 117 in 7ed9355
bridger/src/service/subscribe/mod.rs
Line 84 in a4b351a
if some error occurs here, we may lose events in this block since the next block index still moves forward.
This will make the checking of pull requests easier, for example, rustfmt
will :
Lots of editors will run rustfmt
on saving changes.
This still can be implemented by using husky
.
Our contract addresses are rarely changed, it might be a choice to write it inside and switch by flag, for example bridger run -v --testnet
Or a switcher like the proxy config:
testnet = false;
affirm, when received request of header relay into light client, and there are no existing games match requirement (game block number is smaller than the requested block number).
dispute_and_affirm, when received affirm event and have different checking result.
extend_affirmation, when received event of new round, and continue to follow the right affirmation if necessary. (make sure that last_leaf
is using first_affirm_header_number - 1
, because protocol is using mm_root in first affirmed header parcel to verify consistency)
Check #44
First release and tag,
then ci auto publish on crates.io
Now the tx data center is a memory pool, if the program stopped, the tx data will be lost.
When the user restarts the program, he must reset the start
param in the config file, or the program will do repeat work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.