From 36db34f211e86a47b50825eda1db510384dd456f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:09:32 -0500 Subject: [PATCH] Bridge testnet (#448) (#449) * reporter module * use legacy dec for tips and commision rates * re-add max commision rate check * chore: mv legacy_dec.go to types/legacy_dec.go * minor refactor for clarity * checkpoint to pull main * use LgeacyDec for withdraws * remove old BigUint to LegacyDec fcns * linting * add test * linting * separate blobstream testnet child contract --------- Co-authored-by: danflo27 Co-authored-by: akrem (cherry picked from commit e80017304048f9b591234a2f941ace880b7c7666) Co-authored-by: tkernell --- evm/contracts/bridge/BlobstreamO.sol | 30 -------------------- evm/contracts/testing/BlobstreamOTestnet.sol | 26 +++++++++++++++++ evm/contracts/testing/TellorPlayground.sol | 5 ++++ 3 files changed, 31 insertions(+), 30 deletions(-) create mode 100644 evm/contracts/testing/BlobstreamOTestnet.sol diff --git a/evm/contracts/bridge/BlobstreamO.sol b/evm/contracts/bridge/BlobstreamO.sol index 3d1e2de32..e94555ca6 100644 --- a/evm/contracts/bridge/BlobstreamO.sol +++ b/evm/contracts/bridge/BlobstreamO.sol @@ -45,7 +45,6 @@ contract BlobstreamO is ECDSA { uint256 public validatorTimestamp; /// Timestamp of the block where validator set is updated. address public deployer; /// Address that deployed the contract. bool public initialized; /// True if the contract is initialized. - bool public isTestnet = true; /// True if the contract is on testnet. /*Events*/ event ValidatorSetUpdated(uint256 _powerThreshold, uint256 _validatorTimestamp, bytes32 _validatorSetHash); @@ -59,7 +58,6 @@ contract BlobstreamO is ECDSA { error NotConsensusValue(); error NotDeployer(); error NotGuardian(); - error NotTestnet(); error StaleValidatorSet(); error SuppliedValidatorSetInvalid(); error ValidatorSetNotStale(); @@ -120,34 +118,6 @@ contract BlobstreamO is ECDSA { lastValidatorSetCheckpoint = _validatorSetCheckpoint; } - /// @notice This function is called by the guardian to reset the validator set - /// on testnet. Not to be used on mainnet. - /// @param _powerThreshold Amount of voting power needed to approve operations. - /// @param _validatorTimestamp The timestamp of the block where validator set is updated. - /// @param _validatorSetCheckpoint The hash of the validator set. - function guardianResetValidatorSetTestnet( - uint256 _powerThreshold, - uint256 _validatorTimestamp, - bytes32 _validatorSetCheckpoint - ) external { - if (msg.sender != guardian) { - revert NotGuardian(); - } - if (!isTestnet) { - revert NotTestnet(); - } - powerThreshold = _powerThreshold; - validatorTimestamp = _validatorTimestamp; - lastValidatorSetCheckpoint = _validatorSetCheckpoint; - } - - function guardianThrowAwayReset() external { - if (msg.sender != guardian) { - revert NotGuardian(); - } - isTestnet = false; - } - /// @notice This updates the validator set by checking that the validators /// in the current validator set have signed off on the new validator set. /// @param _newValidatorSetHash The hash of the new validator set. diff --git a/evm/contracts/testing/BlobstreamOTestnet.sol b/evm/contracts/testing/BlobstreamOTestnet.sol new file mode 100644 index 000000000..475226db5 --- /dev/null +++ b/evm/contracts/testing/BlobstreamOTestnet.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "../bridge/BlobstreamO.sol"; + +contract BlobstreamOTestnet is BlobstreamO { + constructor(address _guardian) BlobstreamO(_guardian) {} + + /// @notice This function is called by the guardian to reset the validator set + /// on testnet. Not to be used on mainnet. + /// @param _powerThreshold Amount of voting power needed to approve operations. + /// @param _validatorTimestamp The timestamp of the block where validator set is updated. + /// @param _validatorSetCheckpoint The hash of the validator set. + function guardianResetValidatorSetTestnet( + uint256 _powerThreshold, + uint256 _validatorTimestamp, + bytes32 _validatorSetCheckpoint + ) external { + if (msg.sender != guardian) { + revert NotGuardian(); + } + powerThreshold = _powerThreshold; + validatorTimestamp = _validatorTimestamp; + lastValidatorSetCheckpoint = _validatorSetCheckpoint; + } +} \ No newline at end of file diff --git a/evm/contracts/testing/TellorPlayground.sol b/evm/contracts/testing/TellorPlayground.sol index 44b8688a5..f4dea5908 100644 --- a/evm/contracts/testing/TellorPlayground.sol +++ b/evm/contracts/testing/TellorPlayground.sol @@ -183,6 +183,11 @@ contract TellorPlayground { oracleMintRecipient = _oracle; } + function resetTotalSupply(uint256 totalSupply_) external { + require(msg.sender == deployer, "only deployer can reset total supply"); + _totalSupply = totalSupply_; + } + /** * @dev A mock function to submit a value to be read without reporter staking needed * @param _queryId the ID to associate the value to