Skip to content

INT-402: NativeOFTAdapterUpgradeable - #1591

Closed
ravinagill15 wants to merge 2 commits into
mainfrom
feat/int-402
Closed

INT-402: NativeOFTAdapterUpgradeable#1591
ravinagill15 wants to merge 2 commits into
mainfrom
feat/int-402

Conversation

@ravinagill15

@ravinagill15 ravinagill15 commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

In this PR:

  • Implemented NativeOFTAdapterUpgradeable, essentially the same as NativeOFTAdapter, but using OFTCoreUpgradeable
  • Added tests and mocks as needed

@ravinagill15
ravinagill15 requested a review from a team June 25, 2025 23:36
// Skip native adapter assertions in fee test suite
}

function test_native_oft_adapter_debit() public virtual override {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this solution for testing. I think it leaks problems too much to the test suite that derives from it.

It seems each time we will use OFT.t.sol as a base we will have to manually skip native OFT adapter tests?

I think we should instead create a new test file specifically for NativeOFTAdapter or NativeOFTAdapterUpgradeable so we don't have to call vm.skip(true) in any of test suites that derives from OFT.t.sol.

New test file can derive from OFT.t.sol.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what we need is a base test framework for ugradeable and then there is a new test file that tests ONLY that OApp.

reference: https://github.com/LayerZero-Labs/devtools/tree/feat/ovault-evm/packages/ovault-evm/test/composer

which creates a base, and then you implement Unit, E2E, Upgradeable Unit, etc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like a clean separation @shankars99 👍

constructor(
uint8 _localDecimals,
address _lzEndpoint
) NativeOFTAdapterUpgradeable(_localDecimals, _lzEndpoint, address(0)) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

disableInitializers in constructor of the mock

)
);

dNativeOFTAdapter = NativeOFTAdapterUpgradeableMock(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use separate file for native OFT adapter tests or something that doesn't have to be vm.skipped if something derives from the test suite

// @notice Codec to convert NativeOFTAdapterUpgradeable to NativeOFTAdapterUpgradeableMock in a consistent, readable manner.
// @dev For testing purposes only.
library NativeOFTAdapterUpgradeableMockCodec {
function asNativeOFTAdapterUpgradeableMock(NativeOFTAdapterUpgradeable _oft) internal pure returns (NativeOFTAdapterUpgradeableMock) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this used anywhere?

assertEq(dNativeOFTAdapter.approvalRequired(), false);
}

function test_oftVersion() public view {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why is this change required?

Comment on lines +87 to +90
uint256 requiredMsgValue = _fee.nativeFee + _removeDust(_sendParam.amountLD);
if (msg.value != requiredMsgValue) {
revert IncorrectMessageValue(msg.value, requiredMsgValue);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this expects that the user uses a sendParam.amountLD that would result in no dust. why cant the user send extra native and it get refunded to them later at the refund address?

@DanL0 DanL0 Jun 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is how NativeOFTAdapter (non-upgradeable) operates already, I don't think we should change this in upgradeable version. we should change in both if we want to change it

in my legacy implementation I have also allowed refunds, here you need to pass very precise amounts which I think can be a little bit worse UX during gas spikes: revert instead of refund

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yeah we should change it in both places. revert if not exact is worse UX

@shankars99 shankars99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not a fan of the send()

@ravinagill15

Copy link
Copy Markdown
Contributor Author

Closing this PR as Plume has stated it is not required to have upgradeable contracts

@ravinagill15
ravinagill15 deleted the feat/int-402 branch July 2, 2025 23:26
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.

3 participants