-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add refundOnFraud #73
Conversation
Future-proofs the comparison. With field-by-field comparison, when a new field is added to the Ticket struct, ticket comparison must be updated.
import { L2, L2DepositStruct } from "../contract-types/L2"; | ||
import { TicketsWithIndex } from "../src/types"; | ||
import { hashTickets, signData } from "../src/utils"; | ||
|
||
const gasLimit = 30_000_000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but we could throw this in a common file shared between tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, let's do that once we have more than one test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🌋
Co-authored-by: Alex Gap <[email protected]>
bytes32 message = keccak256( | ||
abi.encode(TicketsWithIndex(fraudStartNonce, fraudTickets)) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ought to be factored into some common utils library contract, since the exact same computation needs to be computed in both L1 and L2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #77
(bool sent, ) = tickets[i].l1Recipient.call{ | ||
value: tickets[i].value | ||
}(""); | ||
require(sent, "Failed to send Ether"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this is a critical security vulnerability. Alice can submit a ticket with a contract address that rejects all incoming eth transfers. This prevents everyone from calling refundOnFraud
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good call. Contract fund distribution needs to be refactored to:
- Factor out this logic.
- FIx the security concern
- Add erc20 support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #78
Fixes #59.
There are 2 cases of fraud:
t
is created on deposit. The ticket is authorized as part of a batch. The liquidity provider (LP) also signs another batch that contains a ticket with the same index ast
but different data.2. Same as above butt
is never authorized.In the second case, a new batch is created on fraud proof. The batch includes all tickets from the last authorized ticket (exclusive) to the ticket that is being "cheated" (inclusive).On more thought, it doesn't seem like we need to take care of the second case. The customer can: