ethermint-archive icon indicating copy to clipboard operation
ethermint-archive copied to clipboard

Enable no empty blocks

Open kidinamoto01 opened this issue 9 years ago • 13 comments

Hello, I tried the --consensus.create_empty_blocks=false flag when running ether mint, but there's still lots of empty blocks. The command is tendermint --home ~/.ethermint/tendermint node --consensus.create_empty_blocks=false && ethermint --datadir ~/.ethermint --rpc --rpcaddr=0.0.0.0 --ws --wsaddr=0.0.0.0 --rpcapi eth,net,web3,personal,admin Version info: Tendermint version: 0.10.4-9af837c2 Ethermint version: 0.4.0-95251185 Go version: 1.8,3 Is there a way to stop all the empty blocks?

Thank you in advance.

kidinamoto01 avatar Sep 19 '17 02:09 kidinamoto01

hi @kidinamoto01 I can reproduce this issue, thanks for reporting it. We will soon have a guide explaining empty blocks, please track this issue for further information.

zramsay avatar Sep 19 '17 13:09 zramsay

@kidinamoto01 correction, this is not a tendermint problem, but rather because ethermint changes app hash every block; a non-trivial modification.

zramsay avatar Sep 20 '17 19:09 zramsay

This shouldn't make a difference. Unless Tendermint calls BeginBlock even when not producing a new block, the apphash should not change.

adrianbrink avatar Sep 28 '17 09:09 adrianbrink

bucky [2:30 PM] It's because the ethermint app hash changes with every block. No empty blocks creates blocks when there are txs and when the app hash changes

adrian [2:52 PM] But how does the app hash change if Tendermint doesn't propose a new block without any new TX. What I would expect to happen is: Tendermint has no tx in the mempool, does not make any calls to the app and just waits. Then Tendermint has a tx in the mempool, calls the app, creates a block, and then waits again.

[2:52] Where does Tendermint receive the changed app hash. Isn't the only place where tendermint gets the app hash as a response to the Commit call?

bucky [3:18 PM] Yeh. So tendermint always makes block 1. If the app hash is still empty, it won't make another one till there's a tx. But the ethermint app hash is the ethereum block hash. So it's not empty. So tendermint creates a new block. Well now that means there's a new ethereum block, so again a new app hash, ad infinitum

adrian [3:25 PM] ah okay, so Tendermint creates 1 block with all the remaining transactions from the mempool and then creates a 2 block without any transactions and checks whether the app hash changes on the second block. If it doesn't then it pauses until it receives another tx, but if it does change then it keeps going into this perpetual cycle.

[3:25] Okay, so on Ethermint this is caused by the fact that BeginBlock will take the Tendermint header and EndBlock will create a new Ethereum block, which then results in a different app hash on Commit

bucky [3:25 PM] Right

adrianbrink avatar Sep 28 '17 13:09 adrianbrink

Hey, Andrian. I've tried to find a solution , and modified UpdateHeaderWithTimeInfofunction to filter empty blocks // UpdateHeaderWithTimeInfo uses the tendermint header to update the ethereum header func (b *Backend) UpdateHeaderWithTimeInfo(tmHeader *abciTypes.Header) { numTx := tmHeader.GetNumTxs() if numTx >0 { b.pending.updateHeaderWithTimeInfo(b.ethereum.ApiBackend.ChainConfig(), tmHeader.Time, tmHeader.GetNumTxs()) } }

But the Verifyheaderwill return Error: timestamp equals parent's

Andlinks-Yourturn avatar Sep 30 '17 07:09 Andlinks-Yourturn

#343 maybe enable this

zramsay avatar Oct 23 '17 20:10 zramsay

But the Verifyheaderwill return Error: timestamp equals parent's

Yes, that's because go-ethereum doesn't support blocks created in the same second:

consensus.go

if header.Time.Cmp(parent.Time) <= 0 {
	return errZeroBlockTime
}

After https://github.com/tendermint/ethermint/pull/350 we still need to find a solution to avoid this.

kesar avatar Nov 24 '17 18:11 kesar

@kesar Well done!

I tested the same solution on older release the other day, but if you shut the Ethermint, it's not possible to restart again.

kidinamoto01 avatar Nov 25 '17 02:11 kidinamoto01

I tested the same solution on older release the other day, but if you shut the Ethermint, it's not possible to restart again.

Thanks @kidinamoto01 !

What error are you getting? If its the "timestamp equals parent's" I have a solution, but I want to test it a bit more 👍

kesar avatar Nov 25 '17 11:11 kesar

@kidinamoto01 Could you share the error?

I have tested this as well, and even though it does seem like Ethermint isn't starting, once you run a transaction it creates blocks again.

adrianbrink avatar Nov 26 '17 10:11 adrianbrink

Sorry for reply so late

What I did is start Ethermint, do some transactions and shut it down. When I restart it , Ethermint was not able to connect with Tendermint node.

