-
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
Entity clarification #35
Conversation
per_multicall/src/ExpressRelay.sol
Outdated
uint256 feeSplitRelayer | ||
) { | ||
// TODO: move this to ExpressRelayState? | ||
state.feeSplitPrecision = 10 ** 18; |
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.
If this is gonna be constant, let's just make it a constant.
|
||
contract ExpressRelayStorage { | ||
struct State { | ||
// address of admin of express relay |
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.
some of these comments do not help in understanding the fields. Comments here should explain what each variable "does" instead of explaining what each variable "is".
@@ -602,6 +608,22 @@ contract ExpressRelayIntegrationTest is | |||
assertEq(balancePost, balancePre + totalBid); | |||
} | |||
|
|||
function testSetRelayerByAdmin() public { |
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.
Let's move these to a different file. These are not integration tests anymore. I think we should have another test suite that only tests the express relay (actual unit tests) with some dummy contracts to call on top.
per_multicall/src/ExpressRelay.sol
Outdated
uint256 feeRelayerNumerator = (totalBid - feeProtocol) * | ||
state.feeSplitRelayer; | ||
if (feeRelayerNumerator > 0) { | ||
uint256 feeRelayer = feeRelayerNumerator / state.feeSplitPrecision; |
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.
why not calculate this first and check feeRelayer > 0
?
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.
little bit of gas costs savings. in practice this is gonna be minimal, can just divide in same line
|
||
function testSetRelayerByAdmin() public { | ||
address newRelayer = makeAddr("newRelayer"); | ||
vm.prank(admin, admin); |
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.
Is it necessary to set the second argument? We don't do any sort of checks based on tx.origin. Same for all the other pranks
|
||
function testSetRelayerByNonAdminFail() public { | ||
address newRelayer = makeAddr("newRelayer"); | ||
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector)); |
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 should work without the encodeWithSelector
too. same for the rest of the tests
uint256 feeSplitProtocolDefaultPost = expressRelay | ||
.getFeeProtocolDefault(); | ||
|
||
assertEq(feeSplitProtocolDefaultPre, feeSplitProtocolDefault); |
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 feeSplitProtocolDefault
variable is a bit magical here. Also this assertion doesn't seem to be testing the setFeeProtocolDefault
function
uint256 fee = feeSplitProtocolDefaultPre + 1; | ||
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector)); | ||
vm.prank(relayer, relayer); | ||
expressRelay.setFeeProtocolDefault(fee); |
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.
we expect unauthorized
here so you can just pass in 0 and simplify the test a bit.
expressRelay.setFeeProtocolDefault(fee); | ||
} | ||
|
||
function testSetFeeProtocolByAdmin() public { |
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.
all the above comments apply to the other getter/setter tests too
per_multicall/src/ExpressRelay.sol
Outdated
state.admin = admin; | ||
state.relayer = relayer; | ||
|
||
if (feeSplitProtocolDefault > state.feeSplitPrecision) { |
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 checking logic can become a separate function
assertEq(balancesAPost.collateral, balancesAPre.collateral); | ||
assertEq(balancesAPost.debt, balancesAPre.debt); | ||
|
||
assertFailedExternal(multicallStatuses[0], "InvalidLiquidation()"); |
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.
let's use InvalidLiquidation.selector
here too.
This really helps with refactoring. My IDE was dumb and when I renamed one of these errors, it didn't automatically changed the string version.
*/ | ||
function setUpContracts() public { | ||
// instantiate multicall contract with ExpressRelay operator as the deployer | ||
// TODO: change admin to xc-admin |
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.
what does this comment mean here?
/** | ||
* @notice setUp function - sets up the contracts, wallets, tokens, oracle feeds, and vaults for the test | ||
* | ||
* This function creates the entire environment for the start of each test. It is called before each test. |
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.
I think this is mostly a repetition of the comments on each of these functions which is unnecessary.
* | ||
* ExpressRelayTestSetup also defines helper methods that are commonly used in the test suites. | ||
*/ | ||
contract ExpressRelayTestSetup is |
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.
Many of the functions here can still be splited into smaller functions. Not necessarily in this PR but some time in the future
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.
Thanks for the refactor on the rust side, looks much better now. Please fix the comments before merging.
auction-server/src/auction.rs
Outdated
winner_bids.iter().map(|b| b.target_contract).collect(), | ||
winner_bids.iter().map(|b| b.target_calldata.clone()).collect(), | ||
winner_bids.iter().map(|b| b.bid_amount).collect(), | ||
winner_bids.iter().map(|b| MulticallData{target_contract: b.target_contract, target_calldata: b.target_calldata.clone(), bid_amount: b.bid_amount }).collect() |
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.
you can implement the From trait for MulticallData so that the conversion logic is just implemented once.
// split of the non-protocol fees to be paid to the relayer | ||
uint256 feeSplitRelayer; | ||
// precision for fee splits | ||
uint256 feeSplitPrecision; |
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.
what I mean is to remove it from the state and just have it as a constant in our contracts.
operator
intorelayer
andadmin
onlyAdmin
andonlyRelayer
modifiers and apply them to methodsExpressRelay
multicall
MulticallData
struct to enforce equal length of the fields inmulticall