|
|
@ -18,6 +18,7 @@ package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"os" |
|
|
|
"os" |
|
|
@ -182,7 +183,7 @@ func open(ctx *cli.Context, epoch uint64) (*era.Era, error) { |
|
|
|
// that the accumulator matches the expected value.
|
|
|
|
// that the accumulator matches the expected value.
|
|
|
|
func verify(ctx *cli.Context) error { |
|
|
|
func verify(ctx *cli.Context) error { |
|
|
|
if ctx.Args().Len() != 1 { |
|
|
|
if ctx.Args().Len() != 1 { |
|
|
|
return fmt.Errorf("missing accumulators file") |
|
|
|
return errors.New("missing accumulators file") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
roots, err := readHashes(ctx.Args().First()) |
|
|
|
roots, err := readHashes(ctx.Args().First()) |
|
|
@ -203,7 +204,7 @@ func verify(ctx *cli.Context) error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(entries) != len(roots) { |
|
|
|
if len(entries) != len(roots) { |
|
|
|
return fmt.Errorf("number of era1 files should match the number of accumulator hashes") |
|
|
|
return errors.New("number of era1 files should match the number of accumulator hashes") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Verify each epoch matches the expected root.
|
|
|
|
// Verify each epoch matches the expected root.
|
|
|
@ -308,7 +309,7 @@ func checkAccumulator(e *era.Era) error { |
|
|
|
func readHashes(f string) ([]common.Hash, error) { |
|
|
|
func readHashes(f string) ([]common.Hash, error) { |
|
|
|
b, err := os.ReadFile(f) |
|
|
|
b, err := os.ReadFile(f) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("unable to open accumulators file") |
|
|
|
return nil, errors.New("unable to open accumulators file") |
|
|
|
} |
|
|
|
} |
|
|
|
s := strings.Split(string(b), "\n") |
|
|
|
s := strings.Split(string(b), "\n") |
|
|
|
// Remove empty last element, if present.
|
|
|
|
// Remove empty last element, if present.
|
|
|
|