ethereumjs-abi icon indicating copy to clipboard operation
ethereumjs-abi copied to clipboard

Fix the rawDecode to utils toBuffer

Open VoR0220 opened this issue 8 years ago • 8 comments

This caused me a heap of problems decoding an output for Parity, and I imagine it's likely to help others down the road.

VoR0220 avatar Oct 11 '17 23:10 VoR0220

Coverage Status

Coverage increased (+2.2%) to 85.97% when pulling e6f324356dba2d5ff964f17047dc38c4e43e25e6 on VoR0220:patch-1 into ee6ded67235a98f3ef4ae2a338aee70a9f68fe20 on ethereumjs:master.

coveralls avatar Oct 12 '17 04:10 coveralls

@VoR0220 what is the problem this is solving?

axic avatar Dec 06 '17 03:12 axic

Well for me, this wasn't compiling previously before I popped this in. Might be an OS X issue, might be an NPM issue, I'm not certain. I believe it had something to do with the way that it assumed the input and didn't convert it prior to. Either way, this converts any inputs into a buffer beforehand and is therefore a better way of going about it from my perspective.

VoR0220 avatar Dec 06 '17 04:12 VoR0220

I think the main motivation was not require strict inputs and not introduce the mess other ethereumjs libraries have with the toBuffer function, which just hides a bunch of different type conversions and makes users lazy.

To be honest I think it shouldn't even expect a hex string, rather a Buffer only and that leaves "bufferization" to the caller.

axic avatar Dec 06 '17 11:12 axic

Is there anything preventing this from being merged? We were running into this error when decoding bytes, and can confirm that it indeed fixes the error.

se3000 avatar Mar 29 '18 19:03 se3000

fixes:

  2) Contract: Args #add has the type:
     Error: Number can only safely store up to 53 bits
      at assert (node_modules/bn.js/lib/bn.js:6:21)
      at BN.toNumber (node_modules/bn.js/lib/bn.js:506:7)
      at decodeSingle (node_modules/ethereumjs-abi/lib/index.js:234:52)
      at Function.ABI.rawDecode (node_modules/ethereumjs-abi/lib/index.js:367:19)
      at Context.it (test/Args_test.js:30:24)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:160:7)

And we're running into this on OSX.

se3000 avatar Mar 29 '18 19:03 se3000

@se3000 What do you take as input so that this error emerges?

holgerd77 avatar Mar 30 '18 20:03 holgerd77

@axic Can't really judge from the discussion if this is a valid PR or not.

holgerd77 avatar Sep 21 '18 12:09 holgerd77