fix: decode subcircuit row usage as integer (#421)

* fix subcircuit row usage type

* bump version
This commit is contained in:
Péter Garamvölgyi 2023-08-02 06:03:18 +02:00 committed by GitHub
parent 11b35cd014
commit 96d12015e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 21 deletions

View file

@ -5,29 +5,25 @@ package types
import (
"encoding/json"
"errors"
"github.com/scroll-tech/go-ethereum/common/hexutil"
)
var _ = (*subCircuitRowUsageMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (s SubCircuitRowUsage) MarshalJSON() ([]byte, error) {
type SubCircuitRowUsage struct {
Name string `json:"name" gencodec:"required"`
RowNumber hexutil.Uint64 `json:"row_number" gencodec:"required"`
Name string `json:"name" gencodec:"required"`
RowNumber uint64 `json:"row_number" gencodec:"required"`
}
var enc SubCircuitRowUsage
enc.Name = s.Name
enc.RowNumber = hexutil.Uint64(s.RowNumber)
enc.RowNumber = s.RowNumber
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (s *SubCircuitRowUsage) UnmarshalJSON(input []byte) error {
type SubCircuitRowUsage struct {
Name *string `json:"name" gencodec:"required"`
RowNumber *hexutil.Uint64 `json:"row_number" gencodec:"required"`
Name *string `json:"name" gencodec:"required"`
RowNumber *uint64 `json:"row_number" gencodec:"required"`
}
var dec SubCircuitRowUsage
if err := json.Unmarshal(input, &dec); err != nil {
@ -40,6 +36,6 @@ func (s *SubCircuitRowUsage) UnmarshalJSON(input []byte) error {
if dec.RowNumber == nil {
return errors.New("missing required field 'row_number' for SubCircuitRowUsage")
}
s.RowNumber = uint64(*dec.RowNumber)
s.RowNumber = *dec.RowNumber
return nil
}

View file

@ -1,24 +1,15 @@
package types
import (
"github.com/scroll-tech/go-ethereum/common/hexutil"
)
type RowUsage struct {
IsOk bool `json:"is_ok"`
RowNumber uint64 `json:"row_number"`
RowUsageDetails []SubCircuitRowUsage `json:"row_usage_details"`
}
//go:generate gencodec -type SubCircuitRowUsage -field-override subCircuitRowUsageMarshaling -out gen_row_consumption_json.go
//go:generate gencodec -type SubCircuitRowUsage -out gen_row_consumption_json.go
type SubCircuitRowUsage struct {
Name string `json:"name" gencodec:"required"`
RowNumber uint64 `json:"row_number" gencodec:"required"`
}
type RowConsumption []SubCircuitRowUsage
// field type overrides for gencodec
type subCircuitRowUsageMarshaling struct {
RowNumber hexutil.Uint64
}

View file

@ -24,7 +24,7 @@ import (
const (
VersionMajor = 4 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionPatch = 5 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string
)