-
Notifications
You must be signed in to change notification settings - Fork 210
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(lazer/contracts/evm): Add fees for verification #2163
Open
darunrs
wants to merge
5
commits into
main
Choose a base branch
from
add-fees-to-lazer-evm-contract
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,36 @@ contract PythLazerTest is Test { | |
skip(2000); | ||
assert(!pythLazer.isValidSigner(address(2))); | ||
} | ||
|
||
function test_verify_with_fee() public { | ||
// Prepare dummy update and signer | ||
address trustedSigner = 0xEfEf56cD66896f6799A90A4e4d512C330c094e44; | ||
vm.prank(address(1)); | ||
pythLazer.updateTrustedSigner(trustedSigner, 3000000000000000); | ||
bytes | ||
memory update = hex"2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100"; | ||
|
||
uint256 fee = pythLazer.verification_fee(); | ||
|
||
address alice = makeAddr("alice"); | ||
vm.deal(alice, 1 ether); | ||
address bob = makeAddr("bob"); | ||
vm.deal(bob, 1 ether); | ||
|
||
// Alice provides appropriate fee | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to just bunch these all together. I can also make them separate unit tests too, but I liked the idea of making more than one call on an account and confirming their balance changes as expected. |
||
vm.prank(alice); | ||
pythLazer.verifyUpdate{value: fee}(update); | ||
assertEq(alice.balance, 1 ether - fee); | ||
|
||
// Alice overpays and is refunded | ||
vm.prank(alice); | ||
pythLazer.verifyUpdate{value: 0.5 ether}(update); | ||
assertEq(alice.balance, 1 ether - fee - fee); | ||
|
||
// Bob does not attach a fee | ||
vm.prank(bob); | ||
vm.expectRevert("Insufficient fee provided"); | ||
pythLazer.verifyUpdate(update); | ||
assertEq(bob.balance, 1 ether); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The storage is incremental in EVM. I recommend we leave room for more signers here so we can add more signers. A better thing to do is to transition from having a list of signers to a map of addressSigner to expiresAt.
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.
Just an FYI for this, by replacing it with a mapping, we seem to incur some costs:
I would rather increase the size to a comfortable size like 100, rather than change to a map which we would have issues working with. This is based on what I've learned so far, so I could be wrong on some of these things. Please do let me know if something is wrong in my considerations above.