-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix: ToB-22 (using msg.value
in a loop)
#1453
Conversation
WalkthroughThe changes primarily revolve around the addition of a Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Files selected for processing (6)
- packages/contracts-core/contracts/client/BaseClient.sol (1 hunks)
- packages/contracts-core/contracts/client/MessageRecipient.sol (1 hunks)
- packages/contracts-core/contracts/client/PingPongClient.sol (1 hunks)
- packages/contracts-core/contracts/client/TestClient.sol (1 hunks)
- packages/contracts-core/test/harnesses/client/BaseClientHarness.t.sol (1 hunks)
- packages/contracts-core/test/suite/client/BaseClient.t.sol (2 hunks)
Files skipped from review due to trivial changes (2)
- packages/contracts-core/contracts/client/TestClient.sol
- packages/contracts-core/test/harnesses/client/BaseClientHarness.t.sol
Additional comments (Suppressed): 8
packages/contracts-core/contracts/client/PingPongClient.sol (1)
- 125-135: The
_sendBaseMessage
function call has been updated to use named arguments and includes a newtipsValue
parameter. Ensure that thetipsValue
is correctly set and used throughout the codebase. Also, the hardcodedMessageRequest
values should be reviewed and replaced with dynamic values if necessary.packages/contracts-core/test/suite/client/BaseClient.t.sol (3)
59-66: The
sendBaseMessage
function now includestipsValue
as an argument. Ensure that the function call is updated everywhere in the codebase. Also, verify that thetipsValue
is correctly used in the function.78-82: The
sendBaseMessage
function now includestipsValue
as an argument. Ensure that the function call is updated everywhere in the codebase. Also, verify that thetipsValue
is correctly used in the function.84-97: A new test function
test_sendBaseMessage_tipsValueNotMsgValue
is added to test the scenario wheretipsValue
is not equal tomsg.value
. Ensure that the test covers all edge cases and the assertions are correct.packages/contracts-core/contracts/client/MessageRecipient.sol (1)
- 76-95: The function signature of
_sendBaseMessage
has been updated to include a new parametertipsValue
. This parameter is used as thevalue
argument when calling thesendBaseMessage
function of theInterfaceOrigin
contract. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that thetipsValue
is always less than or equal tomsg.value
to prevent any potential underflow errors.- return InterfaceOrigin(origin).sendBaseMessage{value: msg.value}( + return InterfaceOrigin(origin).sendBaseMessage{value: tipsValue}( destination_, recipient, optimisticPeriod, _encodeRequest(request), content );packages/contracts-core/contracts/client/BaseClient.sol (3)
78-101: The function signature of
_sendBaseMessage
has been updated to include a new parametertipsValue
. This parameter represents the tips to be paid for sending a message. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that thetipsValue
is being correctly calculated and passed in all instances where_sendBaseMessage
is called.93-100: The
_sendBaseMessage
function now uses named arguments and passes a struct to improve code readability. This is a good practice as it makes the code easier to understand and maintain.91-91: The return statement is calling
_sendBaseMessage
recursively. Ensure that this is the intended behavior and that there is a base case to prevent infinite recursion. If there is another function with the same name but different parameters, consider renaming one of the functions to avoid confusion.
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1453 +/- ##
===================================================
- Coverage 50.69210% 50.68798% -0.00413%
===================================================
Files 356 356
Lines 24274 24274
Branches 267 267
===================================================
- Hits 12305 12304 -1
Misses 10775 10775
- Partials 1194 1195 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Description
msg.value
inMessageRecipient
. This should allow sending more than one message in tx for any contract that inherits from it.Summary by CodeRabbit
tipsValue
parameter to the_sendBaseMessage
function in theBaseClient
,MessageRecipient
,PingPongClient
,TestClient
,BaseClientHarness
, andBaseClientTest
contracts. This allows users to specify the tips to be paid for sending a message.sendMessage
function inPingPongClient
andTestClient
contracts to use named arguments and pass a structMessageRequest
to the_sendBaseMessage
function, improving code readability.test_sendBaseMessage_tipsValueNotMsgValue
inBaseClientTest
to validate the scenario wheretipsValue
is not equal tomsg.value
.