Ethermint Log info: GOROOT=/usr/local/Cellar/go/1.8.3/libexec GOPATH=/Users/b/Documents/go /usr/local/Cellar/go/1.8.3/libexec/bin/go build -i -o /private/var/folders/v_/qpdch0_j031bb1wqwx9m1xrh0000gn/T/___ethermint . /private/var/folders/v_/qpdch0_j031bb1wqwx9m1xrh0000gn/T/___ethermint --datadir /Users/b/.ethermint --rpc --rpcaddr=0.0.0.0 --ws --wsaddr=0.0.0.0 --rpcapi eth,net,web3,personal,admin --with-tendermint INFO [11-26|19:35:09] Starting peer-to-peer node instance=ethermint/v1.6.7-stable/darwin-amd64/go1.8.3 INFO [11-26|19:35:09] Allocated cache and file handles database=/Users/b/.ethermint/ethermint/chaindata cache=128 handles=1024 INFO [11-26|19:35:09] Initialised chain configuration config="{ChainID: 15 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Metropolis: <nil> Engine: unknown}" WARN [11-26|19:35:09] Ethash used in fake mode INFO [11-26|19:35:09] Initialising Ethereum protocol versions="[63 62]" network=1 INFO [11-26|19:35:09] Loaded most recent local header number=5 hash=8da82c…de862d td=655680 INFO [11-26|19:35:09] Loaded most recent local full block number=5 hash=8da82c…de862d td=655680 INFO [11-26|19:35:09] Loaded most recent local fast block number=5 hash=8da82c…de862d td=655680 WARN [11-26|19:35:09] Blockchain not empty, fast sync disabled INFO [11-26|19:35:09] Starting P2P networking INFO [11-26|19:35:09] RLPx listener up self="enode://5a0a42f30a6a9fac3bd62ed571a622c5978ff1d9759db8e45b1ebe8ff186bf5d06c8ac616186f16f5cb008b502bfc41b60b2be657d0b2023a1b2e5018f5f4ab4@[::]:30303?discport=0" INFO [11-26|19:35:09] IPC endpoint opened: /Users/b/.ethermint/geth.ipc INFO [11-26|19:35:09] HTTP endpoint opened: http://0.0.0.0:8545 INFO [11-26|19:35:09] WebSocket endpoint opened: ws://0.0.0.0:8546 INFO [11-26|19:35:11] Mapped network port proto=tcp extport=30303 intport=30303 interface="UPNP IGDv1-IP1" INFO [11-26|19:35:11] Invoked tendermint nodesleeping for 3s args="[--home /Users/b/.ethermint/tendermint node]" INFO [11-26|19:35:11] Invokingtendermint args="[--home /Users/b/.ethermint/tendermint node]" INFO [11-26|19:35:12] tendermint init error="exit status 2" INFO [11-26|19:35:14] Starting ABCIServer module=abci-server impl=ABCIServer INFO [11-26|19:35:14] Waiting for new connection... module=abci-server

Tendermint Log info: GOROOT=/usr/local/Cellar/go/1.8.3/libexec GOPATH=/Users/b/Documents/go /usr/local/Cellar/go/1.8.3/libexec/bin/go build -i -o /private/var/folders/v_/qpdch0_j031bb1wqwx9m1xrh0000gn/T/___tendermint /Users/b/Documents/go/src/github.com/tendermint/tendermint/cmd/tendermint/main.go /private/var/folders/v_/qpdch0_j031bb1wqwx9m1xrh0000gn/T/___tendermint node --home /Users/b/.ethermint/tendermint --consensus.create_empty_blocks=false E[11-26|11:33:57.724] abci.socketClient failed to connect to tcp://127.0.0.1:46658. Retrying... module=abci-client connection=query E[11-26|11:34:00.729] abci.socketClient failed to connect to tcp://127.0.0.1:46658. Retrying... module=abci-client connection=query E[11-26|11:34:03.731] abci.socketClient failed to connect to tcp://127.0.0.1:46658. Retrying... module=abci-client connection=query E[11-26|11:34:06.737] abci.socketClient failed to connect to tcp://127.0.0.1:46658. Retrying... module=abci-client connection=query I[11-26|11:34:12.826] Executed block module=state height=1 validTxs=0 invalidTxs=0 I[11-26|11:34:12.829] Committed state module=state height=1 txs=0 hash=56E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421 I[11-26|11:34:13.836] Executed block module=state height=2 validTxs=0 invalidTxs=0 I[11-26|11:34:13.837] Committed state module=state height=2 txs=0 hash=56E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421 I[11-26|11:34:41.559] Executed block module=state height=3 validTxs=1 invalidTxs=0 I[11-26|11:34:41.562] Committed state module=state height=3 txs=1 hash=FBD2B93D14D536E3E16341A82D6CD609A3DADC868A719CC8006ADB4FA5C01CAA I[11-26|11:34:42.580] Executed block module=state height=4 validTxs=0 invalidTxs=0 I[11-26|11:34:42.582] Committed state module=state height=4 txs=0 hash=56E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421 I[11-26|11:34:43.596] Executed block module=state height=5 validTxs=0 invalidTxs=0 I[11-26|11:34:43.600] Committed state module=state height=5 txs=0 hash=56E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421 E[11-26|11:34:57.778] Stopping abci.socketClient for error: EOF module=abci-client connection=mempool E[11-26|11:34:57.778] Stopping abci.socketClient for error: EOF module=abci-client connection=consensus E[11-26|11:34:57.782] Stopping abci.socketClient for error: EOF module=abci-client connection=query

kidinamoto01 avatar Nov 26 '17 11:11 kidinamoto01

will tools like truffle work with no empty blocks ?

illya13 avatar Dec 21 '17 16:12 illya13

this ought to work with https://github.com/cosmos/ethermint when it is stable

zramsay avatar Jul 11 '18 18:07 zramsay