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

RPC getblocktemplate returns version: -1476395008 #392

Open
nickoarg opened this issue Sep 6, 2018 · 22 comments
Open

RPC getblocktemplate returns version: -1476395008 #392

nickoarg opened this issue Sep 6, 2018 · 22 comments
Labels
bug CLI merit-cli issues

Comments

@nickoarg
Copy link

nickoarg commented Sep 6, 2018

Describe the issue

Pool receives an incorrect version data in the rpc response for getworktemplate

Can you reliably reproduce the issue?

Yes

If so, please list the steps to reproduce below:

  1. Compile in linux, ubuntu 16.04
  2. run meritd --daemon
  3. curl --user rpcpool --data-binary '{"jsonrpc":"1.0", "method" : "getblocktemplate","params" : [{"capabilities" : ["coinbasetxn","workid","coinbase/append"]}],"id" : 2}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

get:
Enter host password for user 'rpcpool':
{"result":{"capabilities":["proposal"],"version":-1476395008,"previousblockhash": ...

Expected behaviour

Version should be valid System.UInt32

Actual behaviour

meritd returned an invalid value

Screenshots.

image

What version of merit-core are you using?

Self compiled from source

Machine specs:

  • OS: ubuntu 16.04
  • CPU: 2
  • RAM: 16gb
  • Disk size: 55gb
  • Disk Type (HD/SDD): nvme
@nickoarg
Copy link
Author

nickoarg commented Sep 6, 2018

result.push_back(Pair("version", pblock->nVersion));

Removed that line, recomiled and it works.

@tonypizzicato
Copy link
Member

@nickoarg what's your gcc version?

@tonypizzicato
Copy link
Member

can you try to replace this line with
result.push_back(Pair("version", static_cast<uint64_t>(pblock->nVersion)));
and paste returned block version here?

@barrystyle
Copy link

barrystyle commented Sep 12, 2018

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main()
{
        uint32_t versionBits = -1476395008;
        printf("%08x \n", versionBits);

        return(0);
}

a8000000

while not conventional, the version is just fine..

@nickoarg
Copy link
Author

nickoarg commented Sep 12, 2018

Hi Tony,

$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.

And the returned bloc after modifying with the suggested change:
System.Exception: There was a problem deserializing the response from the coin wallet. ---> Newtonsoft.Json.JsonSerializationException: Error converting value 18446744072233156608 to type 'System.UInt32'. Path 'result.version', line 6, position 35. ---> System.InvalidOperationException: Can not convert from BigInteger to System.UInt32. ---> System.OverflowException: Value was either too large or too small for an Int64.

@barrystyle
Copy link

System.Exception: There was a problem deserializing the response from the coin wallet. ---> Newtonsoft.Json.JsonSerializationException: Error converting value 18446744072233156608 to type 'System.UInt32'. Path 'result.version', line 6, position 35. ---> System.InvalidOperationException: Can not convert from BigInteger to System.UInt32. ---> System.OverflowException: Value was either too large or too small for an Int64.

thats not an issue with gcc, thats from .net, where are you seeing this?

@nickoarg
Copy link
Author

nickoarg commented Sep 12, 2018

At the pool software. Yes, is the .net that is complaining.
But the json Object deserializator is external, so I beleive that the merit node is returning an unexpected value.

@tonypizzicato
Copy link
Member

looks like a quick fix can be
result.push_back(Pair("version", strprintf("%u", pblock->nVersion)));
we need to figure out why this is happening though

@nickoarg
Copy link
Author

System.Exception: There was a problem deserializing the response from the coin wallet. ---> Newtonsoft.Json.JsonSerializationException: Error converting value "-1476395008" to type 'System.UInt32'. Path 'result.version', line 7, position 28. ---> System.OverflowException: Value was either too large or too small for a UInt32.
  at System.Number.ParseUInt32 (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) <0x7f9edd1eab70 + 0x0013a> in <2943701620b54f86b436d3ffad010412>:0

I'm still getting this error

    //result.push_back(Pair("version", pblock->nVersion));
    result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
    result.push_back(Pair("version", strprintf("%u", pblock->nVersion)));

@barrystyle
Copy link

@nickoarg bonesoul/CoiniumServ#933 shows a similar issue where it overflows a uint32/64 using dotnet, might provide some clues?

i can speak authoritatively here and say icemining (the first non-dev pool) interprets the version -1476395008 as versionbits a8000000, with no issues on submitblock, nor warnings like unknown block versions are being mined, which I have recently observed in the past few days.

interpreting version as a uint32 should return 2818572288, then as hex a8000000.

not a great solution, but try:
result.push_back(Pair("version", strprintf("%u", 2818572288)));

@nickoarg
Copy link
Author

I've updated the node to 0.6.4 and the issue persists. I'll see if I can use bonesoul/CoiniumServ#933

@barrystyle
Copy link

@nickoarg try this:
barrystyle@e6f5794

have submitted PR to merits team

@nickoarg
Copy link
Author

Just tried that. Same result:

21:06:17 [Fatal] [Program] [global] Terminating because of unhandled exception!
System.Exception: There was a problem deserializing the response from the coin wallet. ---> Newtonsoft.Json.JsonSerializationException: Error converting value -1476395008 to type 'System.UInt32'. Path 'result.version', line 6, position 26. ---> System.OverflowException: Value was either too large or too small for a UInt32.
  at System.Int64.System.IConvertible.ToUInt32 (System.IFormatProvider provider) <0x7f0bf51e6680 + 0x0002d> in <2943701620b54f86b436d3ffad010412>:0
  at System.Convert.ChangeType (System.Object value, System.Type conversionType, System.IFormatProvider provider) <0x7f0bf51bbe60 + 0x0028d> in <2943701620b54f86b436d3ffad010412>:0
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x000c0] in <b1d2c1d6f4dd47bea2964bdd6464f67d>:0

Running over Mono 5.14.0.177 (tarball Mon Aug 6 09:13:43 UTC 2018), framework: 4.5 (v4.0.30319.42000).

@barrystyle
Copy link

its still displaying -1476395008?
do you want to doublecheck & compile again?

the build displays that number on my machine pre-patch.. the patch gives 671088640 as a result

@nickoarg
Copy link
Author

Yes, confirmed.
image

image

@barrystyle
Copy link

barrystyle commented Sep 14, 2018

can you post the output of:

merit-cli getblocktemplate '{"capabilities":["coinbasetxn","workid","coinbase/append"]}'

@nickoarg
Copy link
Author

Sure

ubuntu@ip-172-31-86-11:~/merit$ merit-cli getblocktemplate '{"capabilities":["coinbasetxn","workid","coinbase/append"]}'
{
  "capabilities": [
    "proposal"
  ],
  "version": -1476395008,
  "previousblockhash": "472524a6771cad88361f404da4b0b9df6c6c2183268b601214156a2172817fe0",
  "transactions": [
    {
      "data": "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0503a1b00500ffffffff1609ca9a3b000000001976a914f7f82309321e87b27bb0b69716e83d2ea698631f88ac0694a603000000001976a91460442c3a09a673e3df8e024e3c3d90232f21354188ac1a80ec02000000001976a914ac53076781e72c07042a435e8395223887ef648088ac2fbb1503000000001976a9144a0b2940c041e0328dd127ee03addddb6696b55488acb89eb103000000001976a9142c930dff417ce135d133a0d6b4bd91b27885390788ac128b8303000000001976a91467495491b4673de8299b1f6a983b3c719be09f4f88ac611e3503000000001976a914d76c02e7bcff8d864ff3557b83e40b7dfdfab93d88ac67024c03000000001976a9146e92f83064c5bba2c1f73b4cb6947512bc62467b88aca30cb502000000001976a914db0bb09cc5b465f503b2cedd82d8dc6eb80cb72e88ac49ca3103000000001976a914ee34a60e8fe4223c0ad57600b7d70713c73c216e88acbb0d7603000000001976a9145cdcaad0a61feeff8c474d50daf79885bd08694188ace668cb02000000001976a914772fee9f5780658825c943d4c11c623eb69cd48388ac21b10503000000001976a91491b993ce95e687a1cc901a31c7b63d3333607e5788ac06e3c502000000001976a9146cad0cd440df9d2132567af43e94b60b0b9a0c1088ac6647c902000000001976a9148896c31b61795506e4337dde338f295ef3ddac4c88acaad39c02000000001976a9147b7531de9c60c036d286bd5ccf9906d74f46931288ac8cd0d502000000001976a91481b2e30dc37bebdf8fe81e3dbf3807e56ce1cf1a88acbbd6d402000000001976a91420e6f1131d3560322470e1432632a0f604f36c2688acea2e6602000000001976a91404d95d1bdec745b6e5efd181d47b2ec7eb55861088ac75a27402000000001976a9146b6fd12aa5b86e7b059877db10daa86632a19d5088acac3a5c02000000001976a9145efede3c12ecd5d214a86003322b00cb21a5fc1288ac0000000000000000266a24aa21a9ed598bdca4eab6001d5753ba33e9a50b1986649f4b477948b5f761decd6b742b4e00000000",
      "coinbase": true,
      "txid": "3cae4c385dddaa657a51120b472df9a3a74b9ed38570c4c3412b8d0ff11097df",
      "hash": "3cae4c385dddaa657a51120b472df9a3a74b9ed38570c4c3412b8d0ff11097df",
      "depends": [
      ],
      "fee": 0,
      "sigops": 84,
      "weight": 3304
    }
  ],
  "invites": [
    {
      "data": "03000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0503a1b00500ffffffff0101000000000000001976a914e8d78696984c62609ac13707d3383c66b7196f3d88ac00000000",
      "txid": "f65edc71282becef846c55e48f45dc66ac216632c8cb296a419e48fc58bab0b5",
      "hash": "f65edc71282becef846c55e48f45dc66ac216632c8cb296a419e48fc58bab0b5",
      "depends": [
      ],
      "sigops": 84,
      "weight": 360
    }
  ],
  "referrals": [
  ],
  "coinbaseaux": {
    "flags": ""
  },
  "coinbasevalue": 1000000009,
  "longpollid": "472524a6771cad88361f404da4b0b9df6c6c2183268b601214156a2172817fe050",
  "target": "0000a76a00000000000000000000000000000000000000000000000000000000",
  "mintime": 1536794080,
  "mutable": [
    "time",
    "transactions",
    "invites",
    "referrals",
    "prevblock"
  ],
  "noncerange": "00000000ffffffff",
  "sigoplimit": 240000,
  "sizelimit": 16000000,
  "weightlimit": 16000000,
  "curtime": 1536960673,
  "bits": "1f00a76a",
  "edgebits": 26,
  "height": 372897,
  "default_witness_commitment": "6a24aa21a9ed598bdca4eab6001d5753ba33e9a50b1986649f4b477948b5f761decd6b742b4e"
}

@barrystyle
Copy link

ok, what response does it give once the patch is removed & daemon recompiled?

@nickoarg
Copy link
Author

Confirmed, same output, even with make clean, git pull, all fresh.

ubuntu@ip-172-31-86-11:~/merit-pool$ merit-cli getblocktemplate '{"capabilities":["coinbasetxn","workid","coinbase/append"]}'
{
  "capabilities": [
    "proposal"
  ],
  "version": -1476395008,
  "previousblockhash": "8e9e27a26c1ca17f49d7e25b085ba931f1539269f5acb9b1fd644717d4ec0e19",

@barrystyle
Copy link

barrystyle commented Sep 15, 2018

the only other thing i can think of is a path issue or forgetting to run 'make install' at end of compile.
try running those commands directly from the build folder (prefaced with ./ like ./merit-cli)

actually, you cant write to /usr without sudo'ing (i notice youre not root)..

@nickoarg
Copy link
Author

Hi, sorry for the delay, same result by making sure that I'm running the latest.

ubuntu@ip-172-31-86-11:~/merit/src$ ./merit-cli getblocktemplate '{"capabilities":["coinbasetxn","workid","coinbase/append"]}'
{
  "capabilities": [
    "proposal"
  ],
  "version": -1476395008,

@barrystyle
Copy link

As root; can you run:
find / -name meritd | xargs ls -la

@eugene-sy eugene-sy added bug CLI merit-cli issues labels Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug CLI merit-cli issues
Projects
None yet
Development

No branches or pull requests

4 participants