Skip to content

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

Open
@dishmop

Description

@dishmop

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions