Skip to content

Conversation

blockchaindevsh
Copy link

@blockchaindevsh blockchaindevsh commented Aug 7, 2025

This PR makes the deposit tx corresponding to mintTransaction triggered via L2CrossDomainMessenger.relayMessage so that if the execution failed on L2, it can be retried later.

@blockchaindevsh
Copy link
Author

Needs fix, will create a new pr later.

@blockchaindevsh
Copy link
Author

blockchaindevsh commented Aug 7, 2025

reopen , I was hesitant for the msg.sender parameter which is used as sender on L2: for OP standard bridge, it's the bridge address and checked in bridge function via onlyOtherBridge; for mintTransaction, it'll be the portal address.

Other candidate values may be msg.origin/QKC_DEPOSITOR_ACCOUNT, but looks like it doesn't really matter for us.

/// @param _message Message to trigger the target address with.
/// @param _minGasLimit Minimum gas limit that the message can be executed with.
/// @param _value Value to send with the message.
function wrapForRelayMessage(
Copy link

Choose a reason for hiding this comment

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

Another approach is to introduce a new method, sendQKCTransferMessage, in L1CrossDomainMessenger.sol, which would call portal.depositTransactionChecked which can only be called by l1CrossDomainMessenger. And then we can just delete mintTransaction.

Copy link
Author

@blockchaindevsh blockchaindevsh Aug 8, 2025

Choose a reason for hiding this comment

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

Good point, now the call direction is L1CrossDomainMessenger->OptimismPortal2, not the reverse. But I kept the naming mintTransaction.

@blockchaindevsh blockchaindevsh changed the title make mintTransaction call via CrossDomainMessenger make mintTransaction called via CrossDomainMessenger Aug 9, 2025
QKCConfigStorage storage $ = _getQKCConfigStorage();
if (msg.sender != $.minter) {
/// @dev This function is only callable by L1CrossDomainMessenger.
function mintTransaction(
Copy link

@qzhodl qzhodl Aug 9, 2025

Choose a reason for hiding this comment

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

It appears that mintTransaction and depositTransaction share most of the same code. We could implement a shared _depositTransaction internal function containing the common logic, while allowing mintTransaction and depositTransaction to each handle their specific access control requirements.

Copy link
Author

Choose a reason for hiding this comment

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

I'd like to keep depositTransaction untouched, otherwise it'll be a pain to merge in future.

/// @param _minGasLimit Minimum gas limit that the message can be executed with.
function sendMintMessage(
address _target,
bytes calldata _message,
Copy link

Choose a reason for hiding this comment

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

If the method is intended solely for minting QKC, we should omit this parameter

Copy link
Author

Choose a reason for hiding this comment

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

It tries to be flexible, e.g., it's possible to mint and swap in a single L2 transaction if we want it in future.

address _target,
bytes calldata _message,
uint256 _mintValue,
uint32 _minGasLimit
Copy link

Choose a reason for hiding this comment

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

If we're using RECEIVE_DEFAULT_GAS_LIMIT, is there still a need to include the _minGasLimit parameter?

Copy link
Author

@blockchaindevsh blockchaindevsh Aug 12, 2025

Choose a reason for hiding this comment

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

Like the existing sendMessage, it's designed to be flexible, so that user can choose a proper _minGasLimit for the call.

@qzhodl
Copy link

qzhodl commented Aug 12, 2025

I’m wondering if you’ve already tested whether the failed transaction can be replayed on the devnet?

@qzhodl
Copy link

qzhodl commented Aug 12, 2025

I’m wondering if you’ve already tested whether the failed transaction can be replayed on the devnet?

@iteyelmp will try to test it on the devnet to see if it works.

@qizhou
Copy link

qizhou commented Aug 13, 2025

Another option is to change L1StandardBridge and move all mint logic to that so that CrossDomainMessager and Portal can be unchanged?

@blockchaindevsh
Copy link
Author

blockchaindevsh commented Aug 13, 2025

Another option is to change L1StandardBridge and move all mint logic to that so that CrossDomainMessager and Portal can be unchanged?

portal.depositTransaction charges actual msg.value, so portal.mintTransaction is still needed.

@iteyelmp
Copy link

Summary: A devnet has been deployed based on this contract. These funds can currently be retrieved successfully by manually calling L2CrossDomainMessenger.relayMessage, but when doing so, the default estimated gas limit is incorrect — it estimates around 40,000, while the actual cost is about 70,000–80,000.

@qzhodl
Copy link

qzhodl commented Aug 26, 2025

@qizhou noted that the previous CGT design also lacked tx-replay support.

To minimize contract changes and keep upstream merges straightforward, we’ll defer merging this PR into the branch for now. Instead, @iteyelmp, we can surface a notice in the migration UI:

Important Note: Do not send QKC to an L2 address that cannot receive tokens—for example, an address enabled with EIP-7702 but unable to accept native tokens. Otherwise, your funds will be permanently lost.

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.

4 participants