Skip to content

Commit

Permalink
chore: update replica da2e149 -> ee1de3c (dfinity#1830)
Browse files Browse the repository at this point in the history
- Update replica to commit ee1de3c15c9459ed5007c78442621b5a7e43c620 (origin/rc--2021-10-05_18-32)
  - Note that this replica reports its status (responds to ping) before it is healthy 
- `dfx start --background` now waits until status reports healthy
- `dfx ping --wait-healthy` waits up to 60s for replica to become healthy.
- widened replica actor timeout because replica can take longer to start up

See also dfinity/docs#617
  • Loading branch information
ericswanson-dfinity authored Oct 6, 2021
1 parent 63237e4 commit 1184b2a
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 31 deletions.
11 changes: 11 additions & 0 deletions .github/CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ nix-build ci/ci.nix -A dfx[.x86_64-linux|.x86_64-darwin]

== Dependencies

=== Updating the Replica

To update the replica to a given $SHA from the dfinity repo, execute the following:
[source,bash]
----
niv update ic-starter-x86_64-darwin -a rev=$SHA
niv update ic-starter-x86_64-linux -a rev=$SHA
niv update replica-x86_64-darwin -a rev=$SHA
niv update replica-x86_64-linux -a rev=$SHA
----

=== Licenses

https://hydra.oregon.dfinity.build/latest/dfinity-ci-build/sdk/licenses.dfx.x86_64-linux/licenses.dfinity-sdk-dfx.html[Latest licenses of all dependencies of dfx (build for x86_64-linux)].
21 changes: 21 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ Updated the maximum value for the --memory-allocation value to be 12 GiB (12,884

You will need to upgrade your wallet with `dfx wallet upgrade`, or `dfx wallet --network ic upgrade`

== Replica

The included replica now supports public spec 0.18.0

* Canisters can now have more than one controller
* Adds support for 64-bit stable memory
* The replica now goes through an initialization sequence, reported in its status
as `replica_health_status`. Until this reports as `healthy`, queries or updates will
fail.
** `dfx start --background` waits to exit until `replica_health_status` is `healthy`.
** If you run `dfx start` without `--background`, you can call `dfx ping --wait-healthy`
to wait until the replica is healthy.

== Motoko

Updated Motoko from 0.6.7 to 0.6.10

* add Debug.trap : Text -> None (motoko-base #288)
* Introduce primitives for `Int` ⇔ `Float` conversions (#2733)
* Fix crashing bug for formatting huge floats (#2737)

= 0.8.1

== DFX
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ members = [
[patch.crates-io.ic-agent]
version = "0.8.0"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"

[patch.crates-io.ic-asset]
version = "0.3.0"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"

[patch.crates-io.ic-identity-hsm]
version = "0.3.5"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"

[patch.crates-io.ic-utils]
version = "0.6.0"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"
2 changes: 2 additions & 0 deletions e2e/tests-dfx/start.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ teardown() {
timeout 15s sh -c \
'until dfx ping; do echo waiting for replica to restart; sleep 1; done' \
|| (echo "replica did not restart" && ps aux && exit 1)
wait_until_replica_healthy

assert_command dfx canister call hello greet '("Omega")'
assert_eq '("Hello, Omega!")'
Expand Down Expand Up @@ -88,6 +89,7 @@ teardown() {
timeout 15s sh -c \
'until dfx ping; do echo waiting for replica to restart; sleep 1; done' \
|| (echo "replica did not restart" && ps aux && exit 1)
wait_until_replica_healthy

assert_command dfx canister call hello greet '("Omega")'
assert_eq '("Hello, Omega!")'
Expand Down
12 changes: 12 additions & 0 deletions e2e/utils/_.bash
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ dfx_start() {
|| (echo "could not connect to replica on port ${port}" && exit 1)
}

wait_until_replica_healthy() {
echo "waiting for replica to become healthy"
(
# dfx ping has side effects, like creating a default identity.
DFX_CONFIG_ROOT="$DFX_E2E_TEMP_DIR/dfx-ping-tmp"
dfx ping --wait-healthy
)
echo "replica became healthy"
}

# Start the replica in the background.
dfx_start_replica_and_bootstrap() {
dfx_patchelf
Expand Down Expand Up @@ -163,6 +173,8 @@ dfx_start_replica_and_bootstrap() {
"until nc -z localhost ${replica_port}; do echo waiting for replica; sleep 1; done" \
|| (echo "could not connect to replica on port ${replica_port}" && exit 1)

wait_until_replica_healthy

# This only works because we use the network by name
# (implicitly: --network local)
# If we passed --network http://127.0.0.1:${replica_port}
Expand Down
3 changes: 3 additions & 0 deletions e2e/utils/assertions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,13 @@ assert_process_exits() {
pid="$1"
timeout="$2"

echo "waiting up to $timeout seconds for process $pid to exit"

timeout $timeout sh -c \
"while kill -0 $pid; do echo waiting for process $pid to exit; sleep 1; done" \
|| (echo "process $pid did not exit" && ps aux && exit 1)

echo "process $pid exited"
}

# Asserts that `dfx start` and `replica` are no longer running
Expand Down
26 changes: 13 additions & 13 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"agent-rs": {
"branch": "main",
"repo": "https://github.com/dfinity/agent-rs",
"rev": "0cdb7e9cbd44afb368506cd6fd0febee1686316d",
"rev": "0a362053e23f67ede1144b773f6e9f68b2a8a0d6",
"type": "git"
},
"bats-support": {
Expand Down Expand Up @@ -45,18 +45,18 @@
},
"ic-starter-x86_64-darwin": {
"builtin": false,
"rev": "da2e149cbee5f98905e5a0126d0919be12a7c29d",
"sha256": "0hpa0j8gll7bk7rx8jh1y5ad8x5y2pg3bishr1ayi3rardnn2shk",
"rev": "ee1de3c15c9459ed5007c78442621b5a7e43c620",
"sha256": "13kaz9zj38snprzfvj68jxs4ff5yxi9lhifkzs47c6wy8axbz2h7",
"type": "file",
"url": "https://download.dfinity.systems/ic/da2e149cbee5f98905e5a0126d0919be12a7c29d/nix-release/x86_64-darwin/ic-starter.gz",
"url": "https://download.dfinity.systems/ic/ee1de3c15c9459ed5007c78442621b5a7e43c620/nix-release/x86_64-darwin/ic-starter.gz",
"url_template": "https://download.dfinity.systems/ic/<rev>/nix-release/x86_64-darwin/ic-starter.gz"
},
"ic-starter-x86_64-linux": {
"builtin": false,
"rev": "da2e149cbee5f98905e5a0126d0919be12a7c29d",
"sha256": "1bx2j7kcii4s20i6cn2hlwkg3wbjz9xzhifz39ynsij0q1z03ka5",
"rev": "ee1de3c15c9459ed5007c78442621b5a7e43c620",
"sha256": "08ryri2lbw7y2jx0nzg1wv26gkiby3xjq6hg8if33ilw2rrbzs4k",
"type": "file",
"url": "https://download.dfinity.systems/ic/da2e149cbee5f98905e5a0126d0919be12a7c29d/nix-release/ic-starter.gz",
"url": "https://download.dfinity.systems/ic/ee1de3c15c9459ed5007c78442621b5a7e43c620/nix-release/ic-starter.gz",
"url_template": "https://download.dfinity.systems/ic/<rev>/nix-release/ic-starter.gz"
},
"motoko": {
Expand All @@ -81,18 +81,18 @@
},
"replica-x86_64-darwin": {
"builtin": false,
"rev": "da2e149cbee5f98905e5a0126d0919be12a7c29d",
"sha256": "0hzx6kivkcyn8cw9qqfy6nhz60akjifnj7zx0dz31p91jmnrbjzs",
"rev": "ee1de3c15c9459ed5007c78442621b5a7e43c620",
"sha256": "0dwifs75l59287ff7vhb1dpvh0z0i41nxzm2d609ap933fpvs17a",
"type": "file",
"url": "https://download.dfinity.systems/ic/da2e149cbee5f98905e5a0126d0919be12a7c29d/nix-release/x86_64-darwin/replica.gz",
"url": "https://download.dfinity.systems/ic/ee1de3c15c9459ed5007c78442621b5a7e43c620/nix-release/x86_64-darwin/replica.gz",
"url_template": "https://download.dfinity.systems/ic/<rev>/nix-release/x86_64-darwin/replica.gz"
},
"replica-x86_64-linux": {
"builtin": false,
"rev": "da2e149cbee5f98905e5a0126d0919be12a7c29d",
"sha256": "0xlqbvw9yz88wc8xd1kndsvx477ijq6shy52z44lwbrj6g2w7bzl",
"rev": "ee1de3c15c9459ed5007c78442621b5a7e43c620",
"sha256": "0yjm4qsi0r7q90brgz14pisggg1bcsnsdlk9zs34sm6rl1inqwr1",
"type": "file",
"url": "https://download.dfinity.systems/ic/da2e149cbee5f98905e5a0126d0919be12a7c29d/nix-release/replica.gz",
"url": "https://download.dfinity.systems/ic/ee1de3c15c9459ed5007c78442621b5a7e43c620/nix-release/replica.gz",
"url_template": "https://download.dfinity.systems/ic/<rev>/nix-release/replica.gz"
}
}
8 changes: 4 additions & 4 deletions src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ webpki-roots = "0.21.0"
[dependencies.ic-agent]
version = "0.8.0"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"
features = ["reqwest"]

[dependencies.ic-asset]
version = "0.3.0"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"

[dependencies.ic-identity-hsm]
version = "0.3.5"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"

[dependencies.ic-utils]
version = "0.6.0"
git = "https://github.com/dfinity/agent-rs.git"
rev = "0cdb7e9cbd44afb368506cd6fd0febee1686316d"
rev = "0a362053e23f67ede1144b773f6e9f68b2a8a0d6"

[dev-dependencies]
env_logger = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/actors/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Replica {
// Use a Waiter for waiting for the file to be created.
let mut waiter = Delay::builder()
.throttle(Duration::from_millis(100))
.timeout(Duration::from_secs(30))
.timeout(Duration::from_secs(120))
.build();

waiter.start();
Expand Down
37 changes: 35 additions & 2 deletions src/dfx/src/commands/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::util::expiry_duration;

use anyhow::anyhow;
use clap::Clap;
use garcon::{Delay, Waiter};
use slog::warn;
use tokio::runtime::Runtime;

Expand All @@ -20,6 +21,10 @@ pub struct PingOpts {
/// ephemeral network will be created specifically for this request. E.g.
/// "http://localhost:12345/" is a valid network name.
network: Option<String>,

/// Repeatedly ping until the replica is healthy
#[clap(long)]
wait_healthy: bool,
}

pub fn exec(env: &dyn Environment, opts: PingOpts) -> DfxResult {
Expand Down Expand Up @@ -51,8 +56,36 @@ pub fn exec(env: &dyn Environment, opts: PingOpts) -> DfxResult {
.ok_or_else(|| anyhow!("Cannot find dfx configuration file in the current working directory. Did you forget to create one?"))?;

let runtime = Runtime::new().expect("Unable to create a runtime");
let status = runtime.block_on(agent.status())?;
println!("{}", status);
if opts.wait_healthy {
let mut waiter = Delay::builder()
.timeout(std::time::Duration::from_secs(60))
.throttle(std::time::Duration::from_secs(1))
.build();
waiter.start();

loop {
let status = runtime.block_on(agent.status());
if let Ok(status) = status {
let healthy = match &status.replica_health_status {
Some(s) if s == "healthy" => true,
None => true,
_ => false,
};
if healthy {
println!("{}", status);
break;
} else {
eprintln!("{}", status);
}
}
waiter
.wait()
.map_err(|_| anyhow!("Timed out waiting for replica to become healthy"))?;
}
} else {
let status = runtime.block_on(agent.status())?;
println!("{}", status);
}

Ok(())
}
13 changes: 10 additions & 3 deletions src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,23 @@ fn ping_and_wait(frontend_url: &str) -> DfxResult {

// wait for frontend to come up
let mut waiter = Delay::builder()
.timeout(std::time::Duration::from_secs(30))
.timeout(std::time::Duration::from_secs(60))
.throttle(std::time::Duration::from_secs(1))
.build();

runtime.block_on(async {
waiter.start();
loop {
let status = agent.status().await;
if status.is_ok() {
break;
if let Ok(status) = &status {
let healthy = match &status.replica_health_status {
Some(status) if status == "healthy" => true,
None => true, // emulator doesn't report replica_health_status
_ => false,
};
if healthy {
break;
}
}
waiter
.wait()
Expand Down

0 comments on commit 1184b2a

Please sign in to comment.