-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Closed
Closed
Copy link
Labels
Description
System information
Geth version: v1.14.12
CL client & version: Not related
OS & Version: OSX
Commit hash : (if develop)
Expected behaviour
Encode successfully
Actual behaviour
Get error:
failed to pack and hash typedData primary type: provided data '65' doesn't match type 'bytes'
Steps to reproduce the behaviour
-
Consider a message with a field
sigsof typebytes[]in Solidity. In Go, this is represented as[][]uint8. -
The
func (typedData *TypedData) EncodeData(primaryType string, data map[string]interface{}, depth int)method recursively encodes each field. When it encounters thesigsarray, it correctly identifies it as an array due to the trailing "]" in the type string.
encodeArrayValueis called, receiving the[][]uint8asarrayValueandbytesasparsedType(correctly parsed frombytes[]).
- The problem arises within the loop of
encodeArrayValue. Each item inarrayValue(which is a[]uint8representing a Soliditybytes) is incorrectly treated as another array. This triggers a recursive call toencodeArrayValue.
- In the second, erroneous
encodeArrayValuecall, the[]uint8is further split into individualuint8values. TheparsedTyperemainsbytes(becausestrings.Split("bytes", "[")[0]is stillbytes). This leads to an error because a singleuint8cannot be parsed asbytes.
Backtrace
[backtrace]
When submitting logs: please submit them as text and not screenshots.