-
Notifications
You must be signed in to change notification settings - Fork 31
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
OpenZeppelin defender fixes #211
Conversation
d9b819d
to
7a26993
Compare
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.
👍 These are all great.
Left one super small nit, and one comment about how we'll need to update the E2E test that is failing.
tests/flows/basic_send_receive.go
Outdated
deliveryReceipt.Logs, | ||
subnetAInfo.TeleporterMessenger.ParseReceiptReceived) | ||
Expect(err).Should(BeNil()) | ||
Expect(receiptEvent.MessageID).Should(Equal(expectedReceiptID)) |
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 the issue here is that, depending on the order that the tests are run in, the receipt queues have pre-existing state prior to a test starting. This makes it difficult to assert that a specific message will have a specific receipt at a given index.
2023-12-22T00:26:56.5997803Z <*big.Int | 0xc0001c3360>: {neg: false, abs: [4]}
2023-12-22T00:26:56.5998247Z to equal
2023-12-22T00:26:56.5999061Z <*big.Int | 0xc00044c7a0>: {neg: false, abs: [5]}�[0m
2023-12-22T00:26:56.6001273Z �[38;5;9mIn �[1m[It]�[0m�[38;5;9m at: �[1m/home/runner/work/teleporter/teleporter/tests/flows/basic_send_receive.go:105�[0m �[38;5;243m@ 12/22/23 00:26:56.599�[0m
2023-12-22T00:26:56.6002668Z
2023-12-22T00:26:56.6003052Z �[38;5;9mFull Stack Trace�[0m
2023-12-22T00:26:56.6004080Z github.com/ava-labs/teleporter/tests/flows.BasicSendReceive({0x1edd8c0, 0xc0012f5c20})
2023-12-22T00:26:56.6005544Z /home/runner/work/teleporter/teleporter/tests/flows/basic_send_receive.go:105 +0xac2
2023-12-22T00:26:56.6007069Z github.com/ava-labs/teleporter/tests/local.glob..func3.6()
2023-12-22T00:26:56.6008395Z /home/runner/work/teleporter/teleporter/tests/local/e2e_test.go:78 +0x27
2023-12-22T00:26:56.6010518Z < Exit �[1m[It]�[0m Send a message from Subnet A to Subnet B, and one from B to A �[38;5;243m- /home/runner/work/teleporter/teleporter/tests/local/e2e_test.go:77 @ 12/22/23 00:26:56.599 (7.104s)�[0m
2023-12-22T00:26:56.6014665Z �[38;5;9m• [FAILED] [7.104 seconds]�[0m
2023-12-22T00:26:56.6015121Z [Teleporter integration tests]
2023-12-22T00:26:56.6015971Z �[38;5;243m/home/runner/work/teleporter/teleporter/tests/local/e2e_test.go:58�[0m
2023-12-22T00:26:56.6017402Z �[38;5;9m�[1m[It] Send a message from Subnet A to Subnet B, and one from B to A�[0m
2023-12-22T00:26:56.6018549Z �[38;5;243m/home/runner/work/teleporter/teleporter/tests/local/e2e_test.go:77�[0m
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 have a semi-hacky workaround for this in the send specific receipts test here, which involves sending messages to clear the receipt queues prior to proceeding with a test. This is only done in the case of a local network, which is ensure to have a reasonable receipt queue size.
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.
added a check for the ReceiptReceived
event emission
60589b6
to
3eab0a9
Compare
INativeMinter private immutable _nativeMinter = | ||
INativeMinter public constant NATIVE_MINTER = |
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.
Definitely agree with the change to constant vs immutable here. Is there a gas-usage benefit the making it 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.
no gas benefits, I'm going to change it back to private.
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.
nvm updated back to public, to keep in convention with our other Warp precompile declarations
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
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, just one question about named return parameters.
} | ||
|
||
/** | ||
* @dev Returns the outstanding receipts for the given chain ID that should be included in the next message sent. | ||
*/ | ||
function getOutstandingReceiptsToSend(TeleporterMessageReceiptQueue storage queue) | ||
internal | ||
returns (TeleporterMessageReceipt[] memory result) | ||
returns (TeleporterMessageReceipt[] memory) |
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 agree that we should remove named return parameters for the sake of readability, but I'm curious if there are any gas benefits one way or the other? The OZ report does not specify.
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.
from the gas reports didn't notice gas changes, think that makes sense since under the hood the named return parameters are likely the same as declaring a new local variable.
68851a3
68851a3
to
96ef29d
Compare
OpenZeppelin defender fixes
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
// This check is not performed for external networks because unrelated messages may have already changed | ||
// the state of the receipt queues. | ||
if !network.IsExternalNetwork() { | ||
Expect(utils.CheckReceiptReceived( |
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.
In order to not depend on the order that tests run, I think we should clear the receipt queue at the start of this flow. Otherwise, other tests may send messages that cause the receipt queue length to be >5 at the start of this flow, and the first message sent back may not have this specific receipt.
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.
moved the ClearReceiptQueue
into a utils function and call in flow if not an external network
@michaelkaplan13 our openzepplin submode is at version |
Ah, thanks. I should have checked myself. I was assuming it was a more recent fix published for that issue. Now I'm confused why that OpenZeppelin report item is listed at all then. Do we think it's a pure false positive? |
@michaelkaplan13 Actually, |
9000294
to
af29ab6
Compare
af29ab6
to
f573d17
Compare
@michaelkaplan13 this looks to be a false positive. If you click into the link attached in the alert GHSA-9c22-pwxw-p6hx, it specifies |
f573d17
to
9266be3
Compare
9266be3
to
afdc62a
Compare
49b6150
Why this should be merged
Fixes #186
How this works
Handles fixes from the most recent report that are applicable:
msg.sender
vs_msgSender
to support EIP2771 meta transactionsevent UnlockTokens
ReceiptReceived
eventuint256 val = 0;
_nativeMinter
can be made constantHow this was tested
Unit + e2e test updates
CI
How is this documented
TODO