Skip to content

Commit

Permalink
Merge pull request #3 from AstarNetwork/default-instant-seal
Browse files Browse the repository at this point in the history
Use instant seal by default
  • Loading branch information
shunsukew authored May 17, 2022
2 parents 1677a63 + dd9f49e commit eef207b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 75 deletions.
7 changes: 0 additions & 7 deletions .envrc

This file was deleted.

26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ Swanky node is the Substrate based blockchain configured to enable `pallet-contr

Follow the steps below to get started with the swanky node :hammer_and_wrench:

### Using Nix

Install [nix](https://nixos.org/) and optionally [direnv](https://github.com/direnv/direnv) and
[lorri](https://github.com/target/lorri) for a fully plug and play experience for setting up the
development environment. To get all the correct dependencies activate direnv `direnv allow` and
lorri `lorri shell`.

### Rust Setup

First, complete the [basic Rust setup instructions](./docs/rust-setup.md).
Expand Down Expand Up @@ -146,11 +139,21 @@ Unlike other blockchains, Swanky node adopts block authioring and finalized gadg
Manual seal: Where there is one author and it authors a block whenever you tell it via an RPC call.
Instant seal: Where there is one author and it attempts to author a block as soon as it sees a transaction in the pool, most often leading to one transaction per block

### Using Manual Seal
By default, instant seal is used.

### Using Instant Seal
```bash
./target/release/swanky-node --dev
```

As soon as transaction gets pooled, blocks are instantly created.


### Using Manual Seal
```bash
./target/release/swanky-node --dev --manual-seal
```

Once your node is running, you will see that it just sits there idly. It will accept transactions to the pool, but it will not author blocks on its own. In manual seal, the node does not author a block until we explicitly tell it to. We can tell it to author a block by calling the `engine_createBlock` RPC.

```bash
Expand Down Expand Up @@ -183,10 +186,3 @@ $ curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d
"params": ["0x0e0626477621754200486f323e3858cd5f28fcbe52c69b2581aecb622e384764", null]
}'
```

### Using Instant Seal
```bash
./target/release/swanky-node --dev --instant-seal
```

As soon as transaction gets pooled, blocks are instantly created.
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct Cli {
pub run: RunCmd,

#[clap(long)]
pub instant_seal: bool,
pub manual_seal: bool,
}

#[derive(Debug, clap::Subcommand)]
Expand Down
4 changes: 2 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ pub fn run() -> sc_cli::Result<()> {
You can enable it with `--features try-runtime`."
.into()),
None => {
let instant_seal = cli.instant_seal;
let manual_seal = cli.manual_seal;
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
service::new_full(config, instant_seal).map_err(sc_cli::Error::Service)
service::new_full(config, manual_seal).map_err(sc_cli::Error::Service)
})
},
}
Expand Down
8 changes: 4 additions & 4 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub struct FullDeps<C, P> {
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// If instant seal or manaul seal
pub instant_seal: bool,
/// If manual seal or manaul seal
pub manual_seal: bool,
/// A command stream to send authoring commands to manual seal consensus engine
pub command_sink: Sender<EngineCommand<Hash>>,
}
Expand All @@ -51,7 +51,7 @@ where
use substrate_frame_rpc_system::{FullSystem, SystemApi};

let mut io = jsonrpc_core::IoHandler::default();
let FullDeps { client, pool, deny_unsafe, instant_seal, command_sink } = deps;
let FullDeps { client, pool, deny_unsafe, manual_seal, command_sink } = deps;

io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));

Expand All @@ -64,7 +64,7 @@ where
// to call into the runtime.
// `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));`

if !instant_seal {
if manual_seal {
// The final RPC extension receives commands for the manual seal consensus engine.
io.extend_with(
// We provide the rpc handler with the sending end of the channel to allow the rpc
Expand Down
22 changes: 11 additions & 11 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
}

/// Builds a new service for a full client.
pub fn new_full(config: Configuration, instant_seal: bool) -> Result<TaskManager, ServiceError> {
pub fn new_full(config: Configuration, manual_seal: bool) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
client,
backend,
Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn new_full(config: Configuration, instant_seal: bool) -> Result<TaskManager
client: client.clone(),
pool: pool.clone(),
deny_unsafe,
instant_seal,
manual_seal,
command_sink: command_sink.clone(),
};

Expand Down Expand Up @@ -199,41 +199,41 @@ pub fn new_full(config: Configuration, instant_seal: bool) -> Result<TaskManager
telemetry.as_ref().map(|x| x.handle()),
);

if instant_seal {
let params = sc_consensus_manual_seal::InstantSealParams {
if manual_seal {
let params = sc_consensus_manual_seal::ManualSealParams {
block_import: client.clone(),
env: proposer,
client,
pool: transaction_pool,
commands_stream,
select_chain,
consensus_data_provider: None,
create_inherent_data_providers: move |_, ()| async move {
Ok(sp_timestamp::InherentDataProvider::from_system_time())
},
};

task_manager.spawn_essential_handle().spawn_blocking(
"instant-seal",
"manual-seal",
None,
sc_consensus_manual_seal::run_instant_seal(params),
sc_consensus_manual_seal::run_manual_seal(params),
);
} else {
let params = sc_consensus_manual_seal::ManualSealParams {
let params = sc_consensus_manual_seal::InstantSealParams {
block_import: client.clone(),
env: proposer,
client,
pool: transaction_pool,
commands_stream,
select_chain,
consensus_data_provider: None,
create_inherent_data_providers: move |_, ()| async move {
Ok(sp_timestamp::InherentDataProvider::from_system_time())
},
};

task_manager.spawn_essential_handle().spawn_blocking(
"manual-seal",
"instant-seal",
None,
sc_consensus_manual_seal::run_manual_seal(params),
sc_consensus_manual_seal::run_instant_seal(params),
);
};

Expand Down
35 changes: 0 additions & 35 deletions shell.nix

This file was deleted.

0 comments on commit eef207b

Please sign in to comment.