node-real / bsc-erigon

Ethereum implementation on the efficiency frontier
GNU Lesser General Public License v3.0
124 stars 42 forks source link

Validator and staking metrics API #531

Closed ttibord closed 4 days ago

ttibord commented 1 week ago

Hi, Can you point me to an API endpoint on the BSC Erigon archive node, or recommend reading/specs, that would allow for building a history of staking rewards and participating validators? For example, equivalent of /eth/v1/beacon/states/BLOCK_NUMBER/validators on beacon chain. From my understanding of docs, and current validator metrics, there should be ~24 non-Cabinet validators, considered candidates alongside the cabinet and receiving an undefined smaller chance of rewards. Any additional details (links to a good discussion or issue) on this would also be greatly appreciated.

Thank you in advance!

setunapo commented 4 days ago

https://www.bnbchain.org/en/bnb-staking Currently, BSC mainnet has 21 cabinet validator and 24 candidate validators. So you wanna to analyse the BSC staking reward history, right?

Sorry, there is no such kind of API in Erigon right now, here is some concepts hope can give some help: 1.BSC validatorset are determined on epoch block height(BlockNum%200 == 0), like https://bscscan.com/block/43098800 the validatorset is encoded in Header.extra. There is a tool to parse it in BSC-Geth repo: https://github.com/bnb-chain/bsc/tree/master/cmd/extradump

cd <bsc>/cmd/extradump
go build .
./extradump 0xd98301040e846765746889676f312e32312e3133856c696e7578000060adae271518c44f4fbede9826c7f257d500a65a3d5a8edebca76a951b947eda0b4585730049bf08338c0e679071127f0f2f7e7dce542a655d69b24e7af4586ed20efc2764044c0b3c1cfdbd2dff70c6e2e30df5012726f87731f381648e9879d77f0f25c8f6348135cef7477c2455f516bec180921d4c669eae7258857327674ace724b598c0df3fd41068ef837e9627a91dd13e453246856d58797ad6583d762abd04e3688a7c071dbc7eb3d0ace1c06baf163fdc8ffc742fec16f09fa468d30778a3c533b944899d33ae3225a3aee0738944092685a336cb6b9ea58836436709a2adc89afc1c041d36ee43ed51b1cb17b9dff14068e594b79a3c401a0bcf9fae9fd86324822fc0bb768f0b7dae76927b23d3954460a252b4feefa821d3351731220627d7b7d1f3db3e34a6e7967c4da80dd3e5227acb02c92f33a026bbce5e52c19b7d8746b7e55d3e29b9083de0bf334fdf8ac91bc14854e5acf9684652bea56f2f01b7101a225ee33d23f8bcfeba8fcafdc6b6f9016d5a0dd08e4685a13bffd8c2087f66bf7ca2dace7fbbc40c40824e30a84d3fe62a2ddcd5217502aecfe253e6aa0e8d2a06e12438ffed0fe16a0b15df58914a6b751909f0558a9f9af8efca7d46e480fc24478d977dafe7daf5161b38c72e9e1ea4865c288ef5b8054ab58567f7a51a58708c8b40ec592a38ba64c0697de8d78def84b10ab93dbfff6980d1054a2bc561bcf0abf3daf6096849bf03744fd4a49392e4813dc2251d68f6f95f27ba775b851a27d7101438f45fce31816501193239a83ad9a5f4ae5ec7dd886b09a47021461ec6f1971b3558f31e622311e94714398c80573fd531e0e8b4c4c3b456c4a5b9bf67b501c7944185130dd4ad73293e8aa84effdcee7b7adb10448b8be5fc875af7df065a5ee57f2ace2cca77b37bbe2e30fd16481afe8a64fe4dd3aff03d14fb180a05bf6a07e1fdf03eb3ac35bf0256694d7fbe6b6d7b3e0c8a066981de27634c2d17a68333f6d9b0c8cd7e08882c397c6ad92d95f8c279d6ef9ea04a1e2f4c4cdfe7ea6015f367ccb8a239732871adc8829ea2f47e94087c5fbad47b6adc9ae11a5f0da15082a4ded8abaeb73338984c06e2c1af2eb24232e00511e95b24e89291d689f6bedb13d5a398af2ec978f05ced39a4eafa6e8fd045fe2dd6da836c7dfa693d66f1267fdcf9f2d8f08bd398252af79b8868921552ae70bcd00174444df4839e67aeb6d5db8d6b864fa83429f1c9bb56c2b4dbe5a06d79911c9899b6f817696acfc90ba8c56b1a3c032a3a0395d0f42f3a00b4f50ce9dc41f819a601e8f17b00e7a4eba8a9af4c4b3fdd31d555ccf70058db4647b856cb9c3856d559c885bed8b43e0846a47a663982486c84b2f66d9391efe6875d30be1d907e55d9c4a5a224de92a5d8ff180cc4ebca44253fa5a9730cc89d61994bdcc079bbb23c1d9a6f36aa31309676c258abac7a2564fd6f7101c1fdb441018a24d25672826953caa03b6717e26e8af1c38507dd570bdedf1cb270c376630823f101577ca503a7ed99eca485da2e875aedf7758472c378c91dce99bbdc44ee9500ed1e5c864bc88ba518585c7e6de5e94d26ee216dd8a5e06c5d2fc740123976c9588787b54998cccb42a9b8d6c46468900527bc741938e78ab4577b1e211be938b9f77888cbdc7bd3787148a6d1653eb0e17603df69d67db30fa4857e11edec461e01e3e02cea2c7d2c5ddd3b0d838ccceae7ebf1781d11d1bb741db7fe1a7b39bdc22b7275d8456ee325424d33829d364270b1ecebb389318c7f0cb1f1c334f05d1d5e26472f2cd07f5d8025ea266f8b99643fafc79d9404de68e48c4d49a3936f7878d68efc0951aa89bf89fd829dd021fac27712f0f046e70d2d33a8a1fc05554a16d26669a9adb33bb41aaff43df7d4da0f8de5e61322302b2c6e0a525cc842f10332811bf8e69853df9edb142b5d596f93bfa14253a733cb9d2d5a7ed1fc345e248a8cae7f23f438930123eebf61c98785d846a8b01f8b5831fffffb860a47ab74753d2277517bc9b1605e2aac67ba1282c60518c8ea214013baac5948f6c23615f697aa346704230fbc00c718e0b94e2d35711a80f5ef3e8c557f988c232ebde9accb18a54900612dc06cda54451cedcd7295dd9ee703c70dcbcce5f4bf84c840291a2aea0aad687663342367dc5eb69a4fa23e56a2d7134e709d425296d5cd81307ca1e73840291a2afa084ff6bd566f27016b86297f123bd107be6cf94d78b9f928b823e3dda0a12997e80238e46dd400337048752e983e7f151487ac774de77c1fae4fa027c8b0f54d46d16a1e2b982e2528ea7dffed2bbe71816026407a8f0895db1f190e9f1131244d900

2.BSC's validator reward was distributed by SystemContract, which is part of the consensus, they are the last transactions in the block.

image

for reward related descriptions, you may refer this BEP: https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP-319.md

ttibord commented 4 days ago

This is helpful, thank you for the details! 🙌 We'll consider the implementation and reopen if stuck on something specific.