Skip to content

Commit

Permalink
chore: remove dfx start --emulator mode (#3509)
Browse files Browse the repository at this point in the history
Remove the `dfx start --emulator` mode, which we deprecated in dfx 0.15.1

Fixes https://dfinity.atlassian.net/browse/SDK-1321
  • Loading branch information
ericswanson-dfinity authored Jan 17, 2024
1 parent cda396c commit 8d9bd8d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 344 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

The `dfx cycles` command no longer needs nor accepts the `--cycles-ledger-canister-id <canister id>` parameter.

### chore: removed the dfx start --emulator mode

This was deprecated in dfx 0.15.1.

### chore: removed ic-ref from the binary cache

### chore: updated dependencies for new rust projects
Expand Down
1 change: 0 additions & 1 deletion docs/cli-reference/dfx-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ You can use the following optional flags with the `dfx start` command.
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--background` | Starts the local canister execution environment and web server processes in the background and waits for a reply before returning to the shell. |
| `--clean` | Starts the local canister execution environment and web server processes in a clean state by removing checkpoints from your project cache. You can use this flag to set your project cache to a new state when troubleshooting or debugging. |
| `--emulator` | Starts the [IC reference emulator](https://github.com/dfinity/ic-hs) rather than the replica. (deprecated: will be discontinued soon) |
| `--enable-bitcoin` | Enables bitcoin integration. |
| `--enable-canister-http` | Enables canister HTTP requests. (deprecated: now enabled by default) |
| `--use-old-metering` | Enables the old metering in the local canister execution environment. Please see the forum thread for more details or to report any issues: [forum.dfinity.org/t/new-wasm-instrumentation/](https://forum.dfinity.org/t/new-wasm-instrumentation/22080) |
Expand Down
18 changes: 2 additions & 16 deletions src/dfx-core/src/config/model/local_server_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ impl LocalServerDescriptor {
self.data_directory.join("icx-proxy-pid")
}

/// This file contains the listening port of the ic-ref process
pub fn ic_ref_port_path(&self) -> PathBuf {
self.data_directory.join("ic-ref.port")
}

/// This file contains the pid of the ic-btc-adapter process
pub fn btc_adapter_pid_path(&self) -> PathBuf {
self.data_directory.join("ic-btc-adapter-pid")
Expand Down Expand Up @@ -297,12 +292,11 @@ impl LocalServerDescriptor {
/// Gets the port of a local replica.
///
/// # Prerequisites
/// - A local replica or emulator needs to be running, e.g. with `dfx start`.
/// - A local replica needs to be running, e.g. with `dfx start`.
pub fn get_running_replica_port(
&self,
logger: Option<&Logger>,
) -> Result<Option<u16>, NetworkConfigError> {
let emulator_port_path = self.ic_ref_port_path();
let replica_port_path = self.replica_port_path();

match read_port_from(&replica_port_path)? {
Expand All @@ -312,15 +306,7 @@ impl LocalServerDescriptor {
}
Ok(Some(port))
}
None => match read_port_from(&emulator_port_path)? {
Some(port) => {
if let Some(logger) = logger {
info!(logger, "Found local emulator running on port {}", port);
}
Ok(Some(port))
}
None => Ok(self.replica.port),
},
None => Ok(self.replica.port),
}
}
}
Expand Down
245 changes: 0 additions & 245 deletions src/dfx/src/actors/emulator.rs

This file was deleted.

33 changes: 0 additions & 33 deletions src/dfx/src/actors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::actors;
use crate::actors::btc_adapter::signals::BtcAdapterReadySubscribe;
use crate::actors::btc_adapter::BtcAdapter;
use crate::actors::canister_http_adapter::signals::CanisterHttpAdapterReadySubscribe;
use crate::actors::canister_http_adapter::CanisterHttpAdapter;
use crate::actors::emulator::Emulator;
use crate::actors::icx_proxy::signals::PortReadySubscribe;
use crate::actors::icx_proxy::{IcxProxy, IcxProxyConfig};
use crate::actors::replica::{BitcoinIntegrationConfig, Replica};
Expand All @@ -20,7 +18,6 @@ use std::path::PathBuf;

pub mod btc_adapter;
pub mod canister_http_adapter;
pub mod emulator;
pub mod icx_proxy;
pub mod replica;
mod shutdown;
Expand Down Expand Up @@ -82,36 +79,6 @@ pub fn start_canister_http_adapter_actor(
Ok(CanisterHttpAdapter::new(actor_config).start().recipient())
}

#[context("Failed to start emulator actor.")]
pub fn start_emulator_actor(
env: &dyn Environment,
local_server_descriptor: &LocalServerDescriptor,
shutdown_controller: Addr<ShutdownController>,
emulator_port_path: PathBuf,
) -> DfxResult<Addr<Emulator>> {
let ic_ref_path = env.get_cache().get_binary_command_path("ic-ref")?;

// Touch the port file. This ensures it is empty prior to
// handing it over to ic-ref. If we read the file and it has
// contents we shall assume it is due to our spawned ic-ref
// process.
std::fs::write(&emulator_port_path, "").with_context(|| {
format!(
"Failed to write/clear emulator port file {}.",
emulator_port_path.to_string_lossy()
)
})?;

let actor_config = actors::emulator::Config {
ic_ref_path,
port: local_server_descriptor.replica.port,
write_port_to: emulator_port_path,
shutdown_controller,
logger: Some(env.get_logger().clone()),
};
Ok(actors::emulator::Emulator::new(actor_config).start())
}

#[context("Failed to setup replica environment.")]
fn setup_replica_env(
local_server_descriptor: &LocalServerDescriptor,
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/actors/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn wait_for_child_or_receiver(
loop {
// Check if either the child exited or a shutdown has been requested.
// These can happen in either order in response to Ctrl-C, so increase the chance
// to notice a shutdown request even if the emulator exited quickly.
// to notice a shutdown request even if the replica exited quickly.
let child_try_wait = child.try_wait();
let receiver_signalled = receiver.recv_timeout(std::time::Duration::from_millis(100));

Expand Down
Loading

0 comments on commit 8d9bd8d

Please sign in to comment.