Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No empty blocks + Heartbeat #419

Closed
faddat opened this issue Nov 14, 2020 · 7 comments
Closed

No empty blocks + Heartbeat #419

faddat opened this issue Nov 14, 2020 · 7 comments
Assignees
Labels
type:bug Something isn't working

Comments

@faddat
Copy link
Contributor

faddat commented Nov 14, 2020

In resource constrained setups, like embedded computers, it may be desirable to tweak the Tendermint settings so that empty blocks are not produced.

- New `--consensus.create_empty_blocks` flag; when set to false, only creates blocks when there are txs or when the AppHash changes
- New `consensus.create_empty_blocks_interval` config option; when greater than 0, will create an empty block after waiting that many seconds

This also makes early stage blockchains grow less rapidly-- when there are no transactions, drastically fewer blocks will be produced, I'm wondering if we can make this a part of config.yml or the like.

  • Lower overall resource consumption
  • Less SD card wear & tear
  • More efficient, less talkative networks

My off-the-cuff thinking on this is that default should be true (as it is now)

For developers serious about embedded chains, ideal settings might be:

--consensus.create_empty_blocks true
consensus.create_empty_blocks_interval 180

Which would make an empty "heartbeat" block every three minutes.

@faddat
Copy link
Contributor Author

faddat commented Dec 4, 2020

This seems to work for launchpad:

clayd start --consensus.create_empty_blocks true --consensus.create_empty_blocks_interval 180s

I'll try it out on stargate, too.

root@sos ~/.clayd# clayd start --consensus.create_empty_blocks true --consensus.create_empty_blocks_interval 180s
I[2020-12-04|15:00:22.797] starting ABCI with Tendermint                module=main
I[2020-12-04|15:00:28.018] Executed block                               module=state height=1 validTxs=0 invalidTxs=0
I[2020-12-04|15:00:28.031] Committed state                              module=state height=1 txs=0 appHash=CB00C2BE57335C019B26B29D06F87B90D7CFD85128B66EC62C564D6C5D0B8719
I[2020-12-04|15:00:33.081] Executed block                               module=state height=2 validTxs=0 invalidTxs=0
I[2020-12-04|15:00:33.086] Committed state                              module=state height=2 txs=0 appHash=CB00C2BE57335C019B26B29D06F87B90D7CFD85128B66EC62C564D6C5D0B8719
I[2020-12-04|15:03:38.141] Executed block                               module=state height=3 validTxs=0 invalidTxs=0
I[2020-12-04|15:03:38.146] Committed state                              module=state height=3 txs=0 appHash=CB00C2BE57335C019B26B29D06F87B90D7CFD85128B66EC62C564D6C5D0B8719

We save resources and we get a nice reassuring heartbeat every three minutes. Not really sure why the second block came rapidly, but the third took its time like it should have.

@faddat faddat self-assigned this Dec 4, 2020
@fadeev
Copy link
Contributor

fadeev commented Dec 4, 2020

But does that require anything not included with Starport already?

config.yml:

init:
  config:
    consensus:
      create_empty_blocks_interval: "180s"

This does not work the way it supposed to for me on Stargate, but not because it hasn't been propagated to config.toml.

@faddat
Copy link
Contributor Author

faddat commented Dec 4, 2020

That's correct. I actually just tested with starport and it doesn't work, even if I use flags.

Screenshot_20201205-013902

This is a pretty desirable setup for pi-stuff, I will figure it out and check back inm

@faddat faddat added the type:bug Something isn't working label Dec 13, 2020
@faddat
Copy link
Contributor Author

faddat commented Dec 13, 2020

If you're some significant struggle getting the new version of gaia running and happy I can report that this seems like an issue that is confirmed to starport. When I start a gaia testnet, I can adjust the block times successfully.

The version of Gaia I'm using is here:

https://github.com/cosmos/gaia/tree/cosmoshub-test-stargate-e

What do we know?

  • Starport scaffolded chains fail to recognize the config option for the production of empty blocks
    • config.yml -> config.toml
  • When using the new version of Gaia, you can adjust as perimeter only once, when the chain is first started.
  • scaffolded chains work if fresh genesi, manually started with flags

There's discussion of removing consensus config/flag options at the tendermint repo, here:

tendermint/tendermint#2920

I am not 100% certain that this is that, but it certainly sounds like it could be.

Perhaps changes have been made in tendermint, and new gaia is using a different version of tendermint?

Will check....

@faddat
Copy link
Contributor Author

faddat commented Dec 13, 2020

Starport based infra when launched using starport:

