Skip to content
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

OR-1419 update onApprove logic #84

Conversation

nguyenzung
Copy link
Member

  • Update onApprove logic for L1CrossDomainMessenger
  • Add a task as an example: call deposit TON in L2 in onApprove
  • Reduce gas cost in assembly code

Thank you!

PORTAL.depositTransaction(_to, _value, _gasLimit, false, _data);
}

/// @notice unpack onApprove data
/// @param _data Data used in OnApprove contract
function unpackOnApproveData(bytes calldata _data) public pure returns (address _to, uint32 _minGasLimit, bytes calldata _message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you always!
About unpackOnApproveData(onApprove), It seems only L1CDM can set the target Address. Is there any reason?

Copy link
Member Author

@nguyenzung nguyenzung Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Because for other function, it can be encoded into the message directly. The target in CDM is used for relayMessage in sendMessage or sendNativeTokenMessage in L1 to relay a function in L2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In optimism portal, I keep the same logic as previous version, only deposit native token.

Copy link
Member

@rlgns98kr rlgns98kr Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, Thank you very much. I understood it thanks to your explanation.

@Zena-park, @nguyenzung
How about removing onApprove in CDM? I think there is no receive function in legacy. I'm sorry about I'm missing about this.
And one more, I think we can use onApprove only for send TON same as legacy. (not message) Is it bad idea,,,? 🙇🏼‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function does not really matter if we add or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rlgns98kr Thank you Steven, let me update it. I also forgot formatting code.

For encoded message, because owner and amount is already available, so should we only have _to, _minGasLimit and _extraData? I think it will reduce redundant checking and gas cost. In general, we only encode which params in the target function but not exist in onApprove()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

I think you are correct!
But in my thoughts, we may explain about approveAndCall to the frontend or users in the future. So if we unpack all arguments, we explain that more easily.

Is it okay? Is it a waste of gas..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is okay, although will cost some more gas. Maybe it is easier for the frontend team.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much 🙇🏼‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Steven!
I updated

@nguyenzung nguyenzung force-pushed the OR-1419-titan-canyon-update-onApprove-for-L1CDM-and-test branch from 4850e9c to 65d6706 Compare March 5, 2024 04:59
@nguyenzung nguyenzung self-assigned this Mar 5, 2024
@rlgns98kr rlgns98kr requested a review from Zena-park March 5, 2024 06:17
@nguyenzung nguyenzung force-pushed the OR-1419-titan-canyon-update-onApprove-for-L1CDM-and-test branch from e9c5c18 to 58fcc6d Compare March 6, 2024 08:53
Copy link
Member

@rlgns98kr rlgns98kr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@nguyenzung nguyenzung merged commit e5a7cae into OR-1257-Update-smart-contracts-for-deposit-TON-in-L1 Mar 8, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants