Fixes for OpenEthereum

This commit is contained in:
POA 2021-09-24 14:44:35 +03:00
parent 0eae1dfc81
commit ab3cc6b62b
5 changed files with 21 additions and 10 deletions

View File

@ -13,7 +13,7 @@ async function main() {
specFile.engine.authorityRound.params.stepDuration = {
"0": 5
};
// switch to another duration in 120 seconds
// Switch to another duration in 120 seconds
const newStepDurationTimestamp = Math.round((Date.now() / 1000 + 120) / 10) * 10;
specFile.engine.authorityRound.params.stepDuration[newStepDurationTimestamp] = 4;
console.log();
@ -22,11 +22,15 @@ async function main() {
console.log();
console.log();
// specFile.params.eip1559Transition = "10";
// specFile.params.eip1559BaseFeeMaxChangeDenominator = "0x8";
// specFile.params.eip1559ElasticityMultiplier = "0x2";
// specFile.params.eip1559BaseFeeInitialValue = "0x3b9aca00";
// specFile.genesis.baseFeePerGas = "0x3b9aca00";
// Activate London hard fork
specFile.params.eip3198Transition = "0";
specFile.params.eip3529Transition = "0";
specFile.params.eip3541Transition = "0";
specFile.params.eip1559Transition = "8";
specFile.params.eip1559BaseFeeMaxChangeDenominator = "0x8";
specFile.params.eip1559ElasticityMultiplier = "0x2";
specFile.params.eip1559BaseFeeInitialValue = "0x3b9aca00";
specFile.genesis.baseFeePerGas = "0x3b9aca00";
await promisify(fs.writeFile)(__dirname + '/../data/spec.json', JSON.stringify(specFile, null, ' '), 'UTF-8');
}

View File

@ -83,6 +83,10 @@ async function main() {
data,
accessList: []
};
const nodeInfo = await web3.eth.getNodeInfo();
if (nodeInfo.indexOf('OpenEthereum') >= 0) {
delete txParams.chainId;
}
} else { // EIP-1559 is not activated. Use a legacy transaction
txParams = {
from: OWNER,

View File

@ -58,8 +58,8 @@ describe('Candidates place stakes on themselves', () => {
const latestBlock = await getLatestBlock(web3);
if (latestBlock.baseFeePerGas) {
console.log(`latestBlock.baseFeePerGas = ${latestBlock.baseFeePerGas}`);
const netId = await web3.eth.net.getId();
const nodeInfo = await web3.eth.getNodeInfo();
const txParams = {
from: OWNER,
to: StakingTokenContract.address,
@ -71,6 +71,9 @@ describe('Candidates place stakes on themselves', () => {
data: StakingTokenContract.instance.methods.mint(candidate.staking, candidateTokensBN.toString()).encodeABI(),
accessList: []
};
if (nodeInfo.indexOf('OpenEthereum') >= 0) {
delete txParams.chainId;
}
const txHash = await sendRequest(`curl --data '{"method":"eth_sendTransaction","params":[${JSON.stringify(txParams)}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST ${web3.currentProvider.host} 2>/dev/null`);
let txReceipt;
while(!(txReceipt = await web3.eth.getTransactionReceipt(txHash))) {

View File

@ -14,7 +14,7 @@ module.exports = function (cmd) {
if (resp.hasOwnProperty('result')) {
resolve(resp.result);
} else {
reject(new Error('result is undefined'));
reject(new Error(`JSON RPC result is undefined. Response text: ${stdout}`));
}
});
})

View File

@ -61,8 +61,8 @@ function signTransaction(txMessage, txType, privateKey) {
} else {
v = web3.utils.toHex(sigObj.recid + 27 + chainId * 2 + 8);
}
const r = '0x' + signature.slice(0, 64);
const s = '0x' + signature.slice(64, 128);
const r = '0x' + signature.slice(0, 64).replace(/^0+/, '');
const s = '0x' + signature.slice(64, 128).replace(/^0+/, '');
const txMessageSigned = txType > 0 ? txMessage : txMessage.slice(0, 6);
txMessageSigned.push(v);