Skip to content

[OAppCore] Suggested improvements for input validation and usability #1888

@ariessa

Description

@ariessa

Is your feature request related to a problem? Please describe.
When integrating OAppCore into a project, I discovered that setPeer accepts EID 0 as a valid endpoint ID. EID 0 is not a valid LayerZero endpoint (valid ranges are 30xxx for mainnet, 40xxx for testnet), which can lead to silent misconfigurations. Additionally, there's no validation to prevent setting the local endpoint as its own peer, no batch function for multi-chain deployments requiring multiple setPeer calls, and no event emitted when setDelegate is called.


Describe the solution you'd like

  1. Validate EID 0: Add require(_eid != 0) in setPeer to reject invalid endpoint IDs
  2. Prevent self-peer: Add require(_eid != endpoint.eid()) to prevent setting the local chain as a peer
  3. Batch peer setting: Add setPeers(uint32[] calldata _eids, bytes32[] calldata _peers) for gas-efficient multi-chain deployments
  4. Add hasPeer helper: A non-reverting view function to check if a peer is configured
  5. Emit DelegateSet event: Add observability for delegate changes in setDelegate
  6. Validate endpoint in constructor: Add require(_endpoint != address(0)) to catch deployment errors early

Describe alternatives you've considered
Currently implementing these as overrides in our inheriting contract:

function setPeer(uint32 _eid, bytes32 _peer) public override onlyOwner {
    require(_eid != 0, "Invalid endpoint ID");
    super.setPeer(_eid, _peer);
}

This works but requires every OApp integrator to implement the same validation logic. Upstream fixes would benefit all users and ensure consistent behavior across the ecosystem.


Additional context

  • EID numbering convention: 30xxx (mainnet), 40xxx (testnet)
  • EID 0 represents an uninitialized/invalid state
  • Multi-chain protocols often deploy to 5+ chains, making batch setPeers particularly valuable
  • The existing _getPeerOrRevert internal function already treats bytes32(0) as invalid, suggesting EID 0 should also be rejected at the setter level

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions