-
Notifications
You must be signed in to change notification settings - Fork 102
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
Rainbow on Binance Smart Chain #604
Conversation
879edc9
to
7386a26
Compare
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.
For now only reviewed the code affecting the previous setup, will continue reviewing the code introducing the new feature next. I'm making this checkpoint to leave some comments.
400_000 / 30000, | ||
vec![blocks_with_proofs.first().unwrap().merkle_root], | ||
blocks[0].clone(), | ||
30, | ||
10, | ||
10, | ||
None, | ||
97, |
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.
Let's use named ChainId here, to be clear what this number actually means. In this case since we are using ethash
let's use chain_id 3, though it is not used anywhere so it makes no real difference.
Just as a note for other reviewing this PR I found a list of chain id from networks supporting EVM: Chainlist.
Makefile
Outdated
test-eth-client: | ||
cd contracts/near/eth-client && ./test.sh | ||
|
||
.PHONY: help init yarn-init gen-contracts start-bsc full-bsc-contracts light-bsc-contracts start-relayer stop-all build-eth-client test-eth-client start-ethash |
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.
Thanks for the Makefile, it is a really helpful addition. 🎉
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.
Contract LGTM.
For the BSC code in the client I think we should use rust feature flags so only the intended binary is compiled and deployed.
contracts/near/eth-client/src/lib.rs
Outdated
self.headers.get(&self.epoch_header).unwrap() | ||
} | ||
|
||
// check if the auther address is valid and is in the validator set. |
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.
// check if the auther address is valid and is in the validator set. | |
// check if the author address is valid and is in the validator set. |
contracts/near/eth-client/src/lib.rs
Outdated
[extra_vanity..(epoch_header.extra_data.len() - extra_seal)] | ||
.to_vec(); | ||
|
||
// Get validator offset postion. |
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.
// Get validator offset postion. | |
// Get validator offset position. |
contracts/near/eth-client/src/lib.rs
Outdated
return true; | ||
} | ||
|
||
// verift basic header properties. |
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.
// verift basic header properties. | |
// verify basic header properties. |
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.
Merge conflicts needs to be solved before merging.
Feature bsc review 2
Hello @mfornet @abacabadabacaba |
@sept-en could you take a look at this PR before merging. |
I discussed with @sept-en and agreed on merge it to |
New BSC Feature
The new BSC feature allows Rainbow bridge to run on Binance Smart Chain.
Technical
When the Bridge is configured to use bsc mode, the first header has to be an epoch header (block_number%200==0). That is because the epoch header contains the validator set inside the
extra_data
field. After that, bridge starts to receive and validate the other blocks. If current block at the time of starting the bridge isn't the epoch block, bridge gets initialised at previous epoch block.Every time Near client gets a new epoch header it saves it and uses the new validator set from it.
New Configurations:
The Bridge handles POW(ethash), POSA(bsc), or POA, by default the POW is used.
To use
bsc
:and to use
ethash
:here is an example of the new config file
~/.rainbow/config.json
:Deploy the bridge locally with BSC Mode
To run the bridge locally with Binance Smart Chain, run the following cmd:
or use already deployed contracts (on BSC), first copy past the following parameters inside the
~/.rainbow/config.json
file:then run the following command: