Fantom-foundation / Carmen

Carmen engine for fast world state storage.
Other
18 stars 11 forks source link

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

Open 1aBcD1234aBcD1 opened 10 hours ago

1aBcD1234aBcD1 commented 10 hours ago

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)
}

}

2. 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:
```txt
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):

kjezek commented 8 hours ago

Thanks for this report. Data in archive are updated asynchronously to the head state. It may happen (and is likely to happen) that there is a delay between the head state is available and the block in the archive is available.