fetchai / fetchd

Source code for Fetch.ai blockchain nodes
Other
96 stars 40 forks source link

Block time is incorrect if mining interval is less than 1 #245

Open dishmop opened 2 years ago

dishmop commented 2 years ago

Prerequisites

Expected Behavior

I expect the block.time.seconds() to go up about 1 every second

Current Behavior

If I run the node replacing 5 in the timeout_commit config with 0.25, then time rises about twice as quickly as realtime in the contracts. My initialisation script does this: sed -i 's/timeout_commit = "5s"/timeout_commit = "0.25s"/g' ~/.fetchd/config/config.toml

prior to calling fetchd start

I then ran a python script which every second queried a contract which returned the block.time. This is the table:

Rust: env.block.time.seconds(), Python time.time()
0.0, 0.0
3.0. 1.0
5.0, 2.0
7.0. 3.0
9.0. 4.0
11.0, 5.0
13.0, 6.0
15.0, 7.0
17.0, 8.0
19.0, 9.0

You can see that the contract time rises about twice as fast as the realtime (measured in python).

This is only an issue when the timeout_commit time is < 1. However, this is kind of crucial for us otherwise development becomes impossibly slow.

To Reproduce

Talk to Diarmid and I can point you to code.

Context

OSX Fetchd version (docker image) image: fetchai/fetchd:0.9.0-rc4

Failure Logs

No response

daeMOn63 commented 2 years ago

These 3 seconds seem to match the timeout_propose parameter default value. You can try to adjust this as well. Other than this I have no clue how to configure tendermint to achieve what you want, probably worth you ask over https://github.com/tendermint/tendermint or reach on cosmos discord someone to help you.