faddat@Jacobs-MacBook-Pro ~/D/s/b/infra (master) [SIGINT]> infrad start  --consensus.create_empty_blocks_interval 5s
I[2020-12-14|03:29:28.505] starting ABCI with Tendermint                module=main 
E[2020-12-14|03:29:28.947] Error on catchup replay. Proceeding to start State anyway module=consensus err="cannot replay height 439. WAL does not contain #ENDHEIGHT for 438"
I[2020-12-14|03:29:28.947] Starting StateSync service                   module=statesync impl=StateSync
I[2020-12-14|03:29:30.050] Executed block                               module=state height=439 validTxs=0 invalidTxs=0
I[2020-12-14|03:29:30.069] Committed state                              module=state height=439 txs=0 appHash=25713499171089BA53A609235A9DFD76A12DAA54068D729591B4BE6FBA7BC1BA
I[2020-12-14|03:29:31.170] Executed block                               module=state height=440 validTxs=0 invalidTxs=0
I[2020-12-14|03:29:31.184] Committed state                              module=state height=440 txs=0 appHash=9965E6ED1DDEF745CAB43C0EC649504B89C21FE36E010CCEE7CC1F2C475C01CC
I[2020-12-14|03:29:32.270] Executed block                               module=state height=441 validTxs=0 invalidTxs=0
I[2020-12-14|03:29:32.283] Committed state                              module=state height=441 txs=0 appHash=F993019416D1420FC0D792052A87A95A11E81563DCCAFC43CCEEB96D988004F0
I[2020-12-14|03:29:33.370] Executed block                               module=state height=442 validTxs=0 invalidTxs=0
I[2020-12-14|03:29:33.374] Committed state                              module=state height=442 txs=0 appHash=ACF8502542D6E061ED9D7416F633BAB7E511AA09DCDDA7E38EF04521751C4133
I[2020-12-14|03:29:34.451] Executed block                               module=state height=443 validTxs=0 invalidTxs=0
I[2020-12-14|03:29:34.458] Committed state                              module=state height=443 txs=0 appHash=4C81C274C7128B7B0FD6004DD746A6F088DF8E2E896A087F35593FDAE781FD95
I[2020-12-14|03:29:35.555] Executed block                               module=state height=444 validTxs=0 invalidTxs=0
I[2020-12-14|03:29:35.560] Committed state                              module=state height=444 txs=0 appHash=0127650089BF7FF9677C85E5FBD511687B4635D656627E32B1EB1238720BEA93

Infra is making one block per second.

Gaia makes one every five seconds per our request:

faddat@Jacobs-MacBook-Pro ~/.gaia [1]> gaiad start --consensus.create_empty_blocks_interval 5s 
I[2020-12-14|04:05:03.590] starting ABCI with Tendermint                module=main 
I[2020-12-14|04:05:03.833] Starting StateSync service                   module=statesync impl=StateSync
I[2020-12-14|04:05:08.887] Executed block                               module=state height=1 validTxs=0 invalidTxs=0
I[2020-12-14|04:05:08.904] Committed state                              module=state height=1 txs=0 appHash=74953D140C9672A12FFB0A3E18EC557542BF855526AD1F478F107226046E6B07
I[2020-12-14|04:05:13.933] Executed block                               module=state height=2 validTxs=0 invalidTxs=0
I[2020-12-14|04:05:13.946] Committed state                              module=state height=2 txs=0 appHash=191F1EDD9A1B5DE1EE6AE567132BDC14322A35C28C6846DA3DC18A98C38D31BF
I[2020-12-14|04:05:18.964] Executed block                               module=state height=3 validTxs=0 invalidTxs=0
I[2020-12-14|04:05:18.974] Committed state                              module=state height=3 txs=0 appHash=7A35F9F21ABDD4455B8E00829B18DA47FEF78AD13BC53158EB70D02A4E43CB61
I[2020-12-14|04:05:24.015] Executed block                               module=state height=4 validTxs=0 invalidTxs=0
I[2020-12-14|04:05:24.024] Committed state                              module=state height=4 txs=0 appHash=B29BE295B0E4C07484DABA027627DF58434FDBA9CDE639513B58796DDD40D218
I[2020-12-14|04:05:29.049] Executed block                               module=state height=5 validTxs=0 invalidTxs=0
I[2020-12-14|04:05:29.057] Committed state                              module=state height=5 txs=0 appHash=8779BD69B233D51F857F94678427AC3815DB0C51533297EF5639E987A89330B9
I[2020-12-14|04:05:34.102] Executed block                               module=state height=6 validTxs=0 invalidTxs=0
I[2020-12-14|04:05:34.110] Committed state                              module=state height=6 txs=0 appHash=374B3F4C1ADC763CBF433A237502BA2B7B3D1AE73E09E27EF28585667536AF26
I[2020-12-14|04:05:39.152] Executed block                               module=state height=7 validTxs=0 invalidTxs=0

