Skip to content

Conversation

@shunsukew
Copy link
Collaborator

@shunsukew shunsukew commented Apr 24, 2023

Provide --finalize-delay-sec <sec> option for finalizing blocks.
Setting to 0 mean instant finalization.

Note that, without providing --finalize-delay-sec, blocks won't be finalized unless you do it manually by RPC call.

.await
}

pub async fn run_delayed_finalize<B, CB, C>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What matters in client/consensus/manual-seal package is this section.
Others are just copied from Substrate repo here.

Copy link
Contributor

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add more info in the readme ?
ex:
How to instant seal ?
How to set 1 sec blocktime

@shunsukew
Copy link
Collaborator Author

Can you add more info in the readme ? ex: How to instant seal ? How to set 1 sec blocktime

Updated README!

@shunsukew shunsukew merged commit e38181f into main Apr 26, 2023
shunsukew added a commit to inkdevhub/swanky-cli that referenced this pull request May 1, 2023
Updated swanky node version to support `--finalize-delay-sec` 

swanky-node companion
inkdevhub/swanky-node#61
evilrobot-01 pushed a commit to paritytech/substrate-contracts-node that referenced this pull request Nov 7, 2023
athei pushed a commit to paritytech/substrate-contracts-node that referenced this pull request Nov 29, 2023
Adds `--finalize-delay-sec` cli argument, based on the great work by
@shunsukew at inkdevhub/swanky-node#61.

Manual testing by starting node with/without option, along with example
contract upload:
```shell
# build example contract
cargo contract build --manifest-path=../ink-examples/erc20/Cargo.toml

# start node
cargo run

# upload contract
cargo contract upload --suri //Alice --execute --manifest-path=../ink-examples/erc20/Cargo.toml
# check finalized head remains at genesis
sleep 1
test $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chainHead_unstable_genesisHash", "params":[]}' http://localhost:9944 | jq .result) \
  = $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chain_getFinalizedHead", "params":[]}' http://localhost:9944 | jq .result) && echo PASS || echo FAIL


# start node (with delayed finalization)
cargo run -- --finalize-delay-sec 1

# upload contract
cargo contract upload --suri //Alice --execute --manifest-path=../ink-examples/erc20/Cargo.toml
# check finalized head matches chain head
sleep 1
test $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chain_getHead", "params":[]}' http://localhost:9944 | jq .result) \
  = $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chain_getFinalizedHead", "params":[]}' http://localhost:9944 | jq .result) && echo PASS || echo FAIL

```

Closes #160
isaiah86z added a commit to isaiah86z/substrate-contracts-node that referenced this pull request Sep 7, 2025
Adds `--finalize-delay-sec` cli argument, based on the great work by
@shunsukew at inkdevhub/swanky-node#61.

Manual testing by starting node with/without option, along with example
contract upload:
```shell
# build example contract
cargo contract build --manifest-path=../ink-examples/erc20/Cargo.toml

# start node
cargo run

# upload contract
cargo contract upload --suri //Alice --execute --manifest-path=../ink-examples/erc20/Cargo.toml
# check finalized head remains at genesis
sleep 1
test $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chainHead_unstable_genesisHash", "params":[]}' http://localhost:9944 | jq .result) \
  = $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chain_getFinalizedHead", "params":[]}' http://localhost:9944 | jq .result) && echo PASS || echo FAIL


# start node (with delayed finalization)
cargo run -- --finalize-delay-sec 1

# upload contract
cargo contract upload --suri //Alice --execute --manifest-path=../ink-examples/erc20/Cargo.toml
# check finalized head matches chain head
sleep 1
test $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chain_getHead", "params":[]}' http://localhost:9944 | jq .result) \
  = $(curl -sH "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "chain_getFinalizedHead", "params":[]}' http://localhost:9944 | jq .result) && echo PASS || echo FAIL

```

Closes #160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants