Update contract initializer (#397)

* Update contract initializer
* Reduce optimizer runs to 1000
This commit is contained in:
Ali Behjati 2022-11-29 12:11:49 +01:00 committed by GitHub
parent 51514dcd9b
commit 45ce07725f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 509 additions and 553 deletions

View File

@ -7,3 +7,4 @@ GOVERNANCE_CHAIN_ID=0x1
GOVERNANCE_EMITTER=0x5635979a221c34931e32620b9293a463065555ea71fe97cd6237ade875b12e9e
MIGRATION_12_SET_FEE_VAA=0x01000000020d00c0749e12c5a921d38934aea2025e2748b589bc887b071649ad7e55c9356c942f11f0a731b57b4540136d3fdf0fa76a79b2c270cfb56457544ebcdc2bfa1de1bf00034855f23564ec5d9540c0a45d38ddbfdafe5ad7864e5e539f8233b9d1c35e78654fbb48bfde2ba995437bfb38b92be272224b34d8df2df54d8e478eba53f637e00106af3e7ba2f6891b79564270b549ac93f81d02cca85d80ea3bdf2fa0b5fc9831f04088cc644b65e37853d84150f5e7577946c1bf5b58fdce779c5890506a4a639800083b2fed7f4ae9ebe1be7d952be53ffeebc42f03ab2ebbb6d10fcbee34530857083537ec32154cf4c6c298401828145a095eca8d901c6bd34fd3dcbe51a95d9bf40109bd66527f6553a8fd3429305d4a18822d53104b299c9df15ec9437c75bdab9c3c7f55f7c8993283972e5c98a837f5c79e1ccd234330235829f745e97aa1ede88e010afa65862b5b74eab87b72d91cc026629bd82928424a7b85191fcc430cd5cd2ceb25438aa8a346c26585e2c74d00f460e9225e764969e218203fd9f9c41b3cdb2b010b95a4707053581ba586f4463bb6592420942beb1ef5060d7ff87f8980c0cc33526499643f25eb61939b6245a10cd1deb998ff3cf2a30586d336ab7b57424c5419000c12547c3b942944106d126151036f58d7382cdaea2c5bdd12fa5cb359ff0bf56c470ef714ff33313e3d76b36e12f76378d747417ad40cc73b1ad9050d40e50633010dbc7b13e8175715273342e7577018a5d2d22ee83c4916eac8996886568145244e2be027c0739593d10104f55661d4589ff1d45deb80918324e7888db7e0419f03000e12e244ada40eb8d3c1bdce80d4abd5efa9c57cd5bafc1b123f0539c2106aa8474cd250b1d7fffaeb922e6c54a3ce050fc221177d1c56cc784a4e8c76925a3804000f476f02d40ceaa24ee311f50f0486b047ec3ba4d985e771f08941ab81e184bb275e50a0cc2d738b178ef2c982db28e1eac5eaf87658716a5c3959689240ffd7670010f0a374448b3abc05f1cb765f7d8c790d1c34044a8145380557d42077f9bb027d6e29e013360809702e7a8a407b6abd63036d269d1a1abe66f69a7f73d0bb9209001210be861c7f88caa19c8afcdbd2c9fda6c35c68933e7d3a470b916fa4d47fa62868cf38c022764d542ed9a4ddba81ae093aa1e1ecad88f79c9d879e5484bb9b5b01634878210000000000015635979a221c34931e32620b9293a463065555ea71fe97cd6237ade875b12e9e000000000000000c015054474d0103000000000000000000010000000000000000
SINGLE_UPDATE_FEE_IN_WEI=1

View File

@ -7,3 +7,4 @@ GOVERNANCE_CHAIN_ID=0x1
GOVERNANCE_EMITTER=0x63278d271099bfd491951b3e648f08b1c71631e4a53674ad43e8f9f98068c385
MIGRATION_12_SET_FEE_VAA=0x010000000001006c844a6f378ddc46842e61552db124bf384d7fb2410584cdc8f3be8cc864b2d169cd9640f23c72e80ac119f10614bb22570731ce9cd8999501cb9178ad7b27e80063471aea00000000000163278d271099bfd491951b3e648f08b1c71631e4a53674ad43e8f9f98068c3850000000000000006015054474d0103000000000000000000010000000000000000
SINGLE_UPDATE_FEE_IN_WEI=1

View File

@ -19,3 +19,4 @@ PYTHNET_CHAIN_ID= # 0x1a
PYTHNET_EMITTER= # 0xa27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6
GOVERNANCE_CHAIN_ID= # 0x1
GOVERNANCE_EMITTER= # 0x63278d271099bfd491951b3e648f08b1c71631e4a53674ad43e8f9f98068c385
SINGLE_UPDATE_FEE_IN_WEI=0

View File

@ -30,3 +30,4 @@ GOVERNANCE_CHAIN_ID=0x1
GOVERNANCE_EMITTER=0x0000000000000000000000000000000000000000000000000000000000001234
WORMHOLE_CHAIN_NAME=ethereum
SINGLE_UPDATE_FEE_IN_WEI=1

View File

@ -14,12 +14,37 @@ import "./PythInternalStructs.sol";
abstract contract Pyth is PythGetters, PythSetters, AbstractPyth {
function _initialize(
address wormhole,
uint16 pyth2WormholeChainId,
bytes32 pyth2WormholeEmitter
uint16[] calldata dataSourceEmitterChainIds,
bytes32[] calldata dataSourceEmitterAddresses,
uint validTimePeriodSeconds,
uint singleUpdateFeeInWei
) internal {
setWormhole(wormhole);
setPyth2WormholeChainId(pyth2WormholeChainId);
setPyth2WormholeEmitter(pyth2WormholeEmitter);
require(
dataSourceEmitterChainIds.length ==
dataSourceEmitterAddresses.length,
"data source arguments should have the same length"
);
for (uint i = 0; i < dataSourceEmitterChainIds.length; i++) {
PythInternalStructs.DataSource memory ds = PythInternalStructs
.DataSource(
dataSourceEmitterChainIds[i],
dataSourceEmitterAddresses[i]
);
require(
!PythGetters.isValidDataSource(ds.chainId, ds.emitterAddress),
"Data source already added"
);
_state.isValidDataSource[hashDataSource(ds)] = true;
_state.validDataSources.push(ds);
}
PythSetters.setValidTimePeriodSeconds(validTimePeriodSeconds);
PythSetters.setSingleUpdateFeeInWei(singleUpdateFeeInWei);
}
function updatePriceBatchFromVm(bytes calldata encodedVm) private {

View File

@ -13,16 +13,6 @@ contract PythGetters is PythState {
return IWormhole(_state.wormhole);
}
/// Deprecated, use `validDataSources` instead
function pyth2WormholeChainId() public view returns (uint16) {
return _state._deprecatedPyth2WormholeChainId;
}
/// Deprecated, use `validDataSources` instead
function pyth2WormholeEmitter() public view returns (bytes32) {
return _state._deprecatedPyth2WormholeEmitter;
}
function latestPriceInfo(
bytes32 priceId
) internal view returns (PythInternalStructs.PriceInfo memory info) {

View File

@ -6,14 +6,6 @@ pragma solidity ^0.8.0;
import "./PythState.sol";
contract PythSetters is PythState {
function setPyth2WormholeChainId(uint16 chainId) internal {
_state._deprecatedPyth2WormholeChainId = chainId;
}
function setPyth2WormholeEmitter(bytes32 emitterAddr) internal {
_state._deprecatedPyth2WormholeEmitter = emitterAddr;
}
function setWormhole(address wh) internal {
_state.wormhole = payable(wh);
}

View File

@ -21,13 +21,21 @@ contract PythUpgradable is
{
function initialize(
address wormhole,
uint16 pyth2WormholeChainId,
bytes32 pyth2WormholeEmitter
uint16[] calldata dataSourceEmitterChainIds,
bytes32[] calldata dataSourceEmitterAddresses,
uint validTimePeriodSeconds,
uint singleUpdateFeeInWei
) public initializer {
__Ownable_init();
__UUPSUpgradeable_init();
Pyth._initialize(wormhole, pyth2WormholeChainId, pyth2WormholeEmitter);
Pyth._initialize(
wormhole,
dataSourceEmitterChainIds,
dataSourceEmitterAddresses,
validTimePeriodSeconds,
singleUpdateFeeInWei
);
}
/// Privileged function to specify additional data sources in the contract

View File

@ -28,19 +28,21 @@ abstract contract PythTestUtils is Test, WormholeTestUtils {
new bytes(0)
);
PythUpgradable pyth = PythUpgradable(address(proxy));
uint16[] memory emitterChainIds = new uint16[](1);
emitterChainIds[0] = SOURCE_EMITTER_CHAIN_ID;
bytes32[] memory emitterAddresses = new bytes32[](1);
emitterAddresses[0] = SOURCE_EMITTER_ADDRESS;
pyth.initialize(
wormhole,
SOURCE_EMITTER_CHAIN_ID,
SOURCE_EMITTER_ADDRESS
emitterChainIds,
emitterAddresses,
60, // Valid time period in seconds
1 // single update fee in wei
);
// TODO: All the logic below should be moved to the initializer
pyth.addDataSource(SOURCE_EMITTER_CHAIN_ID, SOURCE_EMITTER_ADDRESS);
pyth.updateSingleUpdateFeeInWei(1);
pyth.updateValidTimePeriodSeconds(60);
pyth.updateGovernanceDataSource(
GOVERNANCE_EMITTER_CHAIN_ID,
GOVERNANCE_EMITTER_ADDRESS,

View File

@ -1,7 +1,7 @@
[profile.default]
solc_version = '0.8.4'
optimizer = true
optimizer_runs = 5000
optimizer_runs = 1000
src = 'contracts'
# We put the tests into the forge-test directory (instead of test) so that
# truffle doesn't try to build them

View File

@ -2,26 +2,49 @@ const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const WormholeReceiver = artifacts.require("WormholeReceiver");
const pyth2WormholeChainId = process.env.SOLANA_CHAIN_ID;
const pyth2WormholeEmitter = process.env.SOLANA_EMITTER;
const { deployProxy } = require("@openzeppelin/truffle-upgrades");
const tdr = require("truffle-deploy-registry");
const { CONTRACTS } = require("@certusone/wormhole-sdk");
const { assert } = require("chai");
console.log("pyth2WormholeEmitter: " + pyth2WormholeEmitter);
console.log("pyth2WormholeChainId: " + pyth2WormholeChainId);
const emitterChainIds = [
process.env.SOLANA_CHAIN_ID,
process.env.PYTHNET_CHAIN_ID,
];
const emitterAddresses = [
process.env.SOLANA_EMITTER,
process.env.PYTHNET_EMITTER,
];
const validTimePeriodSeconds = Number(process.env.VALID_TIME_PERIOD_SECONDS);
const singleUpdateFeeInWei = Number(process.env.SINGLE_UPDATE_FEE_IN_WEI);
console.log("emitterChainIds: " + emitterChainIds);
console.log("emitterAddresses: " + emitterAddresses);
console.log("validTimePeriodSeconds: " + validTimePeriodSeconds);
console.log("singleUpdateFeeInWei: " + singleUpdateFeeInWei);
module.exports = async function (deployer, network) {
const cluster = process.env.CLUSTER;
const chainName = process.env.WORMHOLE_CHAIN_NAME;
assert(cluster !== undefined && chainName !== undefined);
const wormholeBridgeAddress =
CONTRACTS[cluster.toUpperCase()][chainName].core;
assert(wormholeBridgeAddress !== undefined);
console.log("Wormhole bridge address: " + wormholeBridgeAddress);
// Deploy the proxy. This will return an instance of PythUpgradable,
// with the address field corresponding to the fronting ERC1967Proxy.
let proxyInstance = await deployProxy(
PythUpgradable,
[
(await WormholeReceiver.deployed()).address,
pyth2WormholeChainId,
pyth2WormholeEmitter,
wormholeBridgeAddress,
emitterChainIds,
emitterAddresses,
validTimePeriodSeconds,
singleUpdateFeeInWei,
],
{ deployer }
);

View File

@ -1,21 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Adds multiple emitter/chain ID support
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.addDataSource(
await proxy.pyth2WormholeChainId(),
await proxy.pyth2WormholeEmitter()
);
};

View File

@ -1,20 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Adds fee for updating prices. Default value in Ethereum is 0, so the value after upgrade will be 0.
* - Emits multiple events when a price gets updated. This can be used by off-chain applications to monitor
* the contract activity.
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,20 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Updates the interface, removes `getPrevPriceUnsafe` and adds two functions
* `getLatestAvailablePriceUnsafe` and `getLatestAvailablePriceWithinDuration`
* to replace its behaviour in a more elegant way.
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,29 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const validTimePeriodSeconds = Number(process.env.VALID_TIME_PERIOD_SECONDS);
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Makes validTimePeriodSeconds configurable and sets its value.
* The value depends on the network latency and block time. So
* it is read from the network env file.
*
* During this upgrade two transaction will be sent and in between validTimePeriodSeconds
* will be zero and `getCurrentPrice` will reject. At the time of doing this migration
* Pyth is not deployed on mainnet and current hard-coded value is large for some
* networks and it's better to reject rather than accept a price old in the past.
*
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.updateValidTimePeriodSeconds(validTimePeriodSeconds);
};

View File

@ -1,25 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Version 0.1.0
*
* This change:
* - Updates the interface, adds `updatePriceFeedsIfNecessary` that wraps
* `updatePriceFeeds` and rejects if the price update is not necessary.
* - Changes some memory modifiers to improve gas efficiency.
* - Changes staleness logic to be included in the sdk and bring
* more clarity to the existing code.
* - Adds version to the contract (which is hard coded)
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,19 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const pythnetChainId = process.env.PYTHNET_CHAIN_ID;
const pythnetEmitter = process.env.PYTHNET_EMITTER;
console.log("pythnetEmitter: " + pythnetEmitter);
console.log("pythnetChainId: " + pythnetChainId);
/**
* This change:
* - Adds PythNet data source.
*/
module.exports = async function (_deployer) {
const proxy = await PythUpgradable.deployed();
await proxy.addDataSource(pythnetChainId, pythnetEmitter);
};

View File

@ -1,43 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const governance = require("@pythnetwork/xc-governance-sdk");
const PythUpgradable = artifacts.require("PythUpgradable");
const wormholeChainName = process.env.WORMHOLE_CHAIN_NAME;
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
const { assert } = require("chai");
/**
* Version 1.1.0
*
* This change:
* - Use pyth-sdk-solidity 1.0.0 which simplifies the PriceFeed interface
*/
module.exports = async function (deployer) {
assert(governance.CHAINS[wormholeChainName] !== undefined);
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
// This step is not needed in new contracts as the contract up to this step is up to date.
// The code is left here to be an example of how to create a governance instruction for upgrade.
// If you wish to create an upgrade step, do it in 2 migration steps. First step should be like below
// that deploys a new contract and creates the governance instruction payload. Second step should
// take the VAA as an env variable and execute it.
// const proxy = await PythUpgradable.deployed();
// const newImpl = (await deployProxyImpl(PythUpgradable, { deployer, unsafeSkipStorageCheck: true }, proxy.address)).impl;
// console.log(`New implementation address is: ${newImpl}. Please sign and execute the following encoded ` +
// `governance instruction to upgrade it.`);
// const instructionBuffer = new governance.EthereumUpgradeContractInstruction(
// governance.CHAINS[wormholeChainName],
// new governance.HexString20Bytes(newImpl)
// ).serialize();
// console.log(`Governance instruction: 0x${instructionBuffer.toString('hex')}`);
};

View File

@ -2,17 +2,26 @@ const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const pyth2WormholeChainId = process.env.SOLANA_CHAIN_ID;
const pyth2WormholeEmitter = process.env.SOLANA_EMITTER;
const { deployProxy } = require("@openzeppelin/truffle-upgrades");
const tdr = require("truffle-deploy-registry");
const { CONTRACTS } = require("@certusone/wormhole-sdk");
const { assert } = require("chai");
console.log("pyth2WormholeEmitter: " + pyth2WormholeEmitter);
console.log("pyth2WormholeChainId: " + pyth2WormholeChainId);
const emitterChainIds = [
process.env.SOLANA_CHAIN_ID,
process.env.PYTHNET_CHAIN_ID,
];
const emitterAddresses = [
process.env.SOLANA_EMITTER,
process.env.PYTHNET_EMITTER,
];
const validTimePeriodSeconds = Number(process.env.VALID_TIME_PERIOD_SECONDS);
const singleUpdateFeeInWei = Number(process.env.SINGLE_UPDATE_FEE_IN_WEI);
console.log("emitterChainIds: " + emitterChainIds);
console.log("emitterAddresses: " + emitterAddresses);
console.log("validTimePeriodSeconds: " + validTimePeriodSeconds);
console.log("singleUpdateFeeInWei: " + singleUpdateFeeInWei);
module.exports = async function (deployer, network) {
const cluster = process.env.CLUSTER;
@ -30,7 +39,13 @@ module.exports = async function (deployer, network) {
// with the address field corresponding to the fronting ERC1967Proxy.
let proxyInstance = await deployProxy(
PythUpgradable,
[wormholeBridgeAddress, pyth2WormholeChainId, pyth2WormholeEmitter],
[
wormholeBridgeAddress,
emitterChainIds,
emitterAddresses,
validTimePeriodSeconds,
singleUpdateFeeInWei,
],
{ deployer }
);

View File

@ -1,21 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Adds multiple emitter/chain ID support
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.addDataSource(
await proxy.pyth2WormholeChainId(),
await proxy.pyth2WormholeEmitter()
);
};

View File

@ -1,20 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Adds fee for updating prices. Default value in Ethereum is 0, so the value after upgrade will be 0.
* - Emits multiple events when a price gets updated. This can be used by off-chain applications to monitor
* the contract activity.
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,20 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Updates the interface, removes `getPrevPriceUnsafe` and adds two functions
* `getLatestAvailablePriceUnsafe` and `getLatestAvailablePriceWithinDuration`
* to replace its behaviour in a more elegant way.
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,29 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const validTimePeriodSeconds = Number(process.env.VALID_TIME_PERIOD_SECONDS);
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Makes validTimePeriodSeconds configurable and sets its value.
* The value depends on the network latency and block time. So
* it is read from the network env file.
*
* During this upgrade two transaction will be sent and in between validTimePeriodSeconds
* will be zero and `getCurrentPrice` will reject. At the time of doing this migration
* Pyth is not deployed on mainnet and current hard-coded value is large for some
* networks and it's better to reject rather than accept a price old in the past.
*
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.updateValidTimePeriodSeconds(validTimePeriodSeconds);
};

View File

@ -1,25 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Version 0.1.0
*
* This change:
* - Updates the interface, adds `updatePriceFeedsIfNecessary` that wraps
* `updatePriceFeeds` and rejects if the price update is not necessary.
* - Changes some memory modifiers to improve gas efficiency.
* - Changes staleness logic to be included in the sdk and bring
* more clarity to the existing code.
* - Adds version to the contract (which is hard coded)
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,19 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const pythnetChainId = process.env.PYTHNET_CHAIN_ID;
const pythnetEmitter = process.env.PYTHNET_EMITTER;
console.log("pythnetEmitter: " + pythnetEmitter);
console.log("pythnetChainId: " + pythnetChainId);
/**
* This change:
* - Adds PythNet data source.
*/
module.exports = async function (_deployer) {
const proxy = await PythUpgradable.deployed();
await proxy.addDataSource(pythnetChainId, pythnetEmitter);
};

View File

@ -8,8 +8,6 @@ const governanceEmitter = process.env.GOVERNANCE_EMITTER;
console.log("governanceEmitter: " + governanceEmitter);
console.log("governanceChainId: " + governanceChainId);
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Version 1.0.0 - 1st step
*
@ -19,10 +17,6 @@ const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.updateGovernanceDataSource(
governanceChainId,
governanceEmitter,

View File

@ -1,44 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const governance = require("@pythnetwork/xc-governance-sdk");
const createLocalnetGovernanceVaa = require("../../scripts/createLocalnetGovernanceVaa");
const PythUpgradable = artifacts.require("PythUpgradable");
const governanceChainId = process.env.GOVERNANCE_CHAIN_ID;
const governanceEmitter = process.env.GOVERNANCE_EMITTER;
console.log("governanceEmitter: " + governanceEmitter);
console.log("governanceChainId: " + governanceChainId);
const {
deployProxyImpl,
} = require("@openzeppelin/truffle-upgrades/dist/utils");
/**
* Version 1.1.0
*
* This change:
* - Use pyth-sdk-solidity 1.0.0 which simplifies the PriceFeed interface
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
const newImpl = (
await deployProxyImpl(
PythUpgradable,
{ deployer, unsafeSkipStorageCheck: true },
proxy.address
)
).impl;
console.log(newImpl);
await proxy.executeGovernanceInstruction(
createLocalnetGovernanceVaa(
new governance.EthereumUpgradeContractInstruction(
governance.CHAINS.ethereum,
new governance.HexString20Bytes(newImpl)
).serialize(),
1
)
);
};

View File

@ -8,6 +8,8 @@ const Wormhole = artifacts.require("Wormhole");
const pyth2WormholeChainId = process.env.SOLANA_CHAIN_ID;
const pyth2WormholeEmitter = process.env.SOLANA_EMITTER;
const validTimePeriodSeconds = Number(process.env.VALID_TIME_PERIOD_SECONDS);
const singleUpdateFeeInWei = Number(process.env.SINGLE_UPDATE_FEE_IN_WEI);
const { deployProxy } = require("@openzeppelin/truffle-upgrades");
@ -22,8 +24,10 @@ module.exports = async function (deployer) {
PythUpgradable,
[
(await Wormhole.deployed()).address,
pyth2WormholeChainId,
pyth2WormholeEmitter,
[pyth2WormholeChainId],
[pyth2WormholeEmitter],
validTimePeriodSeconds,
singleUpdateFeeInWei,
],
{ deployer }
);

View File

@ -1,21 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Adds multiple emitter/chain ID support
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.addDataSource(
await proxy.pyth2WormholeChainId(),
await proxy.pyth2WormholeEmitter()
);
};

View File

@ -1,20 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Adds fee for updating prices. Default value in Ethereum is 0, so the value after upgrade will be 0.
* - Emits multiple events when a price gets updated. This can be used by off-chain applications to monitor
* the contract activity.
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,20 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Updates the interface, removes `getPrevPriceUnsafe` and adds two functions
* `getLatestAvailablePriceUnsafe` and `getLatestAvailablePriceWithinDuration`
* to replace its behaviour in a more elegant way.
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -1,29 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const validTimePeriodSeconds = Number(process.env.VALID_TIME_PERIOD_SECONDS);
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* This change:
* - Makes validTimePeriodSeconds configurable and sets its value.
* The value depends on the network latency and block time. So
* it is read from the network env file.
*
* During this upgrade two transaction will be sent and in between validTimePeriodSeconds
* will be zero and `getCurrentPrice` will reject. At the time of doing this migration
* Pyth is not deployed on mainnet and current hard-coded value is large for some
* networks and it's better to reject rather than accept a price old in the past.
*
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.updateValidTimePeriodSeconds(validTimePeriodSeconds);
};

View File

@ -1,25 +0,0 @@
const loadEnv = require("../../scripts/loadEnv");
loadEnv("../../");
const PythUpgradable = artifacts.require("PythUpgradable");
const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
/**
* Version 0.1.0
*
* This change:
* - Updates the interface, adds `updatePriceFeedsIfNecessary` that wraps
* `updatePriceFeeds` and rejects if the price update is not necessary.
* - Changes some memory modifiers to improve gas efficiency.
* - Changes staleness logic to be included in the sdk and bring
* more clarity to the existing code.
* - Adds version to the contract (which is hard coded)
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
};

View File

@ -19,10 +19,6 @@ const { upgradeProxy } = require("@openzeppelin/truffle-upgrades");
*/
module.exports = async function (deployer) {
const proxy = await PythUpgradable.deployed();
await upgradeProxy(proxy.address, PythUpgradable, {
deployer,
unsafeSkipStorageCheck: true,
});
await proxy.updateGovernanceDataSource(
governanceChainId,
governanceEmitter,

View File

@ -21,6 +21,7 @@
"ganache-cli": "^6.12.1",
"jsonfile": "^4.0.0",
"solc": "^0.8.4",
"truffle-contract-size": "^2.0.1",
"web3": "^1.2.2",
"web3-eth-abi": "^1.2.2",
"web3-utils": "^1.2.2"
@ -12958,6 +12959,25 @@
"node": ">=6"
}
},
"node_modules/cli-table": {
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.11.tgz",
"integrity": "sha512-IqLQi4lO0nIB4tcdTpN4LCB9FI3uqrJZK7RC515EnhZ6qBaglkIgICb1wjeAqpdoOabm1+SuQtkXIPdYC93jhQ==",
"dependencies": {
"colors": "1.0.3"
},
"engines": {
"node": ">= 0.2.0"
}
},
"node_modules/cli-table/node_modules/colors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
"integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw==",
"engines": {
"node": ">=0.1.90"
}
},
"node_modules/cli-util": {
"version": "1.1.27",
"resolved": "https://registry.npmjs.org/cli-util/-/cli-util-1.1.27.tgz",
@ -13598,7 +13618,6 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -35196,8 +35215,7 @@
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
"dev": true
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
},
"node_modules/set-immediate-shim": {
"version": "1.0.1",
@ -36443,6 +36461,199 @@
"node": ">=4"
}
},
"node_modules/truffle-contract-size": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/truffle-contract-size/-/truffle-contract-size-2.0.1.tgz",
"integrity": "sha512-AIKPwHPC/1pZwtVjgUcgcK23k6gWxKhn4ZnKLr339uieb94UgAUeIwGUkfc87T+0lqgC6ePY7YhsFeoZK2YEsA==",
"dependencies": {
"cli-table": "^0.3.1",
"yargs": "^15.3.1"
}
},
"node_modules/truffle-contract-size/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/truffle-contract-size/node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"engines": {
"node": ">=6"
}
},
"node_modules/truffle-contract-size/node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/truffle-contract-size/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/truffle-contract-size/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/truffle-contract-size/node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/truffle-contract-size/node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/truffle-contract-size/node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"node_modules/truffle-contract-size/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q=="
},
"node_modules/truffle-contract-size/node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
},
"node_modules/truffle-contract-size/node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/truffle-contract-size/node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/truffle-deploy-registry": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/truffle-deploy-registry/-/truffle-deploy-registry-0.5.1.tgz",
@ -51356,6 +51567,21 @@
"dev": true,
"optional": true
},
"cli-table": {
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.11.tgz",
"integrity": "sha512-IqLQi4lO0nIB4tcdTpN4LCB9FI3uqrJZK7RC515EnhZ6qBaglkIgICb1wjeAqpdoOabm1+SuQtkXIPdYC93jhQ==",
"requires": {
"colors": "1.0.3"
},
"dependencies": {
"colors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
"integrity": "sha512-pFGrxThWcWQ2MsAz6RtgeWe4NK2kUE1WfsrvvlctdII745EW9I0yflqhe7++M5LEc7bV2c/9/5zc8sFcpL0Drw=="
}
}
},
"cli-util": {
"version": "1.1.27",
"resolved": "https://registry.npmjs.org/cli-util/-/cli-util-1.1.27.tgz",
@ -51904,8 +52130,7 @@
"decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
"dev": true
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
},
"decimal.js": {
"version": "10.4.2",
@ -70675,8 +70900,7 @@
"set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
"dev": true
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
},
"set-immediate-shim": {
"version": "1.0.1",
@ -72461,6 +72685,156 @@
}
}
},
"truffle-contract-size": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/truffle-contract-size/-/truffle-contract-size-2.0.1.tgz",
"integrity": "sha512-AIKPwHPC/1pZwtVjgUcgcK23k6gWxKhn4ZnKLr339uieb94UgAUeIwGUkfc87T+0lqgC6ePY7YhsFeoZK2YEsA==",
"requires": {
"cli-table": "^0.3.1",
"yargs": "^15.3.1"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
},
"cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"requires": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
}
},
"locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"requires": {
"p-locate": "^4.1.0"
}
},
"p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"requires": {
"p-try": "^2.0.0"
}
},
"p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"requires": {
"p-limit": "^2.2.0"
}
},
"p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ=="
},
"path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
},
"require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"requires": {
"ansi-regex": "^5.0.1"
}
},
"which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q=="
},
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
},
"yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"requires": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
}
},
"yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
}
}
}
},
"truffle-deploy-registry": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/truffle-deploy-registry/-/truffle-deploy-registry-0.5.1.tgz",

View File

@ -40,6 +40,7 @@
"ganache-cli": "^6.12.1",
"jsonfile": "^4.0.0",
"solc": "^0.8.4",
"truffle-contract-size": "^2.0.1",
"web3": "^1.2.2",
"web3-eth-abi": "^1.2.2",
"web3-utils": "^1.2.2"

View File

@ -45,18 +45,12 @@ contract("Pyth", function () {
beforeEach(async function () {
this.pythProxy = await deployProxy(PythUpgradable, [
(await Wormhole.deployed()).address,
testPyth2WormholeChainId,
testPyth2WormholeEmitter,
[testPyth2WormholeChainId],
[testPyth2WormholeEmitter],
60, // Validity time in seconds
0, // single update fee in wei
]);
await this.pythProxy.addDataSource(
testPyth2WormholeChainId,
testPyth2WormholeEmitter
);
// Setting the validity time to 60 seconds
await this.pythProxy.updateValidTimePeriodSeconds(60);
// Setting the governance data source to 0x1 (solana) and some random emitter address
await this.pythProxy.updateGovernanceDataSource(
testGovernanceChainId,

View File

@ -230,13 +230,17 @@ module.exports = {
settings: {
optimizer: {
enabled: true,
runs: 5000,
runs: 1000,
},
},
},
},
plugins: ["@chainsafe/truffle-plugin-abigen", "truffle-plugin-verify"],
plugins: [
"@chainsafe/truffle-plugin-abigen",
"truffle-plugin-verify",
"truffle-contract-size",
],
api_keys: {
etherscan: process.env.ETHERSCAN_KEY,