PythState.sol 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // contracts/State.sol
  2. // SPDX-License-Identifier: Apache 2
  3. pragma solidity ^0.8.0;
  4. import "./PythInternalStructs.sol";
  5. import "./PythDeprecatedStructs.sol";
  6. contract PythStorage {
  7. struct State {
  8. address wormhole;
  9. uint16 _deprecatedPyth2WormholeChainId; // Replaced by validDataSources/isValidDataSource
  10. bytes32 _deprecatedPyth2WormholeEmitter; // Ditto
  11. // After a backward-incompatible change in PriceFeed this mapping got deprecated.
  12. mapping(bytes32 => PythDeprecatedStructs.DeprecatedPriceInfoV1) _deprecatedLatestPriceInfoV1;
  13. // For tracking all active emitter/chain ID pairs
  14. PythInternalStructs.DataSource[] validDataSources;
  15. // (chainId, emitterAddress) => isValid; takes advantage of
  16. // constant-time mapping lookup for VM verification
  17. mapping(bytes32 => bool) isValidDataSource;
  18. uint singleUpdateFeeInWei;
  19. /// Maximum acceptable time period before price is considered to be stale.
  20. /// This includes attestation delay, block time, and potential clock drift
  21. /// between the source/target chains.
  22. uint validTimePeriodSeconds;
  23. // Governance data source. VAA messages from this source can change this contract
  24. // state. e.g., upgrade the contract, change the valid data sources, and more.
  25. PythInternalStructs.DataSource governanceDataSource;
  26. // Sequence number of the last executed governance message. Any governance message
  27. // with a lower or equal sequence number will be discarded. This prevents double-execution,
  28. // and also makes sure that messages are executed in the right order.
  29. uint64 lastExecutedGovernanceSequence;
  30. // Mapping of cached price information
  31. // priceId => PriceInfo
  32. mapping(bytes32 => PythDeprecatedStructs.DeprecatedPriceInfoV2) _deprecatedLatestPriceInfoV2;
  33. // Index of the governance data source, increased each time the governance data source
  34. // changes.
  35. uint32 governanceDataSourceIndex;
  36. // Mapping of cached price information
  37. // priceId => PriceInfo
  38. mapping(bytes32 => PythInternalStructs.PriceInfo) latestPriceInfo;
  39. }
  40. }
  41. contract PythState {
  42. PythStorage.State _state;
  43. }