Reset spec params in prepareMoCNode.js (#75)
* reset spec params * delete block reward contract address and transition * update spec for the newest parity version * update required parity version * update spec after contracts deployment * add "check balance" step * add "check balance" step to README * add second check for balance * Enhance checkEmissionFundsBalance.js
This commit is contained in:
parent
6dbab0313f
commit
d7541abbee
15
README.md
15
README.md
|
@ -25,7 +25,7 @@
|
|||
|
||||
## Requirements
|
||||
1. Linux, Mac OS
|
||||
2. Parity 1.9.2+
|
||||
2. Parity 2.5.9+
|
||||
3. Google Chrome
|
||||
|
||||
## Basic scenarios
|
||||
|
@ -33,6 +33,7 @@
|
|||
There are some options to start POA Network test setup depending on your needs:
|
||||
- [Start MoC node](#start-moc-node) - launches only MoC node, generates initial key
|
||||
- [Launch DApps](#launch-dapps) - launches Ceremony, Validators, Governance DApps
|
||||
- [Check Emission Funds balance](#check-emission-funds-balance) - checks whether Emission Funds balance is not zero
|
||||
- [Launch Ceremony](#launch-ceremony) - conducts Ceremony
|
||||
- [Set validator data](#set-validators-personal-data) - set validators personal data with Validators DApp
|
||||
- [Add validator from Governance](#add-validator-from-governance) - add new validator from Governance
|
||||
|
@ -73,10 +74,20 @@ $ npm run launch-dapps
|
|||
- Validators DApp is started on `http://localhost:3001`
|
||||
- Governance DApp is started on `http://localhost:3002`
|
||||
|
||||
### Launch Ceremony
|
||||
### Check Emission Funds balance
|
||||
|
||||
*Note*: can be started after [the previous step is completed](#launch-dapps)
|
||||
|
||||
`npm run check-emission-funds-balance`
|
||||
|
||||
#### Expected results:
|
||||
- no errors returned
|
||||
|
||||
|
||||
### Launch Ceremony
|
||||
|
||||
*Note*: can be started after [the "Launch DApps" step is completed](#launch-dapps)
|
||||
|
||||
For Ubuntu users: you should first install and use *X virtual framebuffer* if you want to move all graphical operations to the virtual memory without showing any screen output.
|
||||
```
|
||||
sudo apt-get -y install xvfb
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
const fs = require('fs');
|
||||
const Web3 = require('web3');
|
||||
const { constants } = require('./utils/constants');
|
||||
|
||||
const { BN } = Web3.utils;
|
||||
|
||||
function timeout(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
async function main() {
|
||||
const spec = JSON.parse(fs.readFileSync(`${constants.specFolder}/spec.json`));
|
||||
const emissionFundsAddress = JSON.parse(fs.readFileSync(`${constants.pathToContractRepo}/contracts.json`)).EMISSION_FUNDS_ADDRESS;
|
||||
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
|
||||
const stepDurationMs = spec.engine.authorityRound.params.stepDuration * 1000;
|
||||
|
||||
let blockNumber = Number(await web3.eth.getBlockNumber());
|
||||
|
||||
while (blockNumber <= Number(spec.engine.authorityRound.params.blockRewardContractTransition) + 2) {
|
||||
console.log('Waiting for blockRewardContractTransition...');
|
||||
await timeout(stepDurationMs);
|
||||
blockNumber = Number(await web3.eth.getBlockNumber());
|
||||
}
|
||||
|
||||
const prevBalance = new BN(await web3.eth.getBalance(emissionFundsAddress, blockNumber - 1));
|
||||
const balance = new BN(await web3.eth.getBalance(emissionFundsAddress, blockNumber));
|
||||
|
||||
if (!balance.gt(prevBalance)) {
|
||||
throw Error('EmissionFunds contract balance hasn\'t been increased');
|
||||
}
|
||||
|
||||
console.log('OK');
|
||||
}
|
|
@ -22,13 +22,14 @@
|
|||
"web3": "1.0.0-beta.34"
|
||||
},
|
||||
"scripts": {
|
||||
"start-moc-setup": "npm run get-all-submodules && npm run prepare-contracts-repo && npm run prepare-moc-node && npm run start-moc-node && npm run deploy-secondary-contracts && npm run prepare-scripts-moc-repo && npm run test-setup-is-started",
|
||||
"start-moc-setup": "npm run get-all-submodules && npm run prepare-contracts-repo && npm run prepare-moc-node && npm run start-moc-node && npm run deploy-secondary-contracts && npm run update-spec && npm run start-moc-node && npm run prepare-scripts-moc-repo && npm run test-setup-is-started",
|
||||
"launch-dapps": "npm run launch-ceremony-dapp && npm run launch-validators-dapp && npm run launch-governance-dapp",
|
||||
"launch-dapps-ceremony": "npm run launch-ceremony-dapp",
|
||||
"launch-dapps-light": "npm run launch-ceremony-dapp",
|
||||
"launch-ceremony": "npm run launch-ceremony-1 && npm run launch-ceremony-2 && npm run launch-ceremony-3",
|
||||
"set-validators-data": "npm run e2e-validators-test 1 && npm run e2e-validators-test 2 && npm run e2e-validators-test 3",
|
||||
"set-validators-data-light": "npm run e2e-validators-test 1",
|
||||
"check-emission-funds-balance": "node checkEmissionFundsBalance",
|
||||
"add-validator": "npm run e2e-voting-test 1",
|
||||
"start-new-validator-node": "node prepareValidatorNode 4 && npm run start-validator-node 4",
|
||||
"launch-ceremony-light": "npm run launch-ceremony-1",
|
||||
|
@ -38,12 +39,13 @@
|
|||
"launch-ceremony-1": "npm run generate-initial-key && npm run get-private-initial-keys && npm run e2e-ceremony-test 1 && npm run prepare-validator-node 1 && npm run start-validator-node 1",
|
||||
"launch-ceremony-2": "npm run generate-initial-key && npm run get-private-initial-keys && npm run e2e-ceremony-test 2 && npm run prepare-validator-node 2 && npm run start-validator-node 2",
|
||||
"launch-ceremony-3": "npm run generate-initial-key && npm run get-private-initial-keys && npm run e2e-ceremony-test 3 && npm run prepare-validator-node 3 && npm run start-validator-node 3",
|
||||
"start-test-setup": "npm run get-all-submodules && npm run prepare-contracts-repo && npm run prepare-moc-node && npm run start-moc-node && npm run deploy-secondary-contracts && npm run prepare-scripts-moc-repo && npm run prepare-ceremony-dapp && npm run prepare-ceremony-dapp-more && npm run generate-initial-keys && npm run get-private-initial-keys && npm run start-ceremony && npm run test-setup-is-started",
|
||||
"start-test-setup": "npm run get-all-submodules && npm run prepare-contracts-repo && npm run prepare-moc-node && npm run start-moc-node && npm run deploy-secondary-contracts && npm run update-spec && npm run start-moc-node && npm run prepare-scripts-moc-repo && npm run prepare-ceremony-dapp && npm run prepare-ceremony-dapp-more && npm run generate-initial-keys && npm run get-private-initial-keys && npm run start-ceremony && npm run test-setup-is-started",
|
||||
"start-test-setup-e2e-ceremony-test": "npm run start-test-setup && npm run e2e-ceremony-test",
|
||||
"start-moc-validator-setup": "npm run start-test-setup-e2e-ceremony-test && npm run prepare-validator-node 1 && npm run start-validator-node 1 > /dev/null 2>&1 & && npm run prepare-validators-dapp && npm run prepare-validators-dapp-more && npm run start-validators-dapp",
|
||||
"get-all-submodules": "git submodule update --init --remote",
|
||||
"prepare-contracts-repo": "bash ./scripts/prepare-contracts-repo",
|
||||
"prepare-moc-node": "node prepareMoCNode",
|
||||
"update-spec": "node updateSpec",
|
||||
"start-moc-node": "bash ./scripts/start-moc-node",
|
||||
"deploy-secondary-contracts": "bash ./scripts/deploy-secondary-contracts",
|
||||
"prepare-scripts-moc-repo": "node prepareMoCScripts",
|
||||
|
|
|
@ -32,6 +32,58 @@ async function main() {
|
|||
return console.log(e.message)
|
||||
}
|
||||
|
||||
[
|
||||
'eip145Transition',
|
||||
'eip1014Transition',
|
||||
'eip1052Transition',
|
||||
'eip1283Transition',
|
||||
'eip1344Transition',
|
||||
'eip1706Transition',
|
||||
'eip1884Transition',
|
||||
'eip2028Transition'
|
||||
].forEach(param => {
|
||||
spec.params[param] = '0x0';
|
||||
});
|
||||
|
||||
delete spec.params['eip1283DisableTransition'];
|
||||
delete spec.engine.authorityRound.params['blockRewardContractAddress'];
|
||||
delete spec.engine.authorityRound.params['blockRewardContractTransition'];
|
||||
|
||||
spec.accounts['0000000000000000000000000000000000000006'].builtin['eip1108_transition'] = '0x0';
|
||||
spec.accounts['0000000000000000000000000000000000000006'].builtin.pricing = {
|
||||
alt_bn128_const_operations: {
|
||||
price: 500,
|
||||
eip1108_transition_price: 150,
|
||||
},
|
||||
};
|
||||
spec.accounts['0000000000000000000000000000000000000007'].builtin['eip1108_transition'] = '0x0';
|
||||
spec.accounts['0000000000000000000000000000000000000007'].builtin.pricing = {
|
||||
alt_bn128_const_operations: {
|
||||
price: 40000,
|
||||
eip1108_transition_price: 6000,
|
||||
},
|
||||
};
|
||||
spec.accounts['0000000000000000000000000000000000000008'].builtin['eip1108_transition'] = '0x0';
|
||||
spec.accounts['0000000000000000000000000000000000000008'].builtin.pricing = {
|
||||
alt_bn128_pairing: {
|
||||
base: 100000,
|
||||
pair: 80000,
|
||||
eip1108_transition_base: 45000,
|
||||
eip1108_transition_pair: 34000,
|
||||
},
|
||||
};
|
||||
spec.accounts['0000000000000000000000000000000000000009'] = {
|
||||
builtin: {
|
||||
name: 'blake2_f',
|
||||
activate_at: '0x0',
|
||||
pricing: {
|
||||
blake2_f: {
|
||||
gas_per_round: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
utils.clearFolder(constants.mocKeysFolder);
|
||||
|
||||
let POAKeysFolder = `${constants.masterNodeKeysFolder}${spec.name}`;
|
||||
|
@ -124,4 +176,4 @@ function generateAddress(password) {
|
|||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,12 @@ fi
|
|||
toml=./nodes/parity-moc/moc.toml
|
||||
log=./nodes/parity-moc/parity.log
|
||||
|
||||
# if the node is already started
|
||||
if lsof -t -i:8545 > /dev/null
|
||||
then
|
||||
kill -9 $(lsof -t -i:8545)
|
||||
fi
|
||||
|
||||
cmd2=$(parity --config $toml > $log 2>&1 &)
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
|
|
@ -9,11 +9,11 @@ function checkclientversion()
|
|||
minor=$(echo $parityversion | cut -d'.' -f 2)
|
||||
patch=$(echo $parityversion | cut -d'.' -f 3)
|
||||
|
||||
majormin=1
|
||||
minormin=9
|
||||
patchmin=2
|
||||
majormin=2
|
||||
minormin=5
|
||||
patchmin=9
|
||||
|
||||
errormsg="Parity Ethereum client version should be more or equal than v1.9.2. Your current installation has version $parityversion"
|
||||
errormsg="Parity Ethereum client version should be more or equal than v2.5.9. Your current installation has version $parityversion"
|
||||
|
||||
function genError()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
const fs = require('fs');
|
||||
const Web3 = require('web3');
|
||||
const Constants = require('./utils/constants');
|
||||
const constants = Constants.constants;
|
||||
const utils = require('./utils/utils');
|
||||
|
||||
main();
|
||||
|
||||
async function main() {
|
||||
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
|
||||
const currentBlock = await web3.eth.getBlockNumber();
|
||||
const specPath = `${constants.specFolder}spec.json`;
|
||||
const spec = JSON.parse(fs.readFileSync(specPath));
|
||||
const addresses = JSON.parse(fs.readFileSync(`${constants.pathToContractRepo}/contracts.json`));
|
||||
spec.engine.authorityRound.params['blockRewardContractAddress'] = addresses.REWARD_BY_BLOCK_ADDRESS;
|
||||
spec.engine.authorityRound.params['blockRewardContractTransition'] = currentBlock + 5;
|
||||
try {
|
||||
await utils.saveToFile(specPath, JSON.stringify(spec, null, 2));
|
||||
} catch (err) {
|
||||
return console.log(err.message);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue