Skip to content

Conversation

andrejrakic
Copy link
Collaborator

This PR adds support for toggling between on-chain and off-chain billing mechanisms in the DataStreamsLocalSimulator contract.

Usage

// Existing customers - no changes needed!
DataStreamsLocalSimulator simulator = new DataStreamsLocalSimulator();
// Defaults to on-chain billing (existing behavior)

// For off-chain billing (new chains like Monad)
simulator.enableOffChainBilling();

// Switch back to on-chain billing if needed
simulator.enableOnChainBilling();

// Consumer contracts can check current state
address feeManager = address(verifierProxy.s_feeManager());
if (feeManager != address(0)) {
    // On-chain billing active
} else {
    // Off-chain billing active
}

@andrejrakic andrejrakic self-assigned this Oct 2, 2025
@andrejrakic andrejrakic requested a review from Copilot October 2, 2025 14:21
@andrejrakic andrejrakic changed the title Data Streams billing mechanism DEVREL-144 : Data Streams billing mechanism Oct 2, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the ability to toggle between on-chain and off-chain billing mechanisms in the DataStreamsLocalSimulator contract to support new chains like Monad that don't have FeeManager contracts deployed.

  • Adds feeManagerEnabled state variable and toggle functions to switch between billing modes
  • Maintains backward compatibility by defaulting to on-chain billing
  • Updates the configuration method to return the current billing state

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/data-streams/DataStreamsLocalSimulator.sol Implements billing mechanism toggle functionality with state tracking and fee manager management
test/smoke/data-streams/BillingMechanisms.t.sol Adds comprehensive tests for both billing mechanisms and toggle functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@andrejrakic andrejrakic requested a review from Copilot October 2, 2025 15:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@andrejrakic andrejrakic marked this pull request as ready for review October 2, 2025 15:25
@andrejrakic andrejrakic requested a review from a team as a code owner October 2, 2025 15:25
Copy link
Contributor

@zeuslawyer zeuslawyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
all comments are raised only to prompt thinking to see if there are improvements we should be considering.

LinkToken internal immutable i_linkToken;

/// @notice Whether fee manager is enabled (can be toggled after deployment)
bool public feeManagerEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we help newbies make the connection in their minds that feeManager == on chain? right now, the literal wording suggests different things but actually the feemanager is an onchain-only primitive but this may not be obvious to most devs.

bool public feeManagerEnabled;

constructor() {
// Default to on-chain billing for backward compatibility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per previous - note the comment and the var name suggest two different things (we know its connected but the end user cannot be expected to know)

* @dev This simulates chains that don't have FeeManager contracts deployed
*/
function enableOffChainBilling() external {
if (feeManagerEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue may be fixed by renaming feeManagerEnabled to onChainBillingEnabled and then the next line .setFeeManager(...) having a comment to explain the connection That way the boolean var is descriptive.

revert FeeManagerRequired(
"On-chain billing is active but your contract is using off-chain billing mechanism. "
"Either call simulator.enableOffChainBilling() or provide fee token address in parameterPayload. "
"See: https://docs.chain.link/data-streams/tutorials/evm-onchain-report-verification"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

if (!hasFeeManager && hasParameterPayload) {
revert FeeManagerNotExpected(
"Off-chain billing is active but your contract is providing parameterPayload for on-chain billing. "
"Either call simulator.enableOnChainBilling() or pass empty bytes as parameterPayload. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, would it revert on-chain if they passed an unnecessary parameterPayload?


// Verify fee manager is deployed by default
assertFalse(address(mockFeeManager_) == address(0), "Fee manager should be deployed by default");
assertEq(address(mockVerifierProxy_.s_feeManager()), address(mockFeeManager_), "Fee manager should be set on verifier proxy");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertEq(address(mockVerifierProxy_.s_feeManager()), address(mockFeeManager_),

is there any risk that this assertEq could pass incorrectly if both are address(0)s and thats the bug?

@andrejrakic andrejrakic requested a review from Copilot October 9, 2025 13:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 14 out of 20 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants