Skip to content

Commit

Permalink
Replace ApplicationDescription with Blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva91 committed Oct 7, 2024
1 parent c281952 commit a30fd77
Show file tree
Hide file tree
Showing 79 changed files with 1,596 additions and 2,148 deletions.
22 changes: 0 additions & 22 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ This document contains the help content for the `linera` command-line program.
* [`linera read-data-blob`](#linera-read-data-blob)
* [`linera create-application`](#linera-create-application)
* [`linera publish-and-create`](#linera-publish-and-create)
* [`linera request-application`](#linera-request-application)
* [`linera keygen`](#linera-keygen)
* [`linera assign`](#linera-assign)
* [`linera retry-pending-block`](#linera-retry-pending-block)
Expand Down Expand Up @@ -81,7 +80,6 @@ A Byzantine-fault tolerant sidechain with low-latency finality and high throughp
* `read-data-blob` — Verify that a data blob is readable
* `create-application` — Create an application
* `publish-and-create` — Create an application, and publish the required bytecode
* `request-application` — Request an application from another chain, so it can be used on this one
* `keygen` — Create an unassigned key-pair
* `assign` — Link a key owned by the wallet to a chain that was just created for that key
* `retry-pending-block` — Retry a block we unsuccessfully tried to propose earlier
Expand Down Expand Up @@ -591,7 +589,6 @@ Create an application
* `--json-parameters-path <JSON_PARAMETERS_PATH>` — Path to a JSON file containing the shared parameters
* `--json-argument <JSON_ARGUMENT>` — The instantiation argument as a JSON string
* `--json-argument-path <JSON_ARGUMENT_PATH>` — Path to a JSON file containing the instantiation argument
* `--required-application-ids <REQUIRED_APPLICATION_IDS>` — The list of required dependencies of application, if any



Expand All @@ -613,24 +610,6 @@ Create an application, and publish the required bytecode
* `--json-parameters-path <JSON_PARAMETERS_PATH>` — Path to a JSON file containing the shared parameters
* `--json-argument <JSON_ARGUMENT>` — The instantiation argument as a JSON string
* `--json-argument-path <JSON_ARGUMENT_PATH>` — Path to a JSON file containing the instantiation argument
* `--required-application-ids <REQUIRED_APPLICATION_IDS>` — The list of required dependencies of application, if any



## `linera request-application`

Request an application from another chain, so it can be used on this one

**Usage:** `linera request-application [OPTIONS] <APPLICATION_ID>`

###### **Arguments:**

* `<APPLICATION_ID>` — The ID of the application to request

###### **Options:**

* `--target-chain-id <TARGET_CHAIN_ID>` — The target chain on which the application is already registered. If not specified, the chain on which the application was created is used
* `--requester-chain-id <REQUESTER_CHAIN_ID>` — The owned chain on which the application is missing



Expand Down Expand Up @@ -813,7 +792,6 @@ Build and publish a Linera project
* `--json-parameters-path <JSON_PARAMETERS_PATH>` — Path to a JSON file containing the shared parameters
* `--json-argument <JSON_ARGUMENT>` — The instantiation argument as a JSON string
* `--json-argument-path <JSON_ARGUMENT_PATH>` — Path to a JSON file containing the instantiation argument
* `--required-application-ids <REQUIRED_APPLICATION_IDS>` — The list of required dependencies of application, if any



Expand Down
29 changes: 1 addition & 28 deletions examples/amm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ FUN2_APP_ID=$(linera --wait-for-outgoing-messages \
(cd examples/amm && cargo build --release --target wasm32-unknown-unknown)
AMM_APPLICATION_ID=$(linera --wait-for-outgoing-messages \
publish-and-create examples/target/wasm32-unknown-unknown/release/amm_{contract,service}.wasm \
--json-parameters "{\"tokens\":["\"$FUN1_APP_ID\"","\"$FUN2_APP_ID\""]}" \
--required-application-ids $FUN1_APP_ID $FUN2_APP_ID)
--json-parameters "{\"tokens\":["\"$FUN1_APP_ID\"","\"$FUN2_APP_ID\""]}")
```

## Using the AMM Application
Expand Down Expand Up @@ -167,20 +166,6 @@ To properly setup the tokens in the proper chains, we need to do some transfer o
```

All operations can only be from a remote chain i.e. other than the chain on which `AMM` is deployed to.
We can do it from GraphiQL by performing the `requestApplication` mutation so that we can perform the
operation from the chain.

```gql,uri=http://localhost:8080
mutation {
requestApplication (
chainId:"$CHAIN_1",
applicationId: "$AMM_APPLICATION_ID",
targetChainId: "$CHAIN_AMM"
)
}
```

Note: The above mutation has to be performed from `http://localhost:8080`.

Before performing any operation we need to provide liquidity to it, so we will use the `AddLiquidity` operation,
navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"`.
Expand All @@ -197,18 +182,6 @@ mutation {
}
```

```gql,uri=http://localhost:8080
mutation {
requestApplication (
chainId:"$CHAIN_2",
applicationId: "$AMM_APPLICATION_ID",
targetChainId: "$CHAIN_AMM"
)
}
```

Note: The above mutation has to be performed from `http://localhost:8080`.

To perform `Swap` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:

Expand Down
29 changes: 1 addition & 28 deletions examples/amm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ FUN2_APP_ID=$(linera --wait-for-outgoing-messages \
(cd examples/amm && cargo build --release --target wasm32-unknown-unknown)
AMM_APPLICATION_ID=$(linera --wait-for-outgoing-messages \
publish-and-create examples/target/wasm32-unknown-unknown/release/amm_{contract,service}.wasm \
--json-parameters "{\"tokens\":["\"$FUN1_APP_ID\"","\"$FUN2_APP_ID\""]}" \
--required-application-ids $FUN1_APP_ID $FUN2_APP_ID)
--json-parameters "{\"tokens\":["\"$FUN1_APP_ID\"","\"$FUN2_APP_ID\""]}")
```
## Using the AMM Application
Expand Down Expand Up @@ -171,20 +170,6 @@ To properly setup the tokens in the proper chains, we need to do some transfer o
```
All operations can only be from a remote chain i.e. other than the chain on which `AMM` is deployed to.
We can do it from GraphiQL by performing the `requestApplication` mutation so that we can perform the
operation from the chain.
```gql,uri=http://localhost:8080
mutation {
requestApplication (
chainId:"$CHAIN_1",
applicationId: "$AMM_APPLICATION_ID",
targetChainId: "$CHAIN_AMM"
)
}
```
Note: The above mutation has to be performed from `http://localhost:8080`.
Before performing any operation we need to provide liquidity to it, so we will use the `AddLiquidity` operation,
navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"`.
Expand All @@ -201,18 +186,6 @@ mutation {
}
```
```gql,uri=http://localhost:8080
mutation {
requestApplication (
chainId:"$CHAIN_2",
applicationId: "$AMM_APPLICATION_ID",
targetChainId: "$CHAIN_AMM"
)
}
```
Note: The above mutation has to be performed from `http://localhost:8080`.
To perform `Swap` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/tests/single_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn single_chain_test() {

let initial_state = 42u64;
let application_id = chain
.create_application(bytecode_id, (), initial_state, vec![])
.create_application(bytecode_id, (), initial_state)
.await;

let increment = 15u64;
Expand Down
26 changes: 0 additions & 26 deletions examples/crowd-funding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ APP_ID_1=$(linera --with-wallet 0 \
project publish-and-create \
examples/crowd-funding \
crowd_funding \
--required-application-ids $APP_ID_0 \
--json-argument '{ "owner": "User:'$OWNER_0'", "deadline": 4102473600000000, "target": "100." }' \
--json-parameters '"'"$APP_ID_0"'"')

Expand All @@ -157,31 +156,6 @@ sleep 2

Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.

Point your browser to http://localhost:8080, and enter the query:

```gql,uri=http://localhost:8080
query { applications(
chainId: "$CHAIN_0"
) { id link } }
```

The response will have two entries, one for each application.

If you do the same with the other chain ID in http://localhost:8081, the node service for the
other wallet, it will have no entries at all, because the applications haven't been registered
there yet. Request `crowd-funding` from the other chain. As an application ID, use `$APP_ID_1`:

```gql,uri=http://localhost:8081
mutation { requestApplication(
chainId: "$CHAIN_1"
applicationId: "$APP_ID_1"
) }
```

If you enter the `applications` query again, both entries will appear in the second wallet as
well now. `$APP_ID_0` has been registered, too, because it is a dependency of the other
application.

On both http://localhost:8080 and http://localhost:8081, you recognize the crowd-funding
application by its ID. The entry also has a field `link`. If you open that in a new tab, you
see the GraphQL API for that application on that chain.
Expand Down
26 changes: 0 additions & 26 deletions examples/crowd-funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ APP_ID_1=$(linera --with-wallet 0 \
project publish-and-create \
examples/crowd-funding \
crowd_funding \
--required-application-ids $APP_ID_0 \
--json-argument '{ "owner": "User:'$OWNER_0'", "deadline": 4102473600000000, "target": "100." }' \
--json-parameters '"'"$APP_ID_0"'"')
Expand All @@ -165,31 +164,6 @@ sleep 2
Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.
Point your browser to http://localhost:8080, and enter the query:
```gql,uri=http://localhost:8080
query { applications(
chainId: "$CHAIN_0"
) { id link } }
```
The response will have two entries, one for each application.
If you do the same with the other chain ID in http://localhost:8081, the node service for the
other wallet, it will have no entries at all, because the applications haven't been registered
there yet. Request `crowd-funding` from the other chain. As an application ID, use `$APP_ID_1`:
```gql,uri=http://localhost:8081
mutation { requestApplication(
chainId: "$CHAIN_1"
applicationId: "$APP_ID_1"
) }
```
If you enter the `applications` query again, both entries will appear in the second wallet as
well now. `$APP_ID_0` has been registered, too, because it is a dependency of the other
application.
On both http://localhost:8080 and http://localhost:8081, you recognize the crowd-funding
application by its ID. The entry also has a field `link`. If you open that in a new tab, you
see the GraphQL API for that application on that chain.
Expand Down
22 changes: 4 additions & 18 deletions examples/crowd-funding/tests/campaign_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,12 @@ async fn collect_pledges() {
target: target_amount,
};
let campaign_id = campaign_chain
.create_application(
bytecode_id,
token_id,
campaign_state,
vec![token_id.forget_abi()],
)
.create_application(bytecode_id, token_id, campaign_state)
.await;

let mut pledges_and_transfers = Vec::new();

for (backer_chain, backer_account, _balance) in &backers {
backer_chain.register_application(campaign_id).await;

let pledge_certificate = backer_chain
.add_block(|block| {
block.with_operation(
Expand All @@ -78,7 +71,7 @@ async fn collect_pledges() {
})
.await;

assert_eq!(pledge_certificate.outgoing_message_count(), 3);
assert_eq!(pledge_certificate.outgoing_message_count(), 2);
pledges_and_transfers.push(pledge_certificate);
}

Expand Down Expand Up @@ -157,19 +150,12 @@ async fn cancel_successful_campaign() {
target: target_amount,
};
let campaign_id = campaign_chain
.create_application(
bytecode_id,
token_id,
campaign_state,
vec![token_id.forget_abi()],
)
.create_application(bytecode_id, token_id, campaign_state)
.await;

let mut pledges_and_transfers = Vec::new();

for (backer_chain, backer_account, _balance) in &backers {
backer_chain.register_application(campaign_id).await;

let pledge_certificate = backer_chain
.add_block(|block| {
block.with_operation(
Expand All @@ -182,7 +168,7 @@ async fn cancel_successful_campaign() {
})
.await;

assert_eq!(pledge_certificate.outgoing_message_count(), 3);
assert_eq!(pledge_certificate.outgoing_message_count(), 2);
pledges_and_transfers.push(pledge_certificate);
}

Expand Down
8 changes: 3 additions & 5 deletions examples/fungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,10 @@ pub async fn create_with_accounts(

let params = Parameters::new("FUN");
let application_id = token_chain
.create_application(bytecode_id, params, initial_state.build(), vec![])
.create_application(bytecode_id, params, initial_state.build())
.await;

for (chain, account, initial_amount) in &accounts {
chain.register_application(application_id).await;

let claim_certificate = chain
.add_block(|block| {
block.with_operation(
Expand All @@ -330,15 +328,15 @@ pub async fn create_with_accounts(
})
.await;

assert_eq!(claim_certificate.outgoing_message_count(), 2);
assert_eq!(claim_certificate.outgoing_message_count(), 1);

let transfer_certificate = token_chain
.add_block(|block| {
block.with_messages_from(&claim_certificate);
})
.await;

assert_eq!(transfer_certificate.outgoing_message_count(), 2);
assert_eq!(transfer_certificate.outgoing_message_count(), 1);

chain
.add_block(|block| {
Expand Down
8 changes: 3 additions & 5 deletions examples/fungible/tests/cross_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn test_cross_chain_transfer() {
let initial_state = InitialStateBuilder::default().with_account(sender_account, initial_amount);
let params = Parameters::new("FUN");
let application_id = sender_chain
.create_application(bytecode_id, params, initial_state.build(), vec![])
.create_application(bytecode_id, params, initial_state.build())
.await;

let receiver_chain = validator.new_chain().await;
Expand Down Expand Up @@ -89,14 +89,12 @@ async fn test_bouncing_tokens() {
let initial_state = InitialStateBuilder::default().with_account(sender_account, initial_amount);
let params = Parameters::new("RET");
let application_id = sender_chain
.create_application(bytecode_id, params, initial_state.build(), vec![])
.create_application(bytecode_id, params, initial_state.build())
.await;

let receiver_chain = validator.new_chain().await;
let receiver_account = AccountOwner::from(receiver_chain.public_key());

receiver_chain.register_application(application_id).await;

let certificate = sender_chain
.add_block(|block| {
block.with_operation(
Expand All @@ -118,7 +116,7 @@ async fn test_bouncing_tokens() {
Some(initial_amount.saturating_sub(transfer_amount)),
);

assert_eq!(certificate.outgoing_message_count(), 2);
assert_eq!(certificate.outgoing_message_count(), 1);

receiver_chain
.add_block(move |block| {
Expand Down
10 changes: 1 addition & 9 deletions examples/matching-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,7 @@ Now we publish and deploy the Matching Engine application:
```bash
MATCHING_ENGINE=$(linera --wait-for-outgoing-messages \
project publish-and-create examples/matching-engine \
--json-parameters "{\"tokens\":["\"$FUN1_APP_ID\"","\"$FUN2_APP_ID\""]}" \
--required-application-ids $FUN1_APP_ID $FUN2_APP_ID)
```

And make sure chain 2 also has it:

```bash
linera --wait-for-outgoing-messages request-application \
--requester-chain-id $CHAIN_2 $MATCHING_ENGINE
--json-parameters "{\"tokens\":["\"$FUN1_APP_ID\"","\"$FUN2_APP_ID\""]}")
```

## Using the Matching Engine Application
Expand Down
Loading

0 comments on commit a30fd77

Please sign in to comment.