Skip to content

Commit

Permalink
Remove notify message (#2402)
Browse files Browse the repository at this point in the history
* Remove the Notify message.

* Remove an unnecessary allocation.

* Update application IDs in README files.

* Fix SDK tests to not expect the Notify message.
  • Loading branch information
afck authored Aug 22, 2024
1 parent 98609fb commit f3deb6a
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 88 deletions.
6 changes: 3 additions & 3 deletions examples/hex-game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sleep 1
The `start` mutation starts a new game. We specify the two players using their new public keys,
on [`http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`][main_chain]:

```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
mutation {
start(
players: [
Expand All @@ -89,7 +89,7 @@ mutation {

The app's main chain keeps track of the games in progress, by public key:

```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
query {
gameChains {
keys(count: 3)
Expand All @@ -99,7 +99,7 @@ query {

It contains the temporary chain's ID, and the ID of the message that created it:

```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
query {
gameChains {
entry(key: "8a21aedaef74697db8b676c3e03ddf965bf4a808dc2bcabb6d70d6e6e3022ff7") {
Expand Down
6 changes: 3 additions & 3 deletions examples/hex-game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sleep 1
The `start` mutation starts a new game. We specify the two players using their new public keys,
on [`http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`][main_chain]:
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
mutation {
start(
players: [
Expand All @@ -93,7 +93,7 @@ mutation {
The app's main chain keeps track of the games in progress, by public key:
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
query {
gameChains {
keys(count: 3)
Expand All @@ -103,7 +103,7 @@ query {
It contains the temporary chain's ID, and the ID of the message that created it:
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
query {
gameChains {
entry(key: "8a21aedaef74697db8b676c3e03ddf965bf4a808dc2bcabb6d70d6e6e3022ff7") {
Expand Down
14 changes: 7 additions & 7 deletions examples/social/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ linera --with-wallet 0 project publish-and-create examples/social
This will output the new application ID, e.g.:

```rust
e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```

With the `wallet show` command you can find the ID of the application creator's chain:
Expand Down Expand Up @@ -88,7 +88,7 @@ one of the chain where it isn't registered yet:
mutation {
requestApplication(
chainId: "1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03",
applicationId: "e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000"
applicationId: "e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000"
)
}
```
Expand All @@ -108,20 +108,20 @@ query {
```

Open both URLs under the entry `link`. Now you can use the application on each chain.
E.g. [in the 8081 tab](http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000)
E.g. [in the 8081 tab](http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000)
subscribe to the other chain:

```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
mutation {
subscribe(
chainId: "e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65"
)
}
```

Now make a post [in the 8080 tab](http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000):
Now make a post [in the 8080 tab](http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000):

```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
mutation {
post(
text: "Linera Social is the new Mastodon!"
Expand All @@ -132,7 +132,7 @@ mutation {

Since 8081 is a subscriber. Let's see if it received any posts: # You can see the post on running the [web-frontend](./web-frontend/), or follow the steps below.

```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
query { receivedPosts { keys { timestamp author index } } }
```

Expand Down
14 changes: 7 additions & 7 deletions examples/social/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ linera --with-wallet 0 project publish-and-create examples/social
This will output the new application ID, e.g.:
```ignore
e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```
With the `wallet show` command you can find the ID of the application creator's chain:
Expand Down Expand Up @@ -97,7 +97,7 @@ one of the chain where it isn't registered yet:
mutation {
requestApplication(
chainId: "1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03",
applicationId: "e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000"
applicationId: "e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000"
)
}
```
Expand All @@ -117,20 +117,20 @@ query {
```
Open both URLs under the entry `link`. Now you can use the application on each chain.
E.g. [in the 8081 tab](http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000)
E.g. [in the 8081 tab](http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000)
subscribe to the other chain:
```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
mutation {
subscribe(
chainId: "e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65"
)
}
```
Now make a post [in the 8080 tab](http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000):
Now make a post [in the 8080 tab](http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000):
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8080/chains/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
mutation {
post(
text: "Linera Social is the new Mastodon!"
Expand All @@ -141,7 +141,7 @@ mutation {
Since 8081 is a subscriber. Let's see if it received any posts: # You can see the post on running the [web-frontend](./web-frontend/), or follow the steps below.
```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000001000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
```gql,uri=http://localhost:8081/chains/1db1936dad0717597a7743a8353c9c0191c14c3a129b258e9743aec2b4f05d03/applications/e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65010000000000000000000000e476187f6ddfeb9d588c7b45d3df334d5501d6499b3f9ad5595cae86cce16a65030000000000000000000000
query { receivedPosts { keys { timestamp author index } } }
```
Expand Down
9 changes: 4 additions & 5 deletions linera-chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,15 @@ where
}
let full_names = raw_outcome
.subscribe
.clone()
.into_iter()
.iter()
.map(|(name, _id)| ChannelFullName {
application_id,
name,
name: name.clone(),
})
.collect::<Vec<_>>();
let channels = self.channels.try_load_entries_mut(&full_names).await?;
let stream = raw_outcome.subscribe.into_iter().zip(channels);
let stream = stream::iter(stream)
let subscribe_channels = raw_outcome.subscribe.into_iter().zip(channels);
let stream = stream::iter(subscribe_channels)
.map(|((name, id), mut channel)| async move {
let mut result = None;
let full_name = ChannelFullName {
Expand Down
11 changes: 1 addition & 10 deletions linera-core/src/unit_tests/wasm_worker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,7 @@ where
let publisher_state_hash = publisher_system_state.into_hash().await;
let accept_block_proposal = HashedCertificateValue::new_confirmed(
BlockExecutionOutcome {
messages: vec![vec![OutgoingMessage {
destination: Destination::Recipient(creator_chain.into()),
authenticated_signer: None,
grant: Amount::ZERO,
refund_grant_to: None,
kind: MessageKind::Protected,
message: Message::System(SystemMessage::Notify {
id: creator_chain.into(),
}),
}]],
messages: vec![Vec::new()],
events: vec![Vec::new()],
state_hash: publisher_state_hash,
oracle_responses: vec![Vec::new()],
Expand Down
30 changes: 6 additions & 24 deletions linera-core/src/unit_tests/worker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2399,11 +2399,7 @@ where
&worker,
HashedCertificateValue::new_confirmed(
BlockExecutionOutcome {
messages: vec![vec![direct_outgoing_message(
user_id,
MessageKind::Protected,
SystemMessage::Notify { id: user_id },
)]],
messages: vec![Vec::new()],
events: vec![Vec::new()],
state_hash: SystemExecutionState {
// The root chain knows both committees at the end.
Expand Down Expand Up @@ -2489,13 +2485,11 @@ where
.added_bundles
.read_front(10)
.await?[..],
[bundle1, bundle2, bundle3]
[bundle1, bundle2]
if matches!(bundle1.messages[..], [PostedMessage {
message: Message::System(SystemMessage::OpenChain(_)), ..
}]) && matches!(bundle2.messages[..], [PostedMessage {
message: Message::System(SystemMessage::Credit { .. }), ..
}]) && matches!(bundle3.messages[..], [PostedMessage {
message: Message::System(SystemMessage::Notify { .. }), ..
}])
);
let channel_inbox = user_chain
Expand All @@ -2517,8 +2511,8 @@ where
&worker,
HashedCertificateValue::new_confirmed(
BlockExecutionOutcome {
messages: vec![Vec::new(); 4],
events: vec![Vec::new(); 4],
messages: vec![Vec::new(); 3],
events: vec![Vec::new(); 3],
state_hash: SystemExecutionState {
subscriptions: [ChannelSubscription {
chain_id: admin_id,
Expand All @@ -2534,7 +2528,7 @@ where
}
.into_hash()
.await,
oracle_responses: vec![Vec::new(); 4],
oracle_responses: vec![Vec::new(); 3],
}
.with(
make_first_block(user_id)
Expand Down Expand Up @@ -2585,18 +2579,6 @@ where
.to_posted(1, MessageKind::Tracked)],
},
action: MessageAction::Accept,
})
.with_incoming_bundle(IncomingBundle {
origin: Origin::chain(admin_id),
bundle: MessageBundle {
certificate_hash: certificate2.value.hash(),
height: BlockHeight::from(2),
timestamp: Timestamp::from(0),
transaction_index: 0,
messages: vec![Message::System(SystemMessage::Notify { id: user_id })
.to_posted(0, MessageKind::Protected)],
},
action: MessageAction::Accept,
}),
),
),
Expand Down Expand Up @@ -2633,7 +2615,7 @@ where
.try_load_entry(&Origin::chain(admin_id))
.await?
.expect("Missing inbox for admin chain in user chain");
assert_eq!(inbox.next_block_height_to_receive()?, BlockHeight(3));
assert_eq!(inbox.next_block_height_to_receive()?, BlockHeight(2));
assert_eq!(inbox.added_bundles.count(), 0);
assert_eq!(inbox.removed_bundles.count(), 0);
}
Expand Down
Loading

0 comments on commit f3deb6a

Please sign in to comment.