-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose validators as host function #2475
Comments
It's not simple to provide all validators with their stakes into the wasm because of limited support for serialization. Our current design for WASM was serialization independent, so we didn't settle on Borsh. I suggest the following API:
|
Another function we need is |
We can also expose the validators the following way: Which will make it flexible enough so long as we can pass validators in sorted order and the list of validators is not long enough. |
We also need |
Sorry, I meant
|
Do we actually need the list of all validators? It seems to me that having
is better because then if you want to know the stake of a specific validator, you don't need to iterate through all validators, which would be gas-consuming. |
Let's create a spec change in NEPs. I think we can go with the following API:
|
Voting contract can't iterate through all validators, because they might not be elected in a given epoch. The total amount of validators who tried to stake (but didn't get elected into 100 seats) can be huge. We can't possibly know who was elected in a current epoch, unless we tracked every single stake proposal from the previous epoch, so this is not the case. It leaves us with the only option for iterating through the list of currently active seats. Ideally they should be sorted in order from the largest stake to the lowest. Iterating through 100 seats is not a lot of gas, because it doesn't touch storage. |
@evgenykuzyakov I don't understand why the voting contract has to iterate through all validators. From my perspective, it is sufficient to know for each account id, what their stake is (0 if they are not a validator) and the total stake. With this information it is sufficient to determine whether a proposal has the majority of votes. |
For this you have to iterate through all possible votes within an epoch. It means if the validator doesn't call the voting contract within this epoch, his vote will not be counted, unless you want to iterate through casted votes. |
This seems to be a duplicate of #2504 . Closing it. |
Expose validator information as host functions: ``` validator_stake(account_id_len: u64, account_id_ptr: u64, stake_ptr: u64) -> [] total_validator_stake(stake_ptr: u64) -> [] ``` so that voting contract can calculate the weight of each vote. Resolves #2475. Implements the runtime change specified in near/NEPs#62
For voting contract #2474 it's required to query current stake by validator account id.
TBD the APIs.
The text was updated successfully, but these errors were encountered: