-
Notifications
You must be signed in to change notification settings - Fork 859
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
optimization constant time #65
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,6 +9,8 @@ contract XCounterUC is UniversalChanIbcApp { | |||||
uint64 public counter; | ||||||
mapping(uint64 => address) public counterMap; | ||||||
|
||||||
uint64 public immutable CONST_TIME = 1e9; | ||||||
|
||||||
constructor(address _middleware) UniversalChanIbcApp(_middleware) {} | ||||||
|
||||||
// application specific logic | ||||||
|
@@ -32,7 +34,7 @@ contract XCounterUC is UniversalChanIbcApp { | |||||
increment(); | ||||||
bytes memory payload = abi.encode(msg.sender, counter); | ||||||
|
||||||
uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * 1000000000); | ||||||
uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * CONST_TIME); | ||||||
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. The calculation of - uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * CONST_TIME);
+ uint64 timeoutTimestamp = uint64(block.timestamp + (timeoutSeconds * CONST_TIME)); Committable suggestion
Suggested change
|
||||||
|
||||||
IbcUniversalPacketSender(mw).sendUniversalPacket( | ||||||
channelId, IbcUtils.toBytes32(destPortAddr), payload, timeoutTimestamp | ||||||
|
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 calculation of
timeoutTimestamp
seems to misunderstand the purpose ofCONST_TIME
. Multiplyingblock.timestamp + timeoutSeconds
byCONST_TIME
does not align with the typical use of a timeout timestamp. IfCONST_TIME
is meant to represent a constant duration, it should likely be added to, not multiplied by, the current timestamp and timeout period.Committable suggestion