-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Describe the bug
A clear and concise description of what the bug is.
Hello everyone. Im a developing some stuff that needs real time on chain execution and I just encountered this error when making requests using my local archive node.
The error can be reproduce just by subscribing to new heads using the standard goethereum client, and just requesting onchain information of that block, which should be the latest one. Maybe is something intended, however when you try to ask information from the received header I always get as an example panic: block 94922164 is not present in the archive (non-empty archive, last block 94922163)
To Reproduce
Steps to reproduce the behavior:
- Test code to reproduce
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
ethClient, err := ethclient.Dial("/opt/sonic/data/opera.ipc")
if err != nil {
panic(err)
}
ch := make(chan *types.Header, 10)
sub, err := ethClient.SubscribeNewHead(context.Background(), ch)
if err != nil {
panic(err)
}
for {
c := <-ch
b, err := ethClient.BalanceAt(context.Background(), common.Address{}, c.Number)
if err != nil {
sub.Unsubscribe()
panic(err)
}
fmt.Println(b, c.Number)
}
}- Error obtained as an example:
panic: block 94922467 is not present in the archive (non-empty archive, last block 94922466)
Expected behavior
By adding a waiting time of 0.4 (expect time between two block) time.Sleep(time.Millisecond * 400) you get the following output:
2137410229675161653917591 94922477
2137410229675161653917591 94922478
2137410229675161653917591 94922479
2137410229675161653917591 94922480
2137410229675161653917591 94922481
2137410229675161653917591 94922482
2137410229675161653917591 94922483
2137410229675161653917591 94922484
2137410229675161653917591 94922485
2137410229675161653917591 94922486Desktop (please complete the following information):
- Sonic version: Sonic/v1.2.1