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

Allow applications to hold native tokens #2978

Merged
merged 58 commits into from
Nov 28, 2024

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Nov 27, 2024

Motivation

Applications may hold tokens from Fungible Token applications, however, they can't hold native tokens. This creates some incompatibility, and also makes it harder to support some scenarios, like automatic market makers using native tokens.

Proposal

Allow applications to hold native tokens, and to transfer them.

Update the on-chain balances to use AccountOwner as its key, instead of Owner. This allows applications to have balances. Also update Account to use AccountOwner instead of Owner.

Update the WIT interface so that the system APIs can transfer, claim and query application balances.

Test Plan

Unit tests were added to test the runtime APIs using application accounts.

Release Plan

  • This requires a new devnet and testnet release, because it introduces breaking changes to the chain state.

Links

@jvff jvff added the enhancement New feature or request label Nov 27, 2024
@jvff jvff added this to the Testnet #2 milestone Nov 27, 2024
@jvff jvff requested review from ma2bd, ndr-ds, afck and deuszx November 27, 2024 18:56
@jvff jvff self-assigned this Nov 27, 2024
@jvff jvff force-pushed the allow-applications-to-hold-native-tokens branch 3 times, most recently from 7b3f1bc to c39b71e Compare November 28, 2024 04:07
jvff added 20 commits November 28, 2024 04:28
Allow applications to hold native tokens.
Allow requesting the balance of an application's account.
Update `ChainClient` methods to be able to query an application's
balance.
Allow the runtime to request the balance of application accounts.
Prepare to update the WIT API to be able to query an application's
balance.
Use `AccountOwner` as the parameter instead of `Owner`, in order to
support application accounts.
Prepare to use the type in `SystemMessage`, which has `Hash` derived for
it.
Prepare to change the runtime interface to use `AccountOwner`.
Prepare to change the runtime interface to use `AccountOwner`.
Update the SDK's runtime API to support querying an application's
balance.
Prepare the `ServiceRuntime` to use an updated WIT interface that allows
querying the balance of application accounts.
Allow the runtime to get a list the balances of application accounts.
Prepare to update the WIT API to be able to list application balances.
Return `AccountOwner` in order to include application accounts.
Include application balances in the result.
Prepare the `ServiceRuntime` to use an updated WIT interface that allows
querying the balance of application accounts.
Allow the runtime to get a list the accounts including application
accounts.
Prepare to update the WIT API to be able to list application accounts.
Return `AccountOwner` in order to include application accounts.
Include application accounts in the result.
Prepare to handle more than one colon in the input string.
@jvff jvff force-pushed the allow-applications-to-hold-native-tokens branch from c39b71e to a8e4d30 Compare November 28, 2024 04:28
linera-base/src/identifiers.rs Show resolved Hide resolved
linera-base/src/identifiers.rs Outdated Show resolved Hide resolved
linera-core/src/client/mod.rs Show resolved Hide resolved
linera-core/src/unit_tests/client_tests.rs Outdated Show resolved Hide resolved
linera-execution/tests/contract_runtime_apis.rs Outdated Show resolved Hide resolved
jvff and others added 24 commits November 28, 2024 13:12
Update `Account` to also represent application accounts.
Prevent excessive stack usage by nested futures.
Remove normalization of owners, and use `AccountOwner` directly.
Update the `balances` map to support applications.
Prepare to allow the helpers to be used by a new integration test
module. Also, rename the test helpers for consistency.
Ensure that applications can transfer from their accounts, from the
shared chain account, and from the signer's account.
Ensure that applications can claim from their accounts or from the
signer account in remote chains.
Prepare to use it in property tests.
Ensure applications can read the chain balance.
Ensure applications can read the balances of individual accounts.
Ensure applications can read a list of all account balances.
Ensure applications can read a list of all accounts.
The system API should fallback and return zero in that case.
Ensure that execution fails with the appropriate error.
Ensure that execution fails with the appropriate error.
Allow tests to create a dummy context to test queries.
Ensure applications can read the chain balance.
Allow the helper function to be used in other tests.
Ensure applications can read the balances of individual accounts.
Ensure applications can read a list of all account balances.
Ensure applications can read a list of all accounts.
The system API should fallback and return zero in that case.
Simplify the code to generate the error.

Co-authored-by: Andreas Fackler <[email protected]>
Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
The runtime API should be deterministic, so the returned lists of
accounts must be sorted.

Co-authored-by: Andreas Fackler <[email protected]>
Signed-off-by: Janito Vaqueiro Ferreira Filho <[email protected]>
@jvff jvff force-pushed the allow-applications-to-hold-native-tokens branch from 14b0638 to 49c439e Compare November 28, 2024 13:13
@jvff jvff merged commit a601098 into linera-io:main Nov 28, 2024
21 checks passed
@jvff jvff deleted the allow-applications-to-hold-native-tokens branch November 28, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow applications to hold native tokens
2 participants