Closed MariusVanDerWijden closed 3 years ago
Ahh I had an interface defined in one of the files
type Serialize interface {
Marshal() []byte
}
Which broke code generation, might be cool to just ignore these.
Please check #53, it should fix the issue.
Besides, I would recommend you to use the '--objs' flag to filter for specific objects and skip everything else. Is there any reason why you would use your own Serialize interface instead of using the Marshaler interface from the library?
Nah, I already removed the Serialize interface, was just an artifact from before
The only problem I have right now is that I cannot ssz a common.Hash
which is a type alias for [32]byte{}
from geth
In the spectests there is an example of an external reference, you can use --include to link the path of the common package such that that sszgen knows the type.
Now I get the following error:
panic: interface conversion: ast.Expr is *ast.Ident, not *ast.BasicLit
goroutine 1 [running]:
main.getObjLen(0xc000158db0, 0x0)
/home/matematik/ethereum/fastssz/sszgen/main.go:890 +0x1a6
main.(*env).parseASTFieldType(0xc00013be28, 0xc000016258, 0x4, 0x0, 0x0, 0x5e4468, 0xc000158db0, 0xffffffffffffffff, 0x0, 0xc00019f9d0)
/home/matematik/ethereum/fastssz/sszgen/main.go:930 +0x1051
main.(*env).encodeItem(0xc00013be28, 0xc000016258, 0x4, 0x0, 0x0, 0x0, 0x203000, 0x203000)
/home/matematik/ethereum/fastssz/sszgen/main.go:825 +0x34f
main.(*env).parseASTFieldType(0xc00013be28, 0xc000016246, 0xa, 0x0, 0x0, 0x5e4b88, 0xc00000c0d8, 0x44a72c, 0x0, 0x5a1860)
/home/matematik/ethereum/fastssz/sszgen/main.go:1034 +0x565
main.(*env).parseASTStructType(0xc00013be28, 0xc000016230, 0xb, 0xc00000c0f0, 0x6ec901, 0x5e4900, 0xc000062340)
/home/matematik/ethereum/fastssz/sszgen/main.go:862 +0x168
main.(*env).encodeItem(0xc00013be28, 0xc000016230, 0xb, 0x0, 0x0, 0xc0001aa800, 0x0, 0x0)
/home/matematik/ethereum/fastssz/sszgen/main.go:823 +0x12f
main.(*env).generateIR(0xc00013be28, 0xc0000762a0, 0xc00013bdc8)
/home/matematik/ethereum/fastssz/sszgen/main.go:794 +0x835
main.encode(0x7fff8c0d026e, 0x10, 0x6eb740, 0x0, 0x0, 0x0, 0x0, 0xc000056340, 0x1, 0x1, ...)
/home/matematik/ethereum/fastssz/sszgen/main.go:95 +0x205
main.main()
/home/matematik/ethereum/fastssz/sszgen/main.go:43 +0x3cb
exit status 2
It's because we use a constant instead of a literal in the type definition of common.Hash. E.g.
const HashLength = 32
type Hash [HashLength]byte
Don't know if that is something that the code generation should handle correctly. But I think the eth2 spec also uses constants for declaring the size of some fields so it might be needed, idk.
Edit. Just realized with ssz-size
and ssz-max
this is not needed
I get the following error during code generation.
command:
go run ~/ethereum/fastssz/sszgen/*.go --path ./types
project:https://github.com/MariusVanDerWijden/go-eth2lc
This is probably due to some nested types right? Do all types need to be available in the project or can you import types from other projects?