Gaia doesn't let us change this setting after genesis:

faddat@Jacobs-MacBook-Pro ~/.gaia [1]> gaiad start --consensus.create_empty_blocks_interval 30s
I[2020-12-14|04:06:14.640] starting ABCI with Tendermint                module=main 
I[2020-12-14|04:06:15.031] Starting StateSync service                   module=statesync impl=StateSync
I[2020-12-14|04:06:20.162] Executed block                               module=state height=13 validTxs=0 invalidTxs=0
I[2020-12-14|04:06:20.190] Committed state                              module=state height=13 txs=0 appHash=A6419C8B27674B57FF07A418A60D9E00EB1B4DFF89D713FFEC24679FDC7D8759
I[2020-12-14|04:06:25.246] Executed block                               module=state height=14 validTxs=0 invalidTxs=0
I[2020-12-14|04:06:25.259] Committed state                              module=state height=14 txs=0 appHash=9E5279A07550380CC85569CDA677443EBD2568D0548D435A627B0AD2D0CC9A8F
I[2020-12-14|04:06:30.331] Executed block                               module=state height=15 validTxs=0 invalidTxs=0
I[2020-12-14|04:06:30.341] Committed state                              module=state height=15 txs=0 appHash=52A728639C7F964B57276D2BE9D357E26AA16BEA2A46C96C07FA3633CF4DC955

Key learning

If we fire up infrad without starport, we can adjust the empty block interval:

faddat@Jacobs-MacBook-Pro ~> infrad start  --consensus.create_empty_blocks_interval 5s
I[2020-12-14|04:27:28.230] starting ABCI with Tendermint                module=main
I[2020-12-14|04:27:28.540] Starting StateSync service                   module=statesync impl=StateSync
I[2020-12-14|04:27:33.605] Executed block                               module=state height=1 validTxs=0 invalidTxs=0
I[2020-12-14|04:27:33.626] Committed state                              module=state height=1 txs=0 appHash=D309BB999E024DC2F9055B3BD214C2B1EA790FF2D7FF90B9B6DB8FB918D3D00A
I[2020-12-14|04:27:38.643] Executed block                               module=state height=2 validTxs=0 invalidTxs=0
I[2020-12-14|04:27:38.656] Committed state                              module=state height=2 txs=0 appHash=962CB7047449335D8F5D212D7B9528B0C88762DAFF3CD53E811CDB7980BBDBED
I[2020-12-14|04:27:43.683] Executed block                               module=state height=3 validTxs=0 invalidTxs=0
I[2020-12-14|04:27:43.693] Committed state                              module=state height=3 txs=0 appHash=5D3C641E5F38E5F7659BB188BB7EA0AFFDBB348B2B38162E1B1541E20DB7DB5E
I[2020-12-14|04:27:48.729] Executed block                               module=state height=4 validTxs=0 invalidTxs=0
I[2020-12-14|04:27:48.738] Committed state                              module=state height=4 txs=0 appHash=F635161D967705A96867939E3AB880B186C7D7289C7BA9EDA1A90BBB4B2D20D9
I[2020-12-14|04:27:53.789] Executed block                               module=state height=5 validTxs=0 invalidTxs=0
I[2020-12-14|04:27:53.798] Committed state                              module=state height=5 txs=0 appHash=6607BBDB8FCE8EE0EC870908A855CA8743C1ED411E28572ABF3722635F764029

@faddat
Copy link
Contributor Author

faddat commented Dec 13, 2020

@fadeev

When using stargate with the config.yaml you posted above above, config.toml looks like:

# EmptyBlocks mode and possible interval between empty blocks
create_empty_blocks = true
create_empty_blocks_interval = "0s"

to keep things lively I tried to set it in two ways:

version: 1
accounts:
  - name: user1
    coins: ["1000token", "100000000stake"]
  - name: user2
    coins: ["500token"]
validator:
  name: user1
  staked: "100000000stake"


#FIRST WAY
#init.config:
#  consensus:
#    create_empty_blocks_interval: "10s"

#SECOND  WAY
init:
  config:
    consensus:
      create_empty_blocks_interval: "20s"

@fadeev
Copy link
Contributor

fadeev commented Apr 9, 2021

Can be configured using existing features of config.yml.

@fadeev fadeev closed this as completed Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants