Skip to content

Implement native-fungible natively.#6256

Open
MathieuDutSik wants to merge 17 commits into
linera-io:mainfrom
MathieuDutSik:native_native_fungible
Open

Implement native-fungible natively.#6256
MathieuDutSik wants to merge 17 commits into
linera-io:mainfrom
MathieuDutSik:native_native_fungible

Conversation

@MathieuDutSik
Copy link
Copy Markdown
Contributor

Motivation

Issue #4416 that is being considered here is about authentication. We have one authentication going on in native-fungible contract code:

                self.runtime
                    .check_account_permission(owner)
                    .expect("Permission for Transfer operation");

This one is done with the authenticated_caller_id being equal to the contract that was calling it.

This is followed in the function fn transfer of linera-execution/src/system.rs by the following:

            ensure!(
                authenticated_owner == Some(source)
                    || authenticated_application_id.map(AccountOwner::from) == Some(source),
                ExecutionError::UnauthenticatedTransferOwner
            );

It looks the same, but it is not: The authenticated caller ID in question is this time the one of the native-fungible contract.

This means that we cannot expect the native-fungible to behave in a way identical to the fungible contract, despite them having the same API. As a practical example, we cannot use crowd-funding with native-fungible.

In the killed PR #5649, it was proposed to expose the stack to the caller who would then be able to select the level of authentication. The problem with this approach is that it exposes us to all kind of possible scenario and complexifies the work of the programmer.

Fixes #4416

Proposal

Implement the native-fungible as an application native to linera. So, now we have applications that are Wasm, applications that are Evm, and native ones.

This is simply a continuation of existing software trends:

  • The native-fungible is anyway having its state in the entries balances and allowances of the ChainStateView.
  • There is a trend to make such applications (see hyperliquid as an example)

Note that we are still forced to expose some of the stack. But this is done in linera-execution and the functionality are not exposed to the linera-sdk.

Test Plan

CI and add a few tests.

Release Plan

It cannot be backported to testnet_conway.

Links

None

@MathieuDutSik MathieuDutSik force-pushed the native_native_fungible branch from c47f5cc to 79a6d65 Compare May 7, 2026 14:51
@MathieuDutSik MathieuDutSik force-pushed the native_native_fungible branch from b1ba5e4 to f83fe17 Compare May 7, 2026 17:57
@MathieuDutSik MathieuDutSik marked this pull request as ready for review May 7, 2026 18:53
/// How an application is implemented: either a published module (Wasm/EVM bytecode), or a
/// runtime-native application that needs no bytecode.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash, Serialize, WitType, WitLoad, WitStore)]
pub enum ApplicationKind {
Copy link
Copy Markdown
Contributor

@ma2bd ma2bd May 8, 2026

Choose a reason for hiding this comment

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

I was hoping we wouldn't have to do that given that we already have the VM enum.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Three points:

  • From a logical standpoint I think this is the right design since Native applications are qualitatively different from Wasm/Revm based ones.

  • But yes of course, if we want compatibility with testnet_conway this is a problem.

  • I think we can support all Wasm/Evm/Native at the same level. After all there is little that cannot be solved by some programming.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See #6269 that demonstrates the concept.

Though more care would be needed to make it work. Also, there are some issues of web compatibility that would have to be carefully considered.

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.

Native-fungible doesn't work as intended for application owners

2 participants