Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator: int & int64 & uint - not supported ? #180

Open
iurii-ssv opened this issue Nov 3, 2024 · 3 comments
Open

generator: int & int64 & uint - not supported ? #180

iurii-ssv opened this issue Nov 3, 2024 · 3 comments

Comments

@iurii-ssv
Copy link

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 ?

@ferranbt
Copy link
Owner

ferranbt commented Nov 4, 2024

Can you share a repro of the struct that fails?

@iurii-ssv
Copy link
Author

iurii-ssv commented Nov 4, 2024

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
}

@ferranbt
Copy link
Owner

ferranbt commented Nov 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants