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 10, 2024
1 parent 1c76184 commit 3ba41da
Show file tree
Hide file tree
Showing 71 changed files with 1,534 additions and 1,974 deletions.
19 changes: 0 additions & 19 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 @@ -83,7 +82,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 @@ -627,23 +625,6 @@ Create an application, and publish the required bytecode



## `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



## `linera keygen`

Create an unassigned key-pair
Expand Down
30 changes: 2 additions & 28 deletions examples/amm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,11 @@ 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"`.

To perform `AddLiquidity` operation:
To perform the `AddLiquidity` operation:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
mutation {
Expand All @@ -197,19 +183,7 @@ 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
To perform the `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:

```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID
Expand Down
30 changes: 2 additions & 28 deletions examples/amm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,11 @@ 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"`.
To perform `AddLiquidity` operation:
To perform the `AddLiquidity` operation:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
mutation {
Expand All @@ -201,19 +187,7 @@ 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
To perform the `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:
```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID
Expand Down
25 changes: 0 additions & 25 deletions examples/crowd-funding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,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
25 changes: 0 additions & 25 deletions examples/crowd-funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,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, vec![])
.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, vec![])
.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
6 changes: 2 additions & 4 deletions examples/fungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ pub async fn create_with_accounts(
.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
4 changes: 1 addition & 3 deletions examples/fungible/tests/cross_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ async fn test_bouncing_tokens() {
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
7 changes: 0 additions & 7 deletions examples/matching-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ MATCHING_ENGINE=$(linera --wait-for-outgoing-messages \
--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
```

## Using the Matching Engine Application

First, a node service for the current wallet has to be started:
Expand Down
7 changes: 0 additions & 7 deletions examples/matching-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ MATCHING_ENGINE=$(linera --wait-for-outgoing-messages \
--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
```
## Using the Matching Engine Application
First, a node service for the current wallet has to be started:
Expand Down
19 changes: 4 additions & 15 deletions examples/matching-engine/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ async fn single_transaction() {
)
.await;

user_chain_a.register_application(token_id_b).await;
user_chain_b.register_application(token_id_a).await;

// Check the initial starting amounts for chain a and chain b
for (owner, amount) in [
(admin_account, None),
Expand All @@ -131,16 +128,8 @@ async fn single_transaction() {
let tokens = [token_id_a, token_id_b];
let matching_parameter = Parameters { tokens };
let matching_id = matching_chain
.create_application(
bytecode_id,
matching_parameter,
(),
vec![token_id_a.forget_abi(), token_id_b.forget_abi()],
)
.create_application(bytecode_id, matching_parameter, (), vec![])
.await;
// Doing the registrations
user_chain_a.register_application(matching_id).await;
user_chain_b.register_application(matching_id).await;

// Creating the bid orders
let mut bid_certificates = Vec::new();
Expand All @@ -159,7 +148,7 @@ async fn single_transaction() {
})
.await;

assert_eq!(bid_certificate.outgoing_message_count(), 3);
assert_eq!(bid_certificate.outgoing_message_count(), 2);
bid_certificates.push(bid_certificate);
}

Expand Down Expand Up @@ -211,7 +200,7 @@ async fn single_transaction() {
})
.await;

assert_eq!(ask_certificate.outgoing_message_count(), 3);
assert_eq!(ask_certificate.outgoing_message_count(), 2);
ask_certificates.push(ask_certificate);
}

Expand Down Expand Up @@ -263,7 +252,7 @@ async fn single_transaction() {
block.with_operation(matching_id, operation);
})
.await;
assert_eq!(order_certificate.outgoing_message_count(), 2);
assert_eq!(order_certificate.outgoing_message_count(), 1);
matching_chain
.add_block(|block| {
block.with_messages_from(&order_certificate);
Expand Down
Loading

0 comments on commit 3ba41da

Please sign in to comment.