Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Conversation

@janx
Copy link
Member

@janx janx commented Mar 20, 2016

abi.decint is used to decode BOTH signed and unsigned integers.

Problem

  • it make the bound check hard to understand, because it mixes int's lower bound and uint's upper bound:
    if is_numeric(n) and n < 2**256 and n >= -2**255:
  • If the input is bytes it will always decode those bytes to unsigned int, cause inconsistent semantic - if input is int/uint, the output is int/uint; if input is bytes of int/uint, the output is uint.

Fix

Add a new argument signed, default to False, behave accordingly.

Consequence

With signed int's bound check fix, test_ecrecover breaks because the types of its arguments default to int256. Declare them to uint256.

$ cat test_ecrecover.se

def test_ecrecover(h, v, r, s):
    return(ecrecover(h, v, r, s))

$ serpent mk_signature test_ecrecover.se

extern test_ecrecover.se: [test_ecrecover:[int256,int256,int256,int256]:int256]

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a1e604d on janx:fix_abi_decint into * on ethereum:develop*.

@ulope ulope merged commit a1e604d into ethereum:develop Apr 15, 2016
@ulope
Copy link
Member

ulope commented Apr 15, 2016

Merged. Thanks for the fix :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants