Closes #13
This commit is contained in:
parent
25941a61e7
commit
8c8dad07ca
14
DEMO.md
14
DEMO.md
|
@ -197,11 +197,11 @@ The public Binance Chain testnet will keep a BEP2 token.
|
|||
"nextEpoch": 3,
|
||||
|
||||
// threshold number for current epoch,
|
||||
// threshold + 1 votes are required for any changes in next epoch
|
||||
"threshold": 1,
|
||||
// at least threshold votes are required for any changes in next epoch
|
||||
"threshold": 2,
|
||||
|
||||
// threshold number for next epoch
|
||||
"nextThreshold": 1,
|
||||
"nextThreshold": 2,
|
||||
|
||||
// current bridge addresses in home and foreign networks
|
||||
"homeBridgeAddress": "0x44c158FE850821ae69DaF37AADF5c539e9d0025B",
|
||||
|
@ -239,13 +239,13 @@ The public Binance Chain testnet will keep a BEP2 token.
|
|||
"confirmationsForFundsTransfer": 0
|
||||
}
|
||||
```
|
||||
* (7.1) Start voting process for next epoch, via sending `$THRESHOLD + 1` requests to `/vote/startVoting` url. Bridge
|
||||
* (7.1) Start voting process for next epoch, via sending `$THRESHOLD` requests to `/vote/startVoting` url. Bridge
|
||||
state should be successfully changed to `voting`.
|
||||
* 7.2 Changing next epoch bridge validators / threshold
|
||||
* (7.2.1) Add / remove validator in next validators list, via sending `$THRESHOLD + 1` requests to
|
||||
* (7.2.1) Add / remove validator in next validators list, via sending `$THRESHOLD` requests to
|
||||
`/vote/addValidator/$ADDRESS` / `/vote/removeValidator/$ADDRESS`.
|
||||
* (7.2.2) Change threshold for the next epoch, via sending `$THRESHOLD + 1` requests to `/vote/changeThreshold/$THRESHOLD`.
|
||||
* (7.3) Start keygen process for next epoch, via sending `$THRESHOLD + 1` requests to `/vote/startKeygen` url. Bridge
|
||||
* (7.2.2) Change threshold for the next epoch, via sending `$THRESHOLD` requests to `/vote/changeThreshold/$THRESHOLD`.
|
||||
* (7.3) Start keygen process for next epoch, via sending `$THRESHOLD` requests to `/vote/startKeygen` url. Bridge
|
||||
state should be successfully changed to `keygen`, and in some time to `funds_transfer`, and then to `ready`.
|
||||
* (7.4) If keygen process at some state was stopped(i. e. one validator turned of his oracle),
|
||||
it can be cancelled via via sending `$THRESHOLD + 1` requests to `/vote/cancelKeygen` url. After
|
||||
|
|
|
@ -9,7 +9,7 @@ VALIDATOR_ADDRESS_2=0xaa006899b0ec407de930ba8a166defe59bbfd3dc
|
|||
VALIDATOR_ADDRESS_3=0x6352e3e6038e05b9da00c84ae851308f9774f883
|
||||
#VALIDATOR_ADDRESS_4=0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa
|
||||
|
||||
THRESHOLD=1
|
||||
THRESHOLD=2
|
||||
|
||||
MIN_TX_LIMIT=10000000000000000
|
||||
MAX_TX_LIMIT=100000000000000000000
|
||||
|
|
|
@ -10,7 +10,7 @@ VALIDATOR_ADDRESS_2=0xbbbb63D6Fc58bD14dAF9eeF653650c4D10f3dBC8
|
|||
VALIDATOR_ADDRESS_3=0xcccc27ae510b63E30eC3C68AAD7DdD2578bD62ed
|
||||
#VALIDATOR_ADDRESS_4=0xdddd9300e32fe162bA420f7313651Fd901C2ed71
|
||||
|
||||
THRESHOLD=1
|
||||
THRESHOLD=2
|
||||
|
||||
MIN_TX_LIMIT=10000000000000000
|
||||
MAX_TX_LIMIT=100000000000000000000
|
||||
|
|
|
@ -57,7 +57,7 @@ contract Bridge {
|
|||
|
||||
constructor(uint threshold, address[] memory validators, address _tokenContract, uint[2] memory limits, uint rangeSize) public {
|
||||
require(validators.length > 0);
|
||||
require(threshold < validators.length);
|
||||
require(threshold <= validators.length);
|
||||
|
||||
tokenContract = IERC20(_tokenContract);
|
||||
|
||||
|
@ -280,6 +280,8 @@ contract Bridge {
|
|||
}
|
||||
|
||||
function voteChangeThreshold(uint threshold) public voting currentValidator {
|
||||
require(threshold > 0 && threshold <= getParties(), "Invalid threshold value");
|
||||
|
||||
if (tryVote(Vote.CHANGE_THRESHOLD, threshold)) {
|
||||
states[nextEpoch].threshold = threshold;
|
||||
}
|
||||
|
@ -292,6 +294,8 @@ contract Bridge {
|
|||
}
|
||||
|
||||
function voteStartKeygen() public voting currentValidator {
|
||||
require(getNextThreshold() <= getNextParties(), "Invalid threshold number");
|
||||
|
||||
if (tryVote(Vote.START_KEYGEN)) {
|
||||
status = Status.KEYGEN;
|
||||
|
||||
|
@ -342,7 +346,7 @@ contract Bridge {
|
|||
require(!votes[personalVote], "Voted already");
|
||||
|
||||
votes[personalVote] = true;
|
||||
if (votesCount[vote] == getThreshold()) {
|
||||
if (votesCount[vote] + 1 == getThreshold()) {
|
||||
votesCount[vote] = 2 ** 255;
|
||||
return true;
|
||||
} else {
|
||||
|
@ -356,7 +360,7 @@ contract Bridge {
|
|||
require(!votes[personalVote], "Confirmed already");
|
||||
|
||||
votes[personalVote] = true;
|
||||
if (votesCount[vote] == getNextThreshold()) {
|
||||
if (votesCount[vote] + 1 == getNextThreshold()) {
|
||||
votesCount[vote] = 2 ** 255;
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -42,7 +42,7 @@ async function main() {
|
|||
logger.debug('Writing params')
|
||||
fs.writeFileSync('./params', JSON.stringify({
|
||||
parties: parties.toString(),
|
||||
threshold: threshold.toString()
|
||||
threshold: (threshold - 1).toString()
|
||||
}))
|
||||
const cmd = exec.execFile('./keygen-entrypoint.sh', [PROXY_URL, keysFile], async () => {
|
||||
currentKeygenEpoch = null
|
||||
|
|
|
@ -172,7 +172,7 @@ async function main() {
|
|||
logger.debug('Writing params')
|
||||
fs.writeFileSync('./params', JSON.stringify({
|
||||
parties: parties.toString(),
|
||||
threshold: threshold.toString()
|
||||
threshold: (threshold - 1).toString()
|
||||
}))
|
||||
|
||||
attempt = 1
|
||||
|
|
|
@ -81,7 +81,7 @@ describe('bridge tests', function () {
|
|||
testEthToBnc(() => users)
|
||||
testBncToEth(() => users)
|
||||
|
||||
testChangeThreshold(2)
|
||||
testChangeThreshold(3)
|
||||
|
||||
testEthToBnc(() => users)
|
||||
testBncToEth(() => users)
|
||||
|
|
Loading…
Reference in New Issue