Add set fee to tests + add some sanity checks (#350)
* Add set fee to tests + add some sanity checks * Add fee to evm relayer
This commit is contained in:
parent
e4160b2f08
commit
d3d10f2ce2
|
@ -1,3 +1,8 @@
|
|||
const { assert } = require("chai");
|
||||
const governance = require("@pythnetwork/xc-governance-sdk");
|
||||
const assertVaaPayloadEquals = require("../../scripts/assertVaaPayloadEquals");
|
||||
const { assert } = require("chai");
|
||||
|
||||
const loadEnv = require("../../scripts/loadEnv");
|
||||
loadEnv("../../");
|
||||
|
||||
|
@ -13,5 +18,18 @@ const PythUpgradable = artifacts.require("PythUpgradable");
|
|||
*/
|
||||
module.exports = async function (_deployer) {
|
||||
const proxy = await PythUpgradable.deployed();
|
||||
|
||||
const setFeeInstruction = new governance.SetFeeInstruction(
|
||||
governance.CHAINS.unset, // All the chains
|
||||
BigInt(1),
|
||||
BigInt(0),
|
||||
).serialize();
|
||||
|
||||
console.log("SetFeeInstruction: 0x", setFeeInstruction.toString('hex'));
|
||||
|
||||
assertVaaPayloadEquals(setFeeVaa, setFeeInstruction);
|
||||
|
||||
await proxy.executeGovernanceInstruction(setFeeVaa);
|
||||
|
||||
assert.equal((await proxy.singleUpdateFeeInWei()).toString(), "1");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
const createLocalnetGovernanceVaa = require("../../scripts/createLocalnetGovernanceVaa");
|
||||
const assertVaaPayloadEquals = require("../../scripts/assertVaaPayloadEquals");
|
||||
const governance = require("@pythnetwork/xc-governance-sdk");
|
||||
const { assert } = require("chai");
|
||||
|
||||
const loadEnv = require("../../scripts/loadEnv");
|
||||
loadEnv("../../");
|
||||
|
||||
|
||||
const PythUpgradable = artifacts.require("PythUpgradable");
|
||||
|
||||
/**
|
||||
*
|
||||
* This change:
|
||||
* - Executes the VAA to set the fee to 1 wei
|
||||
*/
|
||||
module.exports = async function (_deployer) {
|
||||
const setFeeInstruction = new governance.SetFeeInstruction(
|
||||
governance.CHAINS.unset, // All the chains
|
||||
BigInt(1),
|
||||
BigInt(0),
|
||||
).serialize();
|
||||
|
||||
console.log("SetFeeInstruction: 0x", setFeeInstruction.toString('hex'));
|
||||
|
||||
const setFeeVaa = createLocalnetGovernanceVaa(
|
||||
setFeeInstruction,
|
||||
2
|
||||
);
|
||||
|
||||
assertVaaPayloadEquals(setFeeVaa, setFeeInstruction);
|
||||
|
||||
const proxy = await PythUpgradable.deployed();
|
||||
await proxy.executeGovernanceInstruction(setFeeVaa);
|
||||
|
||||
assert.equal((await proxy.singleUpdateFeeInWei()).toString(), "1");
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
"version": "1.1.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@certusone/wormhole-sdk-wasm": "^0.0.1",
|
||||
"@openzeppelin/contracts": "^4.5.0",
|
||||
"@openzeppelin/contracts-upgradeable": "^4.5.2",
|
||||
"@pythnetwork/pyth-sdk-solidity": "^1.0.1",
|
||||
|
@ -419,6 +420,15 @@
|
|||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@certusone/wormhole-sdk-wasm": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk-wasm/-/wormhole-sdk-wasm-0.0.1.tgz",
|
||||
"integrity": "sha512-LdIwLhOyr4pPs2jqYubqC7d4UkqYBX0EG/ppspQlW3qlVE0LZRMrH6oVzzLMyHtV0Rw7O9sIKzORW/T3mrJv2w==",
|
||||
"dependencies": {
|
||||
"@types/long": "^4.0.2",
|
||||
"@types/node": "^18.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@chainsafe/truffle-plugin-abigen": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@chainsafe/truffle-plugin-abigen/-/truffle-plugin-abigen-0.0.1.tgz",
|
||||
|
@ -8121,10 +8131,9 @@
|
|||
"optional": true
|
||||
},
|
||||
"node_modules/@types/long": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz",
|
||||
"integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==",
|
||||
"dev": true
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
|
||||
"integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA=="
|
||||
},
|
||||
"node_modules/@types/mime": {
|
||||
"version": "1.3.2",
|
||||
|
@ -8149,9 +8158,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "17.0.21",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz",
|
||||
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ=="
|
||||
"version": "18.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.0.tgz",
|
||||
"integrity": "sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w=="
|
||||
},
|
||||
"node_modules/@types/npm": {
|
||||
"version": "2.0.32",
|
||||
|
@ -14358,12 +14367,6 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ganache-core/node_modules/@types/node": {
|
||||
"version": "14.14.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.20.tgz",
|
||||
"integrity": "sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ganache-core/node_modules/@types/pbkdf2": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz",
|
||||
|
@ -36710,6 +36713,15 @@
|
|||
"to-fast-properties": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@certusone/wormhole-sdk-wasm": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk-wasm/-/wormhole-sdk-wasm-0.0.1.tgz",
|
||||
"integrity": "sha512-LdIwLhOyr4pPs2jqYubqC7d4UkqYBX0EG/ppspQlW3qlVE0LZRMrH6oVzzLMyHtV0Rw7O9sIKzORW/T3mrJv2w==",
|
||||
"requires": {
|
||||
"@types/long": "^4.0.2",
|
||||
"@types/node": "^18.0.3"
|
||||
}
|
||||
},
|
||||
"@chainsafe/truffle-plugin-abigen": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@chainsafe/truffle-plugin-abigen/-/truffle-plugin-abigen-0.0.1.tgz",
|
||||
|
@ -43715,10 +43727,9 @@
|
|||
"optional": true
|
||||
},
|
||||
"@types/long": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz",
|
||||
"integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==",
|
||||
"dev": true
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
|
||||
"integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA=="
|
||||
},
|
||||
"@types/mime": {
|
||||
"version": "1.3.2",
|
||||
|
@ -43743,9 +43754,9 @@
|
|||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "17.0.21",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz",
|
||||
"integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ=="
|
||||
"version": "18.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.0.tgz",
|
||||
"integrity": "sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w=="
|
||||
},
|
||||
"@types/npm": {
|
||||
"version": "2.0.32",
|
||||
|
@ -49105,12 +49116,6 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.14.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.20.tgz",
|
||||
"integrity": "sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/pbkdf2": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@certusone/wormhole-sdk-wasm": "^0.0.1",
|
||||
"@openzeppelin/contracts": "^4.5.0",
|
||||
"@openzeppelin/contracts-upgradeable": "^4.5.2",
|
||||
"@pythnetwork/pyth-sdk-solidity": "^1.0.1",
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
const { importCoreWasm, setDefaultWasm } = require("@certusone/wormhole-sdk-wasm");
|
||||
setDefaultWasm("node");
|
||||
const { assert } = require("chai");
|
||||
|
||||
module.exports = async function assertVaaPayloadEquals(vaaHexString, expectedPayloadBuffer) {
|
||||
const { parse_vaa } = await importCoreWasm();
|
||||
|
||||
if (vaaHexString.startsWith("0x")) {
|
||||
vaaHexString = vaaHexString.substring(2);
|
||||
}
|
||||
|
||||
const vaaPayload = Buffer.from(parse_vaa(Buffer.from(vaaHexString, 'hex')).payload);
|
||||
|
||||
assert(expectedPayloadBuffer.equals(vaaPayload), "The VAA payload is not equal to the expected payload");
|
||||
}
|
|
@ -45,8 +45,10 @@ export class EvmRelay implements Relay {
|
|||
? await this.queryMany(priceIds)
|
||||
: null;
|
||||
|
||||
const updateFee = await this.p2wContract.getUpdateFee(1);
|
||||
|
||||
let tx = this.p2wContract
|
||||
.updatePriceFeeds(["0x" + signedVAAs[i]], { gasLimit: 2000000 })
|
||||
.updatePriceFeeds(["0x" + signedVAAs[i]], { gasLimit: 2000000, value: updateFee })
|
||||
.then(async (pending) => {
|
||||
let receipt = await pending.wait();
|
||||
logger.info(
|
||||
|
|
Loading…
Reference in New Issue