attestantio / go-eth2-client

Apache License 2.0
102 stars 59 forks source link

ValidatorsProvider.Validators returns wrong 404 errors - bug? #124

Closed peske closed 3 months ago

peske commented 3 months ago

Thanks for great work!

Now the problem: After deploying my project, I've noticed that ValidatorsProvider.Validators call returns a lot of 404 errors. The input argument is like:

opts := &api.ValidatorsOpts{
        Common: api.CommonOpts{
            Timeout: time.Second * time.Duration(cfg.ValidatorsTimeoutSeconds),
        },
        State:   stateID,
        Indices: nil,
        PubKeys: validatorPubKeys,
    }

Where stateID is a slot number (i.e. "8718143"), while validatorPubKeys contains public key slice of variable length (I've tried with up to 1,500 keys). The client communicates with a Lighthouse node, which is fully synced, and it definitely includes history long before the requested slot ("8718143"). Also, the instance reports finalized epoch (via EventsProvider) that is significantly after the requested slot. In short: the requested slot is definitely contained by the server.

When it comes to public keys, almost all (if not all) of them were active in this moment in time (slot 8718143).

Based on everything said, the client should not return 404; it should either return the data, or some other error if there's one. But it does, and it does it a lot. The question is in what circumstances 404 errors are returned, and how we should handle them?

Just to mention: I'm able to get the data manually by using curl and invoking the same endpoint on the same instance.

Thanks!

mcdee commented 3 months ago

Please can you run the client with trace logging and send an example log where it returns a 404 that it shouldn't? That should help me to understand the issue.

peske commented 3 months ago

I will provide asap.

Meanwhile, is there any documentation about 404 errors? What they should mean in this particular call? For example, if I made call for a certain slot and list of validator public keys, as in my original post above, and I get 404 how to interpret it? To be more precise:

Thanks!

mcdee commented 3 months ago

The official specification is at https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidators however it may not define all situations, and not all consensus nodes will follow the spec perfectly. Ideally the consensus node will return 404 if the state cannot be found, and apart from that will return an array of some sort, but it's the type of thing that would need to be tested against all implementations to confirm that they work as expected.

peske commented 3 months ago

Thank you very much for the answers!

Regarding my original problem - getting suspicious 404 - it looks that it was caused by me trying to query slots without blocks. Also, I've provided false info by mistake that manual (curl) queries do return some results. In short - my report was wrong, so I'm closing this one.

Thanks for trying to help!