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

WIP: build boson-kleros integration poc #488

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

0xartem
Copy link

@0xartem 0xartem commented Dec 13, 2022

This is a draft for integration between kleros and boson protocol. The code is for information purposes and should NOT be merged directly to the main.

The following miro board contains some diagrams to inform the integration exploration.

https://miro.com/app/board/uXjVPet6BvQ=/

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@0xartem 0xartem changed the title build boson-kleros integration poc WIP: build boson-kleros integration poc Dec 13, 2022
@cliffhall
Copy link
Contributor

cliffhall commented Dec 19, 2022

The following miro board contains some diagrams to inform the integration exploration.

https://miro.com/app/board/uXjVPet6BvQ=/

@0xartem Since the Miro board is not public (I don't have access to it even with my Redeemeum account) would you mind posting a picture of it here and also summarize the approach taken by these changes? It would be nice to have a big picture understanding of what's going on before reviewing the PR.

@0xartem
Copy link
Author

0xartem commented Dec 22, 2022

@cliffhall I am working on the BPIP. I will add the pictures there and a link to this PR.

Copy link
Contributor

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

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

Some comments about the implementation. Since it's not meant to be merged, I'm not requesting changes.

bytes32 _sigS,
uint8 _sigV
) external override disputesNotPaused nonReentrant {
function resolveDispute(uint256 _exchangeId, uint256 _percent) external override disputesNotPaused nonReentrant {
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in the BPIP discussion, changing this method:

  1. represents a breaking change that would require a major version rev to 3.0.0
  2. discards the signature, which is required to ensure that the two parties are in accord.

It could be added as an alternative method with a name like resolveDisputeWithProposal or something, but it's not clear why this is even part of this proposed implementation. The BPIP is about using Kleros to handle escalations. This comes prior to escalation and is not a prerequisite for such.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the comment @cliffhall. I am going to update the BPIP so we don't introduce the breaking change.

A new method is needed because Kleros requires two options to choose from. It means that escalation only makes sense when a buyer and a seller have proposals that don't match, like 50% and 70%.

A state of those proposals must be stored somewhere before the buyer escalates it to a DR.

@@ -193,6 +193,9 @@ contract BosonTypes {
struct Dispute {
uint256 exchangeId;
uint256 buyerPercent;
uint256 sellerPercent;
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the Dispute struct is dangerous. There are implications for existing storage.

  1. The new fields are not at the end of the struct, and so previously stored structs will be misinterpreted and/or clobbered when written to.
  2. Even if they were at the end of the struct, it isn't always safe to add members to structs, depending upon how those structs are stored, i.e., in arrays vs mappings.

For these reasons, we would more likely want to associate these new fields with the dispute via a mapping and not change the struct and all the client code (including the graph) that relies on its current shape.

Copy link
Author

Choose a reason for hiding this comment

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

Noted, will change it in the new PR.

bytes32 _sigS,
uint8 _sigV
) external;
function resolveDispute(uint256 _exchangeId, uint256 _percent) external;
Copy link
Contributor

Choose a reason for hiding this comment

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

See objections to this below on the DisputeHandlerFacet.

Copy link
Author

Choose a reason for hiding this comment

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

Added changes and Rationale to the BPIP

contracts/kleros/BosonKlerosConnector.sol Show resolved Hide resolved
*/
function rule(uint256 _disputeID, uint256 _ruling) external {
BosonCase memory bosonCase = klerosDisputeCases[_disputeID];
if (bosonCase.exchangeId == 0) revert InvalidExchangeError();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the emission of an Error required by Kleros? Otherwise this would need to be implemented as a revert reason. We discussed implementing formal Error types but we were too far along the development track to do that before deploying V2, so we're kind of stuck with the style.

We definitely shouldn't mix and match unless there's an absolute requirement.

That's said, it's in a client, which is a boundary contract that could conceivably be given a pass if there's no other option.

Copy link
Author

Choose a reason for hiding this comment

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

There is no such requirement from Kleros. It can be modified to match Boson coding style.

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.

None yet

3 participants