Skip to content

Commit

Permalink
Add preliminary LLO contracts (#11990)
Browse files Browse the repository at this point in the history
* Add preliminary LLO contracts

NOTE: These are not the final contracts (not even close). They do not
implement any kind of blue/green deployment and will likely change a
lot.

What they are, is sufficient to run benchmarking.

* Run prettier on new contracts

* Revert "Run prettier on new contracts"

This reverts commit 739ed422616242b565ea1b046027b33bdc14d6cc.

* run prettier
  • Loading branch information
samsondav authored Feb 12, 2024
1 parent 0001494 commit 8fd6226
Show file tree
Hide file tree
Showing 12 changed files with 3,753 additions and 4 deletions.
10 changes: 8 additions & 2 deletions contracts/scripts/native_solc_compile_all_llo-feeds
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ compileContract llo-feeds/VerifierProxy.sol
compileContract llo-feeds/FeeManager.sol
compileContract llo-feeds/RewardManager.sol

#Test | Mocks

# Test | Mocks
compileContract llo-feeds/test/mocks/ErroredVerifier.sol
compileContract llo-feeds/test/mocks/ExposedVerifier.sol
compileContract llo-feeds/test/mocks/ExposedVerifier.sol

# LLO
compileContract llo-feeds/dev/ChannelConfigStore.sol
compileContract llo-feeds/dev/ChannelVerifier.sol
compileContract llo-feeds/dev/test/mocks/ExposedChannelVerifier.sol
104 changes: 104 additions & 0 deletions contracts/src/v0.8/llo-feeds/dev/ChannelConfigStore.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {ConfirmedOwner} from "../../shared/access/ConfirmedOwner.sol";
import {IChannelConfigStore} from "./interfaces/IChannelConfigStore.sol";
import {TypeAndVersionInterface} from "../../interfaces/TypeAndVersionInterface.sol";

contract ChannelConfigStore is ConfirmedOwner, IChannelConfigStore, TypeAndVersionInterface {
mapping(uint32 => ChannelDefinition) private s_channelDefinitions;

// mapping(bytes32 => ChannelConfiguration) private s_channelProductionConfigurations;
// mapping(bytes32 => ChannelConfiguration) private s_channelStagingConfigurations;

event NewChannelDefinition(uint32 channelId, ChannelDefinition channelDefinition);
event ChannelDefinitionRemoved(uint32 channelId);
// event NewProductionConfig(ChannelConfiguration channelConfig);
// event NewStagingConfig(ChannelConfiguration channelConfig);
event PromoteStagingConfig(uint32 channelId);

error OnlyCallableByEOA();
error StagingConfigAlreadyPromoted();
error EmptyStreamIDs();
error ZeroReportFormat();
error ZeroChainSelector();
error ChannelDefinitionNotFound();

constructor() ConfirmedOwner(msg.sender) {}

// function setStagingConfig(bytes32 configDigest, ChannelConfiguration calldata channelConfig) external onlyOwner {
// s_channelStagingConfigurations[channelId] = channelConfig;

// emit NewStagingConfig(channelConfig);
// }

//// this will trigger the following:
//// - offchain ShouldRetireCache will start returning true for the old (production)
//// protocol instance
//// - once the old production instance retires it will generate a handover
//// retirement report
//// - the staging instance will become the new production instance once
//// any honest oracle that is on both instances forward the retirement
//// report from the old instance to the new instace via the
//// PredecessorRetirementReportCache
////
//// Note: the promotion flow only works if the previous production instance
//// is working correctly & generating reports. If that's not the case, the
//// owner is expected to "setProductionConfig" directly instead. This will
//// cause "gaps" to be created, but that seems unavoidable in such a scenario.
// function promoteStagingConfig(bytes32 configDigest) external onlyOwner {
// ChannelConfiguration memory stagingConfig = s_channelStagingConfigurations[channelId];

// if(stagingConfig.channelConfigId.length == 0) {
// revert StagingConfigAlreadyPromoted();
// }

// s_channelProductionConfigurations[channelId] = s_channelStagingConfigurations[channelId];

// emit PromoteStagingConfig(channelId);
// }

function addChannel(uint32 channelId, ChannelDefinition calldata channelDefinition) external onlyOwner {
if (channelDefinition.streamIDs.length == 0) {
revert EmptyStreamIDs();
}

if (channelDefinition.chainSelector == 0) {
revert ZeroChainSelector();
}

if (channelDefinition.reportFormat == 0) {
revert ZeroReportFormat();
}

s_channelDefinitions[channelId] = channelDefinition;

emit NewChannelDefinition(channelId, channelDefinition);
}

function removeChannel(uint32 channelId) external onlyOwner {
if (s_channelDefinitions[channelId].streamIDs.length == 0) {
revert ChannelDefinitionNotFound();
}

delete s_channelDefinitions[channelId];

emit ChannelDefinitionRemoved(channelId);
}

function getChannelDefinitions(uint32 channelId) external view returns (ChannelDefinition memory) {
if (msg.sender != tx.origin) {
revert OnlyCallableByEOA();
}

return s_channelDefinitions[channelId];
}

function typeAndVersion() external pure override returns (string memory) {
return "ChannelConfigStore 0.0.0";
}

function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
return interfaceId == type(IChannelConfigStore).interfaceId;
}
}
Loading

0 comments on commit 8fd6226

Please sign in to comment.