• Frank Bell's avatar
    feat: delayed finalization (#214) · 813d99f4
    Frank Bell authored
    Adds `--finalize-delay-sec` cli argument, based on the great work by
    @shunsukew at https://github.com/inkdevhub/swanky-node/pull/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
    813d99f4