polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
241 stars 115 forks source link

Wrong authority set used while determining block author #384

Closed artem-staked closed 5 months ago

artem-staked commented 6 months ago

Here https://github.com/polkascan/py-substrate-interface/blob/master/substrateinterface/base.py#L2358 you do validator_set = self.query("Session", "Validators", block_hash=block_hash) And block_hash equals the block we're querying for.

But here https://github.com/chainflip-io/polkadot-sdk/blob/chainflip/polkadot-v1.6.0/substrate/client/consensus/aura/src/import_queue.rs#L196 it's implemented differently. They actually get validator set for parent hash.

This results in the wrong author of the block being shown at the edge of epochs when validators set updated.

For example, if you check https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet-archive.chainflip.io#/explorer/query/136993 (this is the first block of epoch) you can see its author iscFLq56dodm9uWSqxc2HBD4jAjqxzEQukZ7hPKV6BDoyMHkD26, but if you load the same block using SubstrateInterface si.get_block_header(si.get_block_hash(136993), include_author=True)["author"] it'll show cFPAWLomZyFwZLgyTrnZVM5Va9GSK2vdG8sNftnxZ4AZ8yHgq, because it's loaded from current epoch validator set and not the previous one

arjanz commented 5 months ago

Fix release in: https://github.com/polkascan/py-substrate-interface/releases/tag/v1.7.8