Skip to content

Commit

Permalink
Merge pull request #266 from bnb-chain/ff_old
Browse files Browse the repository at this point in the history
fix: use old format for genesis header
  • Loading branch information
unclezoro authored Apr 20, 2023
2 parents b144718 + 332423c commit c6f9e89
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions contracts/BSCValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica
uint256 public constant EXPIRE_TIME_SECOND_GAP = 1000;
uint256 public constant MAX_NUM_OF_VALIDATORS = 41;

bytes public constant INIT_VALIDATORSET_BYTES = hex"f84580f842f840949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d79164";
bytes public constant INIT_VALIDATORSET_BYTES = hex"f87680f873f871949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d79164b085e6972fc98cd3c81d64d40e325acfed44365b97a7567a27939c14dbc7512ddcf54cb1284eb637cfa308ae4e00cb5588";

uint32 public constant ERROR_UNKNOWN_PACKAGE_TYPE = 101;
uint32 public constant ERROR_FAIL_CHECK_VALIDATORS = 102;
Expand All @@ -56,7 +56,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica

uint256 public constant BURN_RATIO_SCALE = 10000;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
uint256 public constant INIT_BURN_RATIO = 1000;
uint256 public constant INIT_BURN_RATIO = 0;
uint256 public burnRatio;
bool public burnRatioInitialized;

Expand Down
7 changes: 5 additions & 2 deletions contracts/RelayerHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ contract RelayerHub is IRelayerHub, System, IParamSubscriber {

uint256 public constant INIT_REQUIRED_DEPOSIT = 1e20;
uint256 public constant INIT_DUES = 1e17;
address public constant WHITELIST_1 = 0xb005741528b86F5952469d80A8614591E3c5B632;
address public constant WHITELIST_2 = 0x446AA6E0DC65690403dF3F127750da1322941F3e;


address public constant WHITELIST_1 = 0xb005741528b86F5952469d80A8614591E3c5B632;
address public constant WHITELIST_2 = 0x446AA6E0DC65690403dF3F127750da1322941F3e;


uint256 internal requiredDeposit; // have to keep it to not break the storage layout
uint256 internal dues;
Expand Down
1 change: 0 additions & 1 deletion contracts/SlashIndicator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication
}
}


/**
* @dev Send a felony cross-chain package to jail a validator
*
Expand Down
29 changes: 15 additions & 14 deletions genesis.json

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ const bLSPublicKeys = [
];

// =============== Do not edit below ====
function generateExtradata(validators, bLSPublicKeys) {
function generateExtradata(validators) {
let extraVanity =Buffer.alloc(32);
let validatorsBytes = extraDataSerialize(validators, bLSPublicKeys);
let validatorsBytes = extraDataSerialize(validators);
let extraSeal =Buffer.alloc(65);
return Buffer.concat([extraVanity,validatorsBytes,extraSeal]);
}

function extraDataSerialize(validators, bLSPublicKeys) {
function extraDataSerialize(validators) {
let n = validators.length;
let arr = [];
for(let i = 0;i<n;i++){
let validator = validators[i];
let BLSPublicKey = bLSPublicKeys[i];
arr.push(Buffer.from(web3.utils.hexToBytes(validator.consensusAddr)));
arr.push(Buffer.from(web3.utils.hexToBytes(BLSPublicKey)));
}
return Buffer.concat(arr);
}
Expand All @@ -50,7 +48,7 @@ function validatorUpdateRlpEncode(validators, bLSPublicKeys) {
return web3.utils.bytesToHex(RLP.encode(pkg));
}

extraValidatorBytes = generateExtradata(validators, bLSPublicKeys);
extraValidatorBytes = generateExtradata(validators);
validatorSetBytes = validatorUpdateRlpEncode(validators, bLSPublicKeys);

exports = module.exports = {
Expand Down
11 changes: 4 additions & 7 deletions validators.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@ const bLSPublicKeys = [
];

// =============== Do not edit below ====
function generateExtradata(validators, bLSPublicKeys) {
function generateExtradata(validators) {
let extraVanity =Buffer.alloc(32);
let validatorsBytes = extraDataSerialize(validators, bLSPublicKeys);
let validatorsBytes = extraDataSerialize(validators);
let extraSeal =Buffer.alloc(65);
return Buffer.concat([extraVanity,validatorsBytes,extraSeal]);
}

function extraDataSerialize(validators, bLSPublicKeys) {
function extraDataSerialize(validators) {
let n = validators.length;
let arr = [];
arr.push(Buffer.from(web3.utils.hexToBytes("0x" + n.toString(16))));
for (let i = 0;i<n;i++) {
let validator = validators[i];
let BLSPublicKey = bLSPublicKeys[i];
arr.push(Buffer.from(web3.utils.hexToBytes(validator.consensusAddr)));
arr.push(Buffer.from(web3.utils.hexToBytes(BLSPublicKey)));
}
return Buffer.concat(arr);
}
Expand All @@ -53,7 +50,7 @@ function validatorUpdateRlpEncode(validators, bLSPublicKeys) {
return web3.utils.bytesToHex(RLP.encode(pkg));
}

extraValidatorBytes = generateExtradata(validators, bLSPublicKeys);
extraValidatorBytes = generateExtradata(validators);
validatorSetBytes = validatorUpdateRlpEncode(validators, bLSPublicKeys);

exports = module.exports = {
Expand Down

0 comments on commit c6f9e89

Please sign in to comment.