Skip to content

block is not present in the archive (non-empty archive, last block "blocknumber") #236

@1aBcD1234aBcD1

Description

@1aBcD1234aBcD1

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:

  1. 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)
	}
}
  1. 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 94922486

Desktop (please complete the following information):

  • Sonic version: Sonic/v1.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions