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

Raft consensus: geth console displays incorrect block timestamp #698

Closed
SatpalSandhu61 opened this issue Apr 29, 2019 · 3 comments · Fixed by #762
Closed

Raft consensus: geth console displays incorrect block timestamp #698

SatpalSandhu61 opened this issue Apr 29, 2019 · 3 comments · Fixed by #762

Comments

@SatpalSandhu61
Copy link
Contributor

System information

Version: 1.8.18-stable
Git Commit: 2d22fd0
Quorum Version: 2.2.3
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1337
Go Version: go1.10.4
Operating System: darwin

Description

When 'geth console' is executed, the console displays the timestamp of the latest block, e.g.:

Welcome to the Geth JavaScript console!

instance: Geth/v1.8.18-stable-2d22fd00(quorum-v2.2.3)/darwin-amd64/go1.10.4
coinbase: 0xed9d02e382b34818e88b88a309c7fe71e65f419d
at block: 5 (Fri, 28 Nov 49325133006 11:29:03 GMT)

As you can see, the timestamp is incorrect in the year.
This is because the console expects the block timestamp to be in seconds, but for Raft it is held in nanoseconds.
The relevant code is in console.console.go::Welcome(), where it has the code:

console.log("at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")");

Under Raft, this code should be:

console.log("at block: " + eth.blockNumber + " (" + new Date(eth.getBlock(eth.blockNumber).timestamp / 1000000) + ")");

However, I don't know how we could tell in the console that Raft consensus is being used.

@jbhurat
Copy link
Contributor

jbhurat commented Apr 29, 2019

Hi @SatpalSandhu61, Console struct has a member client which is an rpc client, you should be able to call eth_getBlockByNumber on the client, and inspect the block that is returned to see if the timestamp is in the form you need and based on that, you can conditionally call c.jsre.Run

@SatpalSandhu61
Copy link
Contributor Author

@jbhurat Thanks very much.
I've created a fix based on your suggestion. Would appreciate it if you'd take a look: #699

@SatpalSandhu61
Copy link
Contributor Author

New PR created: #762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment