Closed lightclient closed 2 years ago
It's also making a MarshalSSZ
method with an offset that is never used:
func (b *Bytes) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(4)
return
}
Which commit of sszgen
are you using? I am trying with the latest sszgen
but I get a different error.
@ferranbt I'm using the sszgen
given by go install github.com/ferranbt/fastssz/sszgen@latest
edit: compiled from 780dd73
and was able to replicate the issue? What error are you seeing that differs?
Fixed in #76. There are two things here:
Bytes
cannot ever be ssz generated since it requires tags. You would have to skip it with --exclude-objs
flag.Great - thank you @ferranbt. Will --exclude-objs
also resolve the following issue:
import "github.com/ethereum/go-ethereum/common/hexutil"
type A struct {
Foo hexutil.Bytes `ssz-max:"2048"`
}
type B struct {
Bar hexutil.Bytes `ssz-max:"32"`
}
and sszgen --include ../go-ethereum/common/hexutil --path . --objs A,B
causes the resulting encoding
file to have the error
./main_encoding.go:6:2: imported and not used: "github.com/ethereum/go-ethereum/common/hexutil"
Ok, now this is a different thing hahah. I was wondering if that Bytes
object would come from a different place. In this case, you do not need to use --exclude-objs
since it is not part of the main source. Do you mind opening another issue regarding this?
Yes I will
If you run
sszgen
on these structs, bothA
andB
will use2048
as the max size for the byte list. In the case ofB
, this causes an incorrect hash-tree-root to be calculated, because the mix in should be based on32
, not `2048.