Skip to content

Commit

Permalink
Bridge testnet (#448) (#449)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: akrem <[email protected]>
(cherry picked from commit e800173)

Co-authored-by: tkernell <[email protected]>
  • Loading branch information
github-actions[bot] and tkernell authored Nov 24, 2024
1 parent 49238bb commit 36db34f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
30 changes: 0 additions & 30 deletions evm/contracts/bridge/BlobstreamO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -59,7 +58,6 @@ contract BlobstreamO is ECDSA {
error NotConsensusValue();
error NotDeployer();
error NotGuardian();
error NotTestnet();
error StaleValidatorSet();
error SuppliedValidatorSetInvalid();
error ValidatorSetNotStale();
Expand Down Expand Up @@ -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.
Expand Down
26 changes: 26 additions & 0 deletions evm/contracts/testing/BlobstreamOTestnet.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
5 changes: 5 additions & 0 deletions evm/contracts/testing/TellorPlayground.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 36db34f

Please sign in to comment.