-
Notifications
You must be signed in to change notification settings - Fork 21.5k
Description
System information
Geth version:
- Client: v1.10.14
- Library: works in v1.10.13, fails in v1.10.14
OS & Version: Linux x64 and ARM64
Expected behaviour
ethclient.Client.SyncProgress(context.Background()) should return a pointer to a populated ethereum.SyncProgress object.
Actual behaviour
The function returns the following error:
json: cannot unmarshal string into Go struct field SyncProgress.CurrentBlock of type uint64
This may be the same problem as #24176, though this report is for the current release (v1.10.14) and is part of the library itself regardless of mobile / desktop platform.
This was likely caused by the changes to ethclient/ethclient.go's unmarshaling code in #23576:
https://github.com/ethereum/go-ethereum/pull/23576/files#diff-1053ae80885a491cefa0ab360c605e7abbcec41fbb620c070a132c58a3bd6cac
Steps to reproduce the behaviour
Sample code:
package main
import (
"context"
"fmt"
"os"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
eth1Address := "http://localhost:8545"
// Connect to ETH1
ethClient, err := ethclient.Dial(eth1Address)
if err != nil {
fmt.Printf("Error connecting to ETH1 client on %s: %s\n", eth1Address, err.Error())
os.Exit(1)
}
progress, err := ethClient.SyncProgress(context.Background())
if err != nil {
fmt.Printf("Error getting sync: %s\n", err.Error())
os.Exit(1)
}
fmt.Println(progress)
p := float64(progress.CurrentBlock - progress.StartingBlock) / float64(progress.HighestBlock - progress.StartingBlock)
if p > 1 {
p = 1
}
fmt.Printf("Progress: %.2f\n", p)
}Output when importing github.com/ethereum/[email protected]:
&{0 2199239 6133456 0 0}
Progress: 0.36
Output when importing github.com/ethereum/[email protected]:
Error getting sync: json: cannot unmarshal string into Go struct field SyncProgress.CurrentBlock of type uint64