go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

abi.Method.Sig not contains return types

Open howjmay opened this issue 3 years ago • 2 comments

System information

Geth version: geth version 1.10.21 OS & Version: OSX Commit hash : (if develop)

Expected behaviour

See document of abi.Method. The field Sig is a string of the function signature. For a function foo(uint32 a, int b) returns (uint), it will return foo(uint32,int256) instead of foo(uint32,int256)(uint256)

Actual behaviour

retrun foo(uint32,int256)(uint256) in the previous case.

Steps to reproduce the behaviour

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

howjmay avatar Aug 24 '22 08:08 howjmay

// Sig returns the methods string signature according to the ABI spec.
// e.g.		function foo(uint32 a, int b) = "foo(uint32,int256)"
// Please note that "int" is substitute for its canonical representation "int256"
Sig [string](https://pkg.go.dev/builtin#string)
// ID returns the canonical representation of the method's signature used by the
// abi definition to identify method names and types.
ID [][byte](https://pkg.go.dev/builtin#byte)

Originally, I think the idea was that hash(Sig) -> 4-byte abi (ID). The return parameter does not affect the abi identifier, so hence it was not included in the Sig. The two are tied to one another.

I think that was an explicit decision and not a bug. Question is if it's something we want to change. Personally I'm leaning towards "not", for now.

holiman avatar Sep 27 '22 14:09 holiman

I'm also leaning towards not changing it, since I bet people are depending on the property that hash(Sig) gives the 4 byte abi

MariusVanDerWijden avatar Jan 02 '23 12:01 MariusVanDerWijden