Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contract): implement FraudProofRouter #4927

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

aroralanuk
Copy link
Contributor

@aroralanuk aroralanuk commented Dec 2, 2024

Description

  • Router to communicate fraud messages from the source chain to a destination chain (likely Ethereum), fetching the attributions from AttributeCheckpointFraud on source and storing them on the router on destination for a client contract like Symbiotic/Eigenlayer to read from.

Drive-by changes

Related issues

Backward compatibility

Testing

Copy link

changeset-bot bot commented Dec 2, 2024

⚠️ No Changeset found

Latest commit: 7baae7d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

solidity/contracts/libs/FraudMessage.sol Outdated Show resolved Hide resolved
solidity/contracts/libs/FraudMessage.sol Outdated Show resolved Hide resolved
solidity/contracts/middleware/FraudProofRouter.sol Outdated Show resolved Hide resolved
solidity/contracts/middleware/FraudProofRouter.sol Outdated Show resolved Hide resolved
Comment on lines 26 to 28
// store origin => signer => merkleTree => digest => {timestamp, fraudType}
mapping(uint32 origin => mapping(bytes32 signer => mapping(bytes32 merkleTree => mapping(bytes32 digest => Attribution))))
public fraudAttributions;
Copy link
Member

Choose a reason for hiding this comment

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

this is pretty redundant with the internals of the AttributeCheckpointFraud contract

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the remote chain doesn't know the internals of AttributeCheckpointFraud and it becomes easier for the client sdk or contract.

Copy link
Member

Choose a reason for hiding this comment

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

can we somehow merge these 2 contracts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's possible

@aroralanuk aroralanuk marked this pull request as ready for review December 3, 2024 10:25
@aroralanuk aroralanuk requested a review from yorhodes December 3, 2024 10:25
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Olympix Integrated Security found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

solidity/contracts/middleware/FraudProofRouter.sol Dismissed Show dismissed Hide dismissed
(
address signer,
bytes32 merkleTree,
bytes32 digest,

Check notice

Code scanning / Olympix Integrated Security

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables Low

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables
solidity/contracts/test/TestAttributeCheckpointFraud.sol Dismissed Show dismissed Hide dismissed
@@ -0,0 +1,128 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

Check notice

Code scanning / Olympix Integrated Security

Using an unbounded pragma for Solidity version may be unsafe if future versions introduce breaking changes. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unbounded-pragma Low

Using an unbounded pragma for Solidity version may be unsafe if future versions introduce breaking changes. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unbounded-pragma
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 77.68%. Comparing base (bb44f9b) to head (7baae7d).
Report is 50 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4927      +/-   ##
==========================================
+ Coverage   77.53%   77.68%   +0.14%     
==========================================
  Files         103      105       +2     
  Lines        2110     2142      +32     
  Branches      190      194       +4     
==========================================
+ Hits         1636     1664      +28     
- Misses        453      456       +3     
- Partials       21       22       +1     
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 80.12% <85.00%> (+0.31%) ⬆️

Copy link
Member

@yorhodes yorhodes left a comment

Choose a reason for hiding this comment

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

please add a changeset
you also need to change the base branch

solidity/contracts/libs/FraudMessage.sol Outdated Show resolved Hide resolved
Comment on lines 26 to 28
// store origin => signer => merkleTree => digest => {timestamp, fraudType}
mapping(uint32 origin => mapping(bytes32 signer => mapping(bytes32 merkleTree => mapping(bytes32 digest => Attribution))))
public fraudAttributions;
Copy link
Member

Choose a reason for hiding this comment

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

can we somehow merge these 2 contracts?

Attribution attribution
);

event LocalFraudProofReceived(

Check warning

Code scanning / Olympix Integrated Security

Test functions fail to assert the emission of expected events, potentially missing critical contract behaviors. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/missing-events-assertion Medium

Test functions fail to assert the emission of expected events, potentially missing critical contract behaviors. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/missing-events-assertion
_digest
);

require(attribution.timestamp != 0, "Attribution does not exist");

Check warning

Code scanning / Olympix Integrated Security

Test functions fail to verify specific revert reasons, potentially missing important contract behavior validation. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/missing-revert-reason-tests Medium

Test functions fail to verify specific revert reasons, potentially missing important contract behavior validation. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/missing-revert-reason-tests
Comment on lines +86 to +89
Attribution memory attribution = attributeCheckpointFraud.attributions(
_signer,
_digest
);
Copy link
Member

Choose a reason for hiding this comment

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

I thought you would literally merge these two contracts
as it stands the storage is still redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I did, but you still have 2 mappings

Copy link
Member

Choose a reason for hiding this comment

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

the AttributeCheckpointFraud.attributions mapping has redundant information with this contract's fraudAttributions[chainId]
I am proposing merging these contracts, having a single mapping, and a single storage location for this information

AttributeCheckpointFraud public immutable attributeCheckpointFraud;

// Mapping to store the fraud attributions for a given origin, signer, and digest for easy access for client contracts to aide slashing
mapping(uint32 origin => mapping(address signer => mapping(bytes32 digest => Attribution)))

Check warning

Code scanning / Olympix Integrated Security

Some state variables are not being fuzzed in test functions, potentially leaving vulnerabilities unexplored. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-variables Medium

Some state variables are not being fuzzed in test functions, potentially leaving vulnerabilities unexplored. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-variables
* @param _digest The digest associated with the fraud.
* @return The message ID of the sent fraud proof.
*/
function sendFraudProof(

Check failure

Code scanning / Olympix Integrated Security

Modifying state after making an external call may allow for reentrancy attacks. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy Critical

Modifying state after making an external call may allow for reentrancy attacks. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy
* @param _digest The digest associated with the fraud.
* @return The message ID of the sent fraud proof.
*/
function sendFraudProof(

Check notice

Code scanning / Olympix Integrated Security

Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events Low

Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events
bytes calldata _message
) internal override {
(
address signer,

Check notice

Code scanning / Olympix Integrated Security

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables Low

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables
(
address signer,
bytes32 digest,
Attribution memory attribution

Check notice

Code scanning / Olympix Integrated Security

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables Low

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Implement FraudProofRouter to relay fraud proof attribution results between chains
2 participants