wealdtech / ethereal

Apache License 2.0
209 stars 41 forks source link

Get transaction panics #16

Closed darren closed 4 years ago

darren commented 4 years ago

ethereal version 2.3.7

ethereal  transaction info --transaction=0x8c6bf43be0d649d06d7cab5aec6c96ca1e1e53e09fb41d726a997c41a0b9ae5f --verbose
Type:                   Mined transaction
Result:                 Succeeded
Block:                  10106518
From:                   0x00D7e5eE00549EFd5E1228D98B32706555F664f7
To:                     0xdAC17F958D2ee523a2206206994597C13D831ec7
Nonce:                  11410
Gas limit:              240000
Gas used:               41209
Gas price:              125 GWei
Value:                  0
panic: runtime error: slice bounds out of range [:1337024595] with capacity 68

goroutine 1 [running]:
github.com/wealdtech/ethereal/util/txdata.valueToString(0xc000010008, 0xc00614a300, 0x11, 0x5444920, 0xc00612eaf0, 0x9, 0x5, 0xc001f73460, 0x9, 0x0, ...)
        /Users/darren/Sources/go/src/github.com/wealdtech/ethereal/util/txdata/signature.go:134 +0x112a
github.com/wealdtech/ethereal/util/txdata.contractValueToString(...)
        /Users/darren/Sources/go/src/github.com/wealdtech/ethereal/util/txdata/signature.go:113
github.com/wealdtech/ethereal/util/txdata.DataToString(0xc000010008, 0xc0061301e0, 0x44, 0x44, 0xc006139c08, 0x1)
        /Users/darren/Sources/go/src/github.com/wealdtech/ethereal/util/txdata/signature.go:58 +0x3ed
github.com/wealdtech/ethereal/cmd.glob..func75(0x5cd5d80, 0xc00061e180, 0x0, 0x4)
        /Users/darren/Sources/go/src/github.com/wealdtech/ethereal/cmd/transactioninfo.go:150 +0x8b2
github.com/spf13/cobra.(*Command).execute(0x5cd5d80, 0xc00061e140, 0x4, 0x4, 0x5cd5d80, 0xc00061e140)
        /Users/darren/Sources/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0x5cd3380, 0x4044c8a, 0x5bcbde0, 0xc000000180)
        /Users/darren/Sources/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/darren/Sources/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
github.com/wealdtech/ethereal/cmd.Execute()
        /Users/darren/Sources/go/src/github.com/wealdtech/ethereal/cmd/root.go:296 +0x31
main.main()
        /Users/darren/Sources/go/src/github.com/wealdtech/ethereal/main.go:19 +0x20
mcdee commented 4 years ago

This is an interesting situation. Function signatures are defined by the first four bytes of their signature hash, and due to the number of signatures out there we are starting to see clashes. In this case, the transfer() function signature is being overwritten by something else, and because the arguments don't match it's struggling. I'm going to tweak the way that ethereal takes signatures from the directory by going in age order, so that a newer signature doesn't overwrite an older (and most likely more popular/supported) signature.

mcdee commented 4 years ago

Ethereal version 2.3.8 should fix this:

$ ethereal version
2.3.8
$ ethereal  transaction info --transaction=0x8c6bf43be0d649d06d7cab5aec6c96ca1e1e53e09fb41d726a997c41a0b9ae5f --verbose
Type:           Mined transaction
Result:         Succeeded
Block:          10106518
From:           0x00D7e5eE00549EFd5E1228D98B32706555F664f7
To:         0xdAC17F958D2ee523a2206206994597C13D831ec7
Nonce:          11410
Gas limit:      240000
Gas used:       41209
Gas price:      125 GWei
Value:          0
Data:           transfer(0xA9f5B14b46A59BE0be5a547AE240C4804fB1602F,200455082)
Logs:
    0:
        From:   0xdAC17F958D2ee523a2206206994597C13D831ec7
        Event:  Transfer(0x00D7e5eE00549EFd5E1228D98B32706555F664f7,0xA9f5B14b46A59BE0be5a547AE240C4804fB1602F,200455082)

After examination it appears that some unknown people decided to infect the 4byte directory with suspicious function names that just happened to have the same signature as common ones, including all of the ERC-20 functions. I've added a blacklist function to exclude these from the list of acceptable functions.

Thank you for reporting this; if you meet any further problems please open a new issue.