From 56af1c006baedd1baea97ad6db1e725c0826388d Mon Sep 17 00:00:00 2001 From: kasey Date: Fri, 5 May 2023 12:57:02 -0500 Subject: [PATCH 1/3] support List[List, N'], N] --- go.mod | 21 ++++---------- go.sum | 61 ++++++++++----------------------------- sszgen/backend/list.go | 13 ++++++--- sszgen/backend/overlay.go | 12 +++++++- sszgen/node.go | 2 ++ sszgen/representer.go | 25 ++++++++-------- 6 files changed, 56 insertions(+), 78 deletions(-) diff --git a/go.mod b/go.mod index 3a4c944..62a4f05 100644 --- a/go.mod +++ b/go.mod @@ -7,41 +7,32 @@ require ( github.com/ethereum/go-ethereum v1.11.2 github.com/golang/snappy v0.0.4 github.com/pkg/errors v0.9.1 - github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 github.com/prysmaticlabs/prysm/v3 v3.2.2-rc.1.0.20230309092345-83a294c1a5a4 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.2.2 github.com/urfave/cli/v2 v2.24.1 golang.org/x/tools v0.6.0 - google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v3 v3.0.1 sigs.k8s.io/yaml v1.2.0 ) require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/d4l3k/messagediff v1.2.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect github.com/klauspost/cpuid/v2 v2.2.1 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/sha256-simd v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.4.1 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.39.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab // indirect github.com/prysmaticlabs/gohashtree v0.0.2-alpha // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/stretchr/testify v1.8.2 // indirect github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.5.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/sys v0.5.0 // indirect + golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.7.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index ed3d4bc..f7ac848 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,7 @@ -github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= -github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= -github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U= @@ -20,55 +11,37 @@ github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+Egvsz github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/ethereum/go-ethereum v1.11.2 h1:z/luyejbevDCAMUUiu0rc80dxJxOnpoG58k5o0tSawc= github.com/ethereum/go-ethereum v1.11.2/go.mod h1:DuefStAgaxoaYGLR0FueVcVbehmn5n9QUcVrMCuOvuc= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= -github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.1 h1:X2vfSnm1WC8HEo0MBHZg2TcuDUHJj6kd1TmEAQncnSA= -github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw= -github.com/holiman/uint256 v1.2.1 h1:XRtyuda/zw2l+Bq/38n5XUoEF72aSOu/77Thd9pPp2o= -github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.1 h1:U33DW0aiEj633gHYw3LoDNfkDiYnE5Q8M/TKJn2f2jI= github.com/klauspost/cpuid/v2 v2.2.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic= github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab h1:Y3PcvUrnneMWLuypZpwPz8P70/DQsz6KgV9JveKpyZs= github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg= github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw= @@ -78,40 +51,36 @@ github.com/prysmaticlabs/gohashtree v0.0.2-alpha/go.mod h1:4pWaT30XoEx1j8KNJf3TV github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20230228205207-28762a7b9294 h1:q9wE0ZZRdTUAAeyFP/w0SwBEnCqlVy2+on6X2/e+eAU= github.com/prysmaticlabs/prysm/v3 v3.2.2-rc.1.0.20230309092345-83a294c1a5a4 h1:P58mUzwZ4xrbsIiecFLJOaYBeltJTYmQ4bB1iZgArkA= github.com/prysmaticlabs/prysm/v3 v3.2.2-rc.1.0.20230309092345-83a294c1a5a4/go.mod h1:QyK7KxYY+0PGQaCuRtb55EpvA3Zh74wCNKl8EW+sYS0= -github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo= github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8= -github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= -github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= github.com/urfave/cli/v2 v2.24.1 h1:/QYYr7g0EhwXEML8jO+8OYt5trPnLHS0p3mrgExJ5NU= github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= @@ -121,11 +90,11 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 h1:R1r5J0u6Cx+RNl/6mezTw6oA14cmKC96FeUwL6A9bd4= google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/sszgen/backend/list.go b/sszgen/backend/list.go index b5407dc..90898ff 100644 --- a/sszgen/backend/list.go +++ b/sszgen/backend/list.go @@ -73,14 +73,14 @@ func (g *generateList) generateHTRPutter(fieldName string) string { switch v := vr.(type) { case *types.ValueByte: t := `if len(%s) > %d { - return ssz.ErrBytesLength + return ssz.ErrIncorrectListSize } subIndx := hh.Index() - hh.PutBytes(%s)` + hh.AppendBytes32(%s)` putBytes := fmt.Sprintf(t, fieldName, g.valRep.MaxSize, fieldName) mtmpl := `numItems := uint64(len(%s)) - hh.MerkleizeWithMixin(subIndx, numItems, (%d*%d + 31)/32)` - res := "\n{\n" + putBytes + "\n" + fmt.Sprintf(mtmpl, fieldName, g.valRep.MaxSize, v.FixedSize()) + "\n}\n" + hh.MerkleizeWithMixin(subIndx, numItems, (%d + 31)/32)` + res := "\n{\n" + putBytes + "\n" + fmt.Sprintf(mtmpl, fieldName, g.valRep.MaxSize) + "\n}\n" return res case *types.ValueVector: gv := &generateVector{valRep: v, targetPackage: g.targetPackage} @@ -105,6 +105,11 @@ func (g *generateList) generateHTRPutter(fieldName string) string { lpe.AppendCall = gc.generateHTRPutter(nestedFieldName) lpe.Merkleize = fmt.Sprintf("hh.MerkleizeWithMixin(subIndx, uint64(len(%s)), %d)", fieldName, g.valRep.MaxSize) return renderHtrListPutter(lpe) + case *types.ValueList: + gc := newValueGenerator(interfaces.SszLightHasher, v, g.targetPackage, g.importNamer) + lpe.AppendCall = gc.generateHTRPutter(nestedFieldName) + lpe.Merkleize = fmt.Sprintf("hh.MerkleizeWithMixin(subIndx, uint64(len(%s)), %d)", fieldName, g.valRep.MaxSize) + return renderHtrListPutter(lpe) default: panic(fmt.Sprintf("unsupported type combination - list of %v", v)) } diff --git a/sszgen/backend/overlay.go b/sszgen/backend/overlay.go index a574017..1f7d713 100644 --- a/sszgen/backend/overlay.go +++ b/sszgen/backend/overlay.go @@ -61,7 +61,17 @@ func (g *generateOverlay) generateFixedMarshalValue(fieldName string) string { } func (g *generateOverlay) variableSizeSSZ(fieldname string) string { - return "" + l, ok := g.Underlying.(*types.ValueList) + if !ok { + panic("unhandled case, non-list variable sized overlay") + } + if l.ElementValue.IsVariableSized() { + panic("unhandled case, overlay of list of variable-sized values") + } + if l.ElementValue.FixedSize() == 1 { + return fmt.Sprintf("len(%s)", fieldname) + } + return fmt.Sprintf("len(%s) * %d", fieldname, l.ElementValue.FixedSize()) } func (g *generateOverlay) generateHTRPutter(fieldName string) string { diff --git a/sszgen/node.go b/sszgen/node.go index c11ac9d..97932db 100644 --- a/sszgen/node.go +++ b/sszgen/node.go @@ -26,6 +26,8 @@ type FieldDef struct { typ types.Type tag string pkg *types.Package + // declared as a slice pointer for unambiguous zero-value + dims *[]*SSZDimension } func newStructDef(fs *token.FileSet, imp types.Importer, typ *types.Named, packageName string) *TypeDef { diff --git a/sszgen/representer.go b/sszgen/representer.go index 566cd7a..ba5b878 100644 --- a/sszgen/representer.go +++ b/sszgen/representer.go @@ -91,7 +91,7 @@ func (p *FieldParser) expand(f *FieldDef) (gentypes.ValRep, error) { } return &container, nil case *types.Named: - exp, err := p.expand(&FieldDef{name: ty.Obj().Name(), tag: f.tag, typ: ty.Underlying(), pkg: f.pkg}) + exp, err := p.expand(&FieldDef{name: ty.Obj().Name(), tag: f.tag, typ: ty.Underlying(), pkg: f.pkg, dims: f.dims}) switch ty.Underlying().(type) { case *types.Struct: return exp, err @@ -114,6 +114,10 @@ func (p *FieldParser) expand(f *FieldDef) (gentypes.ValRep, error) { } func (p *FieldParser) expandArrayHead(f *FieldDef) (gentypes.ValRep, error) { + // when recursing through a nested vector/list, receive dimensions parsed through parents + if f.dims != nil { + return p.expandArray(*f.dims, f) + } dims, err := extractSSZDimensions(fmt.Sprintf("`%v`", f.tag)) if err != nil { return nil, errors.Wrapf(err, "name=%s, package=%s, tag=%s", f.name, f.pkg.Path(), f.tag) @@ -142,17 +146,14 @@ func (p *FieldParser) expandArray(dims []*SSZDimension, f *FieldDef) (gentypes.V return nil, fmt.Errorf("invalid typ in expand array: %v with name: %v ", f.typ, f.name) } - // Only expand the inner array if it is not a named type - if _, ok := elem.(*types.Named); !ok && len(dims) > 1 { - elv, err = p.expandArray(dims[1:], &FieldDef{name: f.name, typ: elem.Underlying(), pkg: f.pkg}) - if err != nil { - return nil, err - } - } else { - elv, err = p.expand(&FieldDef{name: f.name, tag: f.tag, typ: elem, pkg: f.pkg}) - if err != nil { - return nil, err - } + var dimTail *[]*SSZDimension + if len(dims) > 1 { + dt := dims[1:] + dimTail = &dt + } + elv, err = p.expand(&FieldDef{name: f.name, tag: f.tag, typ: elem, pkg: f.pkg, dims: dimTail}) + if err != nil { + return nil, err } if d.IsVector() { From 7109d59f9fc12cfbb3ac6c18d9c68fc217f9b7d7 Mon Sep 17 00:00:00 2001 From: kasey Date: Fri, 5 May 2023 14:28:39 -0500 Subject: [PATCH 2/3] remove dead code --- cmd/ssz/generate.go | 8 ++- go.mod | 16 ++++- go.sum | 46 +++++++++++-- sszgen/backend/container_test.go | 28 -------- sszgen/backend/genunmarshal.go | 17 ----- sszgen/backend/list.go | 11 --- sszgen/backend/render.go | 4 -- sszgen/backend/render_test.go | 2 +- sszgen/parser.go | 1 - sszgen/types/container_test.go | 11 --- sszgen/typeutil.go | 112 ------------------------------- 11 files changed, 61 insertions(+), 195 deletions(-) diff --git a/cmd/ssz/generate.go b/cmd/ssz/generate.go index cdcbccb..c1caf2d 100644 --- a/cmd/ssz/generate.go +++ b/cmd/ssz/generate.go @@ -9,6 +9,7 @@ import ( "github.com/OffchainLabs/methodical-ssz/sszgen" "github.com/OffchainLabs/methodical-ssz/sszgen/backend" + "github.com/pkg/errors" "github.com/urfave/cli/v2" ) @@ -41,8 +42,11 @@ var generate = &cli.Command{ Action: func(c *cli.Context) error { sourcePackage = c.Args().Get(0) if sourcePackage == "" { - cli.ShowCommandHelp(c, "generate") - return fmt.Errorf("error: mising required argument") + missingErr := fmt.Errorf("error: missing required argument") + if err := cli.ShowCommandHelp(c, "generate"); err != nil { + return errors.Wrapf(missingErr, "unable to show help text, ShowCommandHelp error=%s", err.Error()) + } + return missingErr } var err error var fields []string diff --git a/go.mod b/go.mod index 62a4f05..9f87f60 100644 --- a/go.mod +++ b/go.mod @@ -7,32 +7,42 @@ require ( github.com/ethereum/go-ethereum v1.11.2 github.com/golang/snappy v0.0.4 github.com/pkg/errors v0.9.1 + github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 github.com/prysmaticlabs/prysm/v3 v3.2.2-rc.1.0.20230309092345-83a294c1a5a4 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.2.2 github.com/urfave/cli/v2 v2.24.1 golang.org/x/tools v0.6.0 + google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v3 v3.0.1 sigs.k8s.io/yaml v1.2.0 ) require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/d4l3k/messagediff v1.2.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect github.com/klauspost/cpuid/v2 v2.2.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab // indirect + github.com/prometheus/client_golang v1.14.0 // indirect + github.com/prometheus/client_model v0.3.0 // indirect + github.com/prometheus/common v0.39.0 // indirect + github.com/prometheus/procfs v0.9.0 // indirect github.com/prysmaticlabs/gohashtree v0.0.2-alpha // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/stretchr/testify v1.8.2 // indirect github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + golang.org/x/crypto v0.5.0 // indirect golang.org/x/mod v0.8.0 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.7.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index f7ac848..377ca12 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,16 @@ +github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= +github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U= @@ -11,37 +20,55 @@ github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+Egvsz github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/ethereum/go-ethereum v1.11.2 h1:z/luyejbevDCAMUUiu0rc80dxJxOnpoG58k5o0tSawc= github.com/ethereum/go-ethereum v1.11.2/go.mod h1:DuefStAgaxoaYGLR0FueVcVbehmn5n9QUcVrMCuOvuc= +github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.1 h1:X2vfSnm1WC8HEo0MBHZg2TcuDUHJj6kd1TmEAQncnSA= +github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw= +github.com/holiman/uint256 v1.2.1 h1:XRtyuda/zw2l+Bq/38n5XUoEF72aSOu/77Thd9pPp2o= +github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.1 h1:U33DW0aiEj633gHYw3LoDNfkDiYnE5Q8M/TKJn2f2jI= github.com/klauspost/cpuid/v2 v2.2.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= +github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic= github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab h1:Y3PcvUrnneMWLuypZpwPz8P70/DQsz6KgV9JveKpyZs= github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg= github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw= @@ -51,9 +78,11 @@ github.com/prysmaticlabs/gohashtree v0.0.2-alpha/go.mod h1:4pWaT30XoEx1j8KNJf3TV github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20230228205207-28762a7b9294 h1:q9wE0ZZRdTUAAeyFP/w0SwBEnCqlVy2+on6X2/e+eAU= github.com/prysmaticlabs/prysm/v3 v3.2.2-rc.1.0.20230309092345-83a294c1a5a4 h1:P58mUzwZ4xrbsIiecFLJOaYBeltJTYmQ4bB1iZgArkA= github.com/prysmaticlabs/prysm/v3 v3.2.2-rc.1.0.20230309092345-83a294c1a5a4/go.mod h1:QyK7KxYY+0PGQaCuRtb55EpvA3Zh74wCNKl8EW+sYS0= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= @@ -66,16 +95,23 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo= github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8= +github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= +github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= github.com/urfave/cli/v2 v2.24.1 h1:/QYYr7g0EhwXEML8jO+8OYt5trPnLHS0p3mrgExJ5NU= github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -90,11 +126,11 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 h1:R1r5J0u6Cx+RNl/6mezTw6oA14cmKC96FeUwL6A9bd4= google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/sszgen/backend/container_test.go b/sszgen/backend/container_test.go index 94f4082..c245dad 100644 --- a/sszgen/backend/container_test.go +++ b/sszgen/backend/container_test.go @@ -22,32 +22,4 @@ func normalizeFixtureString(raw string) (string, error) { return normalizeFixtureBytes([]byte(raw)) } -var testFixStatus types.ValRep = &types.ValueContainer{Name: "Status", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "ForkDigest", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "FinalizedRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "FinalizedEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "HeadRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "HeadSlot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}} - -var testFixBeaconBlocksByRangeRequest types.ValRep = &types.ValueContainer{Name: "BeaconBlocksByRangeRequest", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "StartSlot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Count", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Step", Value: &types.ValueUint{Name: "uint64", Size: 64}}}} - -var testFixENRForkID types.ValRep = &types.ValueContainer{Name: "ENRForkID", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "CurrentForkDigest", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "NextForkVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "NextForkEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}} - -var testFixMetaDataV0 types.ValRep = &types.ValueContainer{Name: "MetaDataV0", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "SeqNumber", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Attnets", Value: &types.ValueOverlay{Name: "Bitvector64", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueVector{Size: 8, ElementValue: &types.ValueByte{Name: "byte"}}}}}} - -var testFixMetaDataV1 types.ValRep = &types.ValueContainer{Name: "MetaDataV1", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "SeqNumber", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Attnets", Value: &types.ValueOverlay{Name: "Bitvector64", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueVector{Size: 8, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Syncnets", Value: &types.ValueOverlay{Name: "Bitvector512", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueVector{Size: 64, ElementValue: &types.ValueByte{Name: "byte"}}}}}} - var testFixBeaconState types.ValRep = &types.ValueContainer{Name: "BeaconState", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "GenesisTime", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "GenesisValidatorsRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Fork", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Fork", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "PreviousVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "CurrentVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}}}}, {Key: "LatestBlockHeader", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "BeaconBlockHeader", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ProposerIndex", Value: &types.ValueOverlay{Name: "ValidatorIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ParentRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "StateRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "BodyRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "BlockRoots", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "StateRoots", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "HistoricalRoots", Value: &types.ValueList{MaxSize: 16777216, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Eth1Data", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Eth1Data", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "DepositRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "DepositCount", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "BlockHash", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "Eth1DataVotes", Value: &types.ValueList{MaxSize: 2048, ElementValue: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Eth1Data", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "DepositRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "DepositCount", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "BlockHash", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}, {Key: "Eth1DepositIndex", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Validators", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Validator", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "PublicKey", Value: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "WithdrawalCredentials", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "EffectiveBalance", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Slashed", Value: &types.ValueBool{Name: "bool"}}, {Key: "ActivationEligibilityEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ActivationEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ExitEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "WithdrawableEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}}}}}, {Key: "Balances", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "RandaoMixes", Value: &types.ValueVector{Size: 65536, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Slashings", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "PreviousEpochAttestations", Value: &types.ValueList{MaxSize: 4096, ElementValue: &types.ValuePointer{Referent: &types.ValueContainer{Name: "PendingAttestation", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "AggregationBits", Value: &types.ValueOverlay{Name: "Bitlist", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueList{MaxSize: 2048, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Data", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "AttestationData", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "CommitteeIndex", Value: &types.ValueOverlay{Name: "CommitteeIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "BeaconBlockRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Source", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "Target", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}}}}, {Key: "InclusionDelay", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ProposerIndex", Value: &types.ValueOverlay{Name: "ValidatorIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}}}}}, {Key: "CurrentEpochAttestations", Value: &types.ValueList{MaxSize: 4096, ElementValue: &types.ValuePointer{Referent: &types.ValueContainer{Name: "PendingAttestation", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "AggregationBits", Value: &types.ValueOverlay{Name: "Bitlist", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueList{MaxSize: 2048, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Data", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "AttestationData", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "CommitteeIndex", Value: &types.ValueOverlay{Name: "CommitteeIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "BeaconBlockRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Source", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "Target", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}}}}, {Key: "InclusionDelay", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ProposerIndex", Value: &types.ValueOverlay{Name: "ValidatorIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}}}}}, {Key: "JustificationBits", Value: &types.ValueOverlay{Name: "Bitvector4", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueVector{Size: 1, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "PreviousJustifiedCheckpoint", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "CurrentJustifiedCheckpoint", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "FinalizedCheckpoint", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}} - -var testFixBeaconStateAltair types.ValRep = &types.ValueContainer{Name: "BeaconStateAltair", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "GenesisTime", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "GenesisValidatorsRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Fork", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Fork", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "PreviousVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "CurrentVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}}}}, {Key: "LatestBlockHeader", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "BeaconBlockHeader", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ProposerIndex", Value: &types.ValueOverlay{Name: "ValidatorIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ParentRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "StateRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "BodyRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "BlockRoots", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "StateRoots", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "HistoricalRoots", Value: &types.ValueList{MaxSize: 16777216, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Eth1Data", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Eth1Data", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "DepositRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "DepositCount", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "BlockHash", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "Eth1DataVotes", Value: &types.ValueList{MaxSize: 2048, ElementValue: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Eth1Data", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "DepositRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "DepositCount", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "BlockHash", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}, {Key: "Eth1DepositIndex", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Validators", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Validator", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "PublicKey", Value: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "WithdrawalCredentials", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "EffectiveBalance", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "Slashed", Value: &types.ValueBool{Name: "bool"}}, {Key: "ActivationEligibilityEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ActivationEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ExitEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "WithdrawableEpoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}}}}}, {Key: "Balances", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "RandaoMixes", Value: &types.ValueVector{Size: 65536, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Slashings", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "PreviousEpochParticipation", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "CurrentEpochParticipation", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "JustificationBits", Value: &types.ValueOverlay{Name: "Bitvector4", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueVector{Size: 1, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "PreviousJustifiedCheckpoint", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "CurrentJustifiedCheckpoint", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "FinalizedCheckpoint", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "InactivityScores", Value: &types.ValueList{MaxSize: 1099511627776, ElementValue: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "CurrentSyncCommittee", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "SyncCommittee", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "Pubkeys", Value: &types.ValueVector{Size: 512, ElementValue: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "AggregatePubkey", Value: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "NextSyncCommittee", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "SyncCommittee", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "Pubkeys", Value: &types.ValueVector{Size: 512, ElementValue: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "AggregatePubkey", Value: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}} - -var testFixFork types.ValRep = &types.ValueContainer{Name: "Fork", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "PreviousVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "CurrentVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}} - -var testFixPendingAttestation types.ValRep = &types.ValueContainer{Name: "PendingAttestation", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "AggregationBits", Value: &types.ValueOverlay{Name: "Bitlist", Package: "github.com/prysmaticlabs/go-bitfield", Underlying: &types.ValueList{MaxSize: 2048, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "Data", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "AttestationData", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Slot", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "CommitteeIndex", Value: &types.ValueOverlay{Name: "CommitteeIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "BeaconBlockRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Source", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}, {Key: "Target", Value: &types.ValuePointer{Referent: &types.ValueContainer{Name: "Checkpoint", Package: "github.com/prysmaticlabs/prysm/v3/proto/eth/v1alpha1", Contents: []types.ContainerField{{Key: "Epoch", Value: &types.ValueOverlay{Name: "Epoch", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "Root", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}}}}}}}, {Key: "InclusionDelay", Value: &types.ValueOverlay{Name: "Slot", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}, {Key: "ProposerIndex", Value: &types.ValueOverlay{Name: "ValidatorIndex", Package: "github.com/prysmaticlabs/eth2-types", Underlying: &types.ValueUint{Name: "uint64", Size: 64}}}}} - -var testFixHistoricalBatch types.ValRep = &types.ValueContainer{Name: "HistoricalBatch", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "BlockRoots", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "StateRoots", Value: &types.ValueVector{Size: 8192, ElementValue: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}}} - -var testFixSigningData types.ValRep = &types.ValueContainer{Name: "SigningData", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "ObjectRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Domain", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}} - -var testFixForkData types.ValRep = &types.ValueContainer{Name: "ForkData", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "CurrentVersion", Value: &types.ValueVector{Size: 4, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "GenesisValidatorsRoot", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}}} - -var testFixDepositMessage types.ValRep = &types.ValueContainer{Name: "DepositMessage", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "PublicKey", Value: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "WithdrawalCredentials", Value: &types.ValueVector{Size: 32, ElementValue: &types.ValueByte{Name: "byte"}}}, {Key: "Amount", Value: &types.ValueUint{Name: "uint64", Size: 64}}}} - -var testFixSyncCommittee types.ValRep = &types.ValueContainer{Name: "SyncCommittee", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "Pubkeys", Value: &types.ValueVector{Size: 512, ElementValue: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}}, {Key: "AggregatePubkey", Value: &types.ValueVector{Size: 48, ElementValue: &types.ValueByte{Name: "byte"}}}}} - -var testFixSyncAggregatorSelectionData types.ValRep = &types.ValueContainer{Name: "SyncAggregatorSelectionData", Package: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", Contents: []types.ContainerField{{Key: "Slot", Value: &types.ValueUint{Name: "uint64", Size: 64}}, {Key: "SubcommitteeIndex", Value: &types.ValueUint{Name: "uint64", Size: 64}}}} diff --git a/sszgen/backend/genunmarshal.go b/sszgen/backend/genunmarshal.go index 7da33e3..821abe0 100644 --- a/sszgen/backend/genunmarshal.go +++ b/sszgen/backend/genunmarshal.go @@ -45,25 +45,8 @@ func GenerateUnmarshalSSZ(g *generateContainer) (*generatedCode, error) { sliceName := fmt.Sprintf("s%d", i) mv := mg.generateUnmarshalValue(fieldName, sliceName) if mv != "" { - //unmarshalBlocks = append(unmarshalBlocks, fmt.Sprintf("\t%s = %s", fieldName, mv)) unmarshalBlocks = append(unmarshalBlocks, mv) } - - /* - if !c.Value.IsVariableSized() { - continue - } - _, ok := mg.(variableUnmarshaller) - if !ok { - continue - } - vm := mg.(variableUnmarshaller) - vmc := vm.generateVariableUnmarshalValue(fieldName) - if vmc != "" { - unmarshalVariableBlocks = append(unmarshalVariableBlocks, fmt.Sprintf("\n\t// Field %d: %s", i, c.Key)) - unmarshalVariableBlocks = append(unmarshalVariableBlocks, "\t" + vmc) - } - */ } sliceDeclarations := strings.Join([]string{ums.fixedSlices(), "", ums.variableSlices(g.fixedOffset())}, "\n") diff --git a/sszgen/backend/list.go b/sszgen/backend/list.go index 90898ff..fba1f4b 100644 --- a/sszgen/backend/list.go +++ b/sszgen/backend/list.go @@ -315,17 +315,6 @@ func (g *generateList) variableSizeSSZ(fieldName string) string { return buf.String() } -var generateVariableMarshalValueTmpl = `if len({{ .FieldName }}) > {{ .MaxSize }} { - return nil, ssz.ErrListTooBig -} - -for _, o := range {{ .FieldName }} { - if len(o) != {{ .ElementSize }} { - return nil, ssz.ErrBytesLength - } - dst = append(dst, o) -}` - var tmplVariableOffsetManagement = `{ offset = 4 * len({{.FieldName}}) for _, {{.NestedFieldName}} := range {{.FieldName}} { diff --git a/sszgen/backend/render.go b/sszgen/backend/render.go index c42a6b2..f6e2288 100644 --- a/sszgen/backend/render.go +++ b/sszgen/backend/render.go @@ -143,10 +143,6 @@ type variableMarshaller interface { generateVariableMarshalValue(string) string } -type variableUnmarshaller interface { - generateVariableUnmarshalValue(string) string -} - type coercer interface { coerce() func(string) string } diff --git a/sszgen/backend/render_test.go b/sszgen/backend/render_test.go index 28a7949..3f056fd 100644 --- a/sszgen/backend/render_test.go +++ b/sszgen/backend/render_test.go @@ -49,7 +49,7 @@ func TestGenerator_GenerateBeaconState(t *testing.T) { g := &Generator{ packagePath: "github.com/prysmaticlabs/prysm/v3/proto/beacon/p2p/v1", } - g.Generate(testFixBeaconState) + require.NoError(t, g.Generate(testFixBeaconState)) rendered, err := g.Render() require.NoError(t, err) actual := string(rendered) diff --git a/sszgen/parser.go b/sszgen/parser.go index c1b4a69..bc91adb 100644 --- a/sszgen/parser.go +++ b/sszgen/parser.go @@ -15,7 +15,6 @@ import ( type GoPathScoper struct { packagePath string - fieldNames []string pkg *types.Package } diff --git a/sszgen/types/container_test.go b/sszgen/types/container_test.go index 4c82da0..c231a08 100644 --- a/sszgen/types/container_test.go +++ b/sszgen/types/container_test.go @@ -6,17 +6,6 @@ import ( "github.com/prysmaticlabs/prysm/v3/testing/require" ) -var testFixderp ValRep = &ValueContainer{ - Name: "derp", - Package: "derp", - Contents: []ContainerField{ - { - Key: "sup", - Value: nil, - }, - }, -} - func TestBeaconStateSizeSSZ(t *testing.T) { require.Equal(t, 84, testFixStatus.FixedSize()) require.Equal(t, false, testFixStatus.IsVariableSized()) diff --git a/sszgen/typeutil.go b/sszgen/typeutil.go index ea7be78..4a0e779 100644 --- a/sszgen/typeutil.go +++ b/sszgen/typeutil.go @@ -58,92 +58,6 @@ func lookupType(scope *types.Scope, name string) (*types.Named, types.Object, er return typ.Type().(*types.Named), obj, nil } -func isPointer(typ types.Type) bool { - _, ok := typ.(*types.Pointer) - return ok -} - -func underlyingSlice(typ types.Type) *types.Slice { - for { - switch t := typ.(type) { - case *types.Named: - typ = typ.Underlying() - case *types.Slice: - return t - default: - return nil - } - } -} - -func underlyingMap(typ types.Type) *types.Map { - for { - switch t := typ.(type) { - case *types.Named: - typ = typ.Underlying() - case *types.Map: - return t - default: - return nil - } - } -} - -func ensureNilCheckable(typ types.Type) types.Type { - orig := typ - named := false - for { - switch typ.(type) { - case *types.Named: - typ = typ.Underlying() - named = true - case *types.Slice, *types.Map: - if named { - // Named slices, maps, etc. are special because they can have a custom - // decoder function that prevents the JSON null value. Wrap them with a - // pointer to allow null always so required/optional works as expected. - return types.NewPointer(orig) - } - return orig - case *types.Pointer, *types.Interface: - return orig - default: - return types.NewPointer(orig) - } - } -} - -// checkConvertible determines whether values of type from can be converted to type to. It -// returns nil if convertible and a descriptive error otherwise. -// See package documentation for this definition of 'convertible'. -func checkConvertible(from, to types.Type) error { - if types.ConvertibleTo(from, to) { - return nil - } - // Slices. - sfrom := underlyingSlice(from) - sto := underlyingSlice(to) - if sfrom != nil && sto != nil { - if !types.ConvertibleTo(sfrom.Elem(), sto.Elem()) { - return fmt.Errorf("slice element type %s is not convertible to %s", sfrom.Elem(), sto.Elem()) - } - return nil - } - // Maps. - mfrom := underlyingMap(from) - mto := underlyingMap(to) - if mfrom != nil && mto != nil { - if !types.ConvertibleTo(mfrom.Key(), mto.Key()) { - return fmt.Errorf("map key type %s is not convertible to %s", mfrom.Key(), mto.Key()) - } - if !types.ConvertibleTo(mfrom.Elem(), mto.Elem()) { - return fmt.Errorf("map element type %s is not convertible to %s", mfrom.Elem(), mto.Elem()) - } - return nil - } - return fmt.Errorf("type %s is not convertible to %s", from, to) -} - // fileScope tracks imports and other names at file scope. type fileScope struct { imports []*types.Package @@ -248,29 +162,3 @@ func (s *fileScope) packageName(path string) string { } return name } - -// funcScope tracks used identifiers in a function. It can create new identifiers that do -// not clash with the parent scope. -type funcScope struct { - used map[string]bool - parent *fileScope -} - -func newFuncScope(parent *fileScope) *funcScope { - return &funcScope{make(map[string]bool), parent} -} - -// newIdent creates a new identifier that doesn't clash with any name -// in the scope or its parent file scope. -func (s *funcScope) newIdent(base string) string { - for i := 0; ; i++ { - name := base - if i > 0 { - name += strconv.Itoa(i - 1) - } - if !s.parent.isNameTaken(name) && !s.used[name] { - s.used[name] = true - return name - } - } -} From 38830ec79f2d0f95a1cfbb089474904d1c63b250 Mon Sep 17 00:00:00 2001 From: kasey Date: Fri, 5 May 2023 16:31:46 -0500 Subject: [PATCH 3/3] spectest support for engine types --- README.md | 11 +++++++---- specs/testdata/engine-prysm.yaml | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 specs/testdata/engine-prysm.yaml diff --git a/README.md b/README.md index 841e152..f1eda00 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,15 @@ spectest subcommand =================== The `generated` directory is a good place to stick generated tests as it is already in the .gitignore for the project. Assuming the tarball in the example above has been downloaded to the repo directory, running the following command there will generate spectests for all prysm types described in the test fixture yaml config: -``` -go run ./cmd/ssz spectest --release-uri=file://$PWD/mainnet-v1.3.0-rc.2.tar.gz --config=$PWD/specs/testdata/prysm.yaml --output=$PWD/generated +```bash +go run ./cmd/ssz spectest --release-uri=file://$PWD/mainnet-v1.3.0-rc.2.tar.gz --config=$PWD/specs/testdata/prysm.yaml --output=$PWD/spectests/v1alpha1 + +go run ./cmd/ssz spectest --release-uri=file://$PWD/mainnet-v1.3.0-rc.2.tar.gz --config=$PWD/specs/testdata/engine-prysm.yaml --output=$PWD/spectests/engine ``` Run the spectest like normal go tests: ``` -go test ./generated -ok github.com/OffchainLabs/methodical-ssz/generated 1.003s +go test ./spectests/... +ok github.com/OffchainLabs/methodical-ssz/spectests/engine 0.110s +ok github.com/OffchainLabs/methodical-ssz/spectests/v1alpha1 1.112s ``` diff --git a/specs/testdata/engine-prysm.yaml b/specs/testdata/engine-prysm.yaml new file mode 100644 index 0000000..9d0b0db --- /dev/null +++ b/specs/testdata/engine-prysm.yaml @@ -0,0 +1,14 @@ +package: github.com/prysmaticlabs/prysm/v3/proto/engine/v1 +preset: mainnet +defs: + - fork: bellatrix + types: + - name: ExecutionPayload + - name: ExecutionPayloadHeader + - fork: capella + types: + - name: ExecutionPayload + type_name: ExecutionPayloadCapella + - name: ExecutionPayloadHeader + type_name: ExecutionPayloadHeaderCapella + - name: Withdrawal