fastssz
fastssz copied to clipboard
generator: int & int64 & uint - not supported ?
I'm trying to use generator and encounter the following error(s):
- for
int
[ERR]: failed to encode storageShare: failed to encode storageShareValidatorMetadata: failed to encode storageShareValidatorMetadata: failed to encode int: could not find struct with name 'int'
shares.go:22: running "sszgen": exit status 1
- for
int64
[ERR]: failed to encode storageShare: failed to encode storageShareValidatorMetadata: failed to encode storageShareValidatorMetadata: failed to encode int64: could not find struct with name 'int64'
shares.go:22: running "sszgen": exit status 1
- for
uint
[ERR]: failed to encode storageShare: failed to encode storageShareValidatorMetadata: failed to encode storageShareValidatorMetadata: failed to encode uint: could not find struct with name 'uint'
shares.go:22: running "sszgen": exit status 1
It seems uint64 works fine, is there a reason those 3 can't be ssz-encoded ?
Can you share a repro of the struct that fails?
What's also curious is that latest version seems to be 0.1.3 while 0.1.4 seems to have been out for a while now as per https://github.com/ferranbt/fastssz/tags
➜ go install github.com/ferranbt/fastssz/sszgen@latest
...
➜ sszgen version
0.1.3
looking more into it - I believe the issue is only showing up when struct fields start with capital letter (and have int or int64 or uint type):
package storage
//go:generate sszgen -path ./shares.go --objs storageShare
type storageShare struct {
// intExample working fine
intExample int
// int64Example working fine
int64Example int64
// uintExample working fine
uintExample uint
// IntExample not working fine
IntExample int
// Int64Example not working fine
Int64Example int64
// UintExample not working fine
UintExample uint
Layer2Struct layer2Struct
}
type layer2Struct struct {
// intExample working fine
intExample int
// int64Example working fine
int64Example int64
// uintExample working fine
uintExample uint
// IntExample not working fine
IntExample int
// Int64Example not working fine
Int64Example int64
// UintExample not working fine
UintExample uint
}
I was able to reproduce it. There are two issues:
- Uint need to specify the amount of bytes.
- I do not think signed integers are part of the SSZ spec.