Skip to content

temp mock pol#2868

Closed
rezzmah wants to merge 2 commits intomainfrom
mock-pol-reverting-after-10
Closed

temp mock pol#2868
rezzmah wants to merge 2 commits intomainfrom
mock-pol-reverting-after-10

Conversation

@rezzmah
Copy link
Copy Markdown
Contributor

@rezzmah rezzmah commented Aug 1, 2025

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "./ValidatorRegistry.sol";

/// @title SimplePoLDistributor
/// @notice Simple mock PoL distributor for testing bera-reth
/// @dev Updated to interact with ValidatorRegistry to test multi-contract state changes
contract SimplePoLDistributor {
    /// @notice System address that can call distributeFor (execution layer client)
    address private constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE;
    
    /// @notice The validator registry contract address (hardcoded for genesis deployment)
    ValidatorRegistry private constant VALIDATOR_REGISTRY = ValidatorRegistry(0x4200000000000000000000000000000000000043);
    
    /// @notice Event emitted when distributeFor is called
    event PoLDistributed(bytes pubkey);
    
    /// @notice Counter for total distributions
    uint256 public totalDistributions;
    
    /// @notice Error thrown when caller is not the system address
    error NotSystemAddress();
    
    /// @dev Modifier to restrict function access to system address.
    /// @dev This ensures only the execution layer client can call `distributeFor` function.
    modifier onlySystemCall() {
        if (msg.sender != SYSTEM_ADDRESS) {
            revert NotSystemAddress();
        }
        _;
    }
    
    /// @notice Main function that bera-reth will call
    /// @param pubkey The validator public key
    /// @dev Now calls the ValidatorRegistry to test multi-contract state changes
    function distributeFor(bytes calldata pubkey) external onlySystemCall {
        require(totalDistributions < 10, "Max distributions reached");
        // Update state in this contract
        totalDistributions++;
        
        // Call another contract to update its state
        // This tests whether system calls properly capture state changes from multiple contracts
        VALIDATOR_REGISTRY.recordValidatorActivity(pubkey);
        
        emit PoLDistributed(pubkey);
    }
}


// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/// @title ValidatorRegistry
/// @notice A simple registry contract that increments a counter when called
/// @dev This contract will be called by SimplePoLDistributor to test multi-contract state changes
contract ValidatorRegistry {
    /// @notice Simple counter that increments on each call
    uint256 public callCount;
    
    /// @notice Event emitted when the contract is called
    event RegistryCalled(uint256 newCount);
    
    /// @notice Records activity - simply increments counter and emits event
    function recordValidatorActivity(bytes calldata /* pubkey */) external {
        callCount++;
        emit RegistryCalled(callCount);
    }
}

@calbera
Copy link
Copy Markdown
Contributor

calbera commented Aug 11, 2025

@rezbera can you add the contract solidity source code in the contracts/src folder ? And then we should merge this

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.74%. Comparing base (344c4bd) to head (6009eca).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2868      +/-   ##
==========================================
+ Coverage   60.70%   60.74%   +0.03%     
==========================================
  Files         354      354              
  Lines       16647    16647              
==========================================
+ Hits        10106    10112       +6     
+ Misses       5752     5747       -5     
+ Partials      789      788       -1     

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@calbera
Copy link
Copy Markdown
Contributor

calbera commented Aug 11, 2025

Can probably close #2843 once this is resolved.

@rezzmah
Copy link
Copy Markdown
Contributor Author

rezzmah commented Aug 11, 2025

superced by #2878

@rezzmah rezzmah closed this Aug 11, 2025
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