Closed mcdee closed 2 years ago
It tries to encode also the alias type but It cannot find the SSZ tags. Use this flag:
sszgen --exclude-objs FixedSizeArray,Slice ...
Thanks, but that doesn't seem to fix the issue:
sszgen --exclude-objs FixedSizeArray,Slice --path . --objs Struct3
[ERR]: failed to encode Struct3: failed to encode FixedSizeArray: failed to encode FixedSizeArray: unexpected mismatch between ssz-size and array fixed size, name=FixedSizeArray, ssz-size=128, fixed=20```
I think this is the same as #55
However, I am unsure how easy it is to fix this issue. Alias management is pretty hard, especially for unmarshalling. Almost all of these cases have to be built ad-hoc without good abstractions so I am not sure to what extent this issue can be fixed.
I will try to look for an easy solution for this case too. However, if your only intention for the alias is to do marshal/unmarshal of the JSON structures, there is another approach here that works better than aliases with custom encoding functions.
Thanks, I'll consider how best to approach this in the specific cases I have. I suspect that a shadow copy of the structs with unaliased types would be the best short-term solution here.
Could you try this PR #103 @mcdee? It has a possible fix for the issue.
A simple struct using only primitive types:
encodes fine, but if the type is abstracted:
An attempt to create the encoding with
sszgen
returns an error:Similarly, attempting to do the same with a fixed-size array:
returns
This is using current
master
.