-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature requests for AuRa #41
Comments
I like the idea, because I think that in general it's good to have more than one engine that's compatible with that set of contracts. AuRa doesn't make it easy to provide trustworthy random numbers, though. Or block timestamps! I guess for now we'd just have to trust the primary, but that way it certainly wouldn't be good for anything but testing purposes. /cc @DrPeterVanNostrand, @mbr, @c0gent |
@varasev I think we only need #33 for testing on AuRa
|
In the case of
Note that the standard To remove this requirement the So, in case of reporting malicious validators in AuRa, we also need the Another way is to introduce support of events emitting by system transactions because currently Parity doesn't support that: https://wiki.parity.io/Validator-Set.html#limitations |
|
I'm not sure how point 1 would work in detail: Would the other nodes store their random numbers using regular transactions, as clients? Or when it's their turn, as a primary? Either way, the last one to submit their numbers could then freely determine the result, couldn't they? So I'm wondering whether this is any better than having only the primary generate the numbers. I agree with 2; we'll just need to figure out why |
I see the next problem here: if some arbitrary participants generate the numbers, we won't have guarantees that the numbers have a uniform distribution 🤔 We need twenty 64-bit unsigned uniformly distributed random numbers (in the range from 0 to 0xffffffffffffffff). |
Exactly: With AuRa, I think it's difficult to get that kind of guarantee. |
Randao also uses random numbers provided by arbitrary users, so it is also affected. It seems to be a good subject to think for us. |
Yes, but in randao, the users first commit to their number without revealing it, by submitting only the hash and some amount of ETH as a pledge. This considerably ameliorates the attack: The last one to reveal their number can still refuse to do so (and pay the penalty by not getting their ETH pledge back). But at least that way, they only can choose between two outcomes (the one with and without their number), and they have an incentive to play by the rules. In Honey Badger, it's even better: everyone also first commits to their number without revealing it, but this time not using a hash but by threshold-encrypting their number (as part of their contribution). That way, they won't even have the option later to refuse to reveal it: the other validators can collaborate to decrypt the number. |
Randao is a good solution to stimulate users to reveal their seeds, but it is also trustless because they can commit ununiformly distributed numbers. What if each validator node that creates a block would just generate and save one random number per block into the contract. Then after 20 blocks, we would be able to use the last 20 random numbers? So, I think maybe we could trust the validator who creates a block at the moment? |
Yes, but since they are all xored together at the end, the result is uniformly distributed even if just one of the contributors was honest. Sure, we can just trust the primary validator for now. But for any production system, I think we'd need a different solution. |
Another lack of randao is that one campaign for getting one random number takes some time (because the contributors need have enough time to take part in the process). So, we'll need to wait for some time to get 20 random numbers. Also, the calling contract ( Did I understand it correctly that you suggest calling randao's functions from validator nodes? I.e., the contributors should be validators? |
Yes, I think so. And I guess the validators can use their stakes as the bounty? |
Ok. No, the addresses cannot use their stakes while they're validators. Also, the stakes will be made in ERC20 tokens (not in native coins). I'll think about how to use randao in our case. |
One more idea for random in AuRa (refers to #41 (comment)) is to hash random number (submitted by validator's node) with a previous hash result: function storeRandom(uint256[] _random) public onlySystem {
require(_random.length == 20);
for (uint256 i = 0; i < 20; i++) {
currentRandom[i] = uint256(keccak256(currentRandom[i], _random[i]));
}
} So, when some validator generates 20 random numbers, they are hashed with random numbers saved previously. In this case, it's difficult for the last validator to submit such a number that would result in predictable |
That does make it infeasible to pick an exact value for |
The problem with the last participant is also possible in case of randao :( because the current random number can be read by anyone from It seems that accumulating the random numbers in the contract before Maybe we could pass the array of random numbers at the moment of E.g., all validators' nodes know the future number of the block when |
But the problem is way less severe with randao, because by the time the numbers are revealed, everyone has already committed to their number (i.e. published its hash). So the last validator has only two options: reveal their number or not. That way they can only pick one of two results, and also only if they are willing to forfeit their pledge money. With the above approach, the last validator could simply freely choose among any of thousands of possible values.
But the primary would be the one who'd collect all the other validators' transactions, and could decide for each of them whether it should be included in the block. And worse: by the time the primary puts together the block, they do know which numbers the others have picked, so the problem would still be the same. Technically, they would be the last one to pick their number, and therefore could freely choose the result. (Or maybe I'm misunderstanding what you're proposing: but how could, with AuRa, everyone write numbers to the contract at the same time? It's only one node who actually produces the block, isn't it?) |
Yes, you're right. Seems that randao is a better solution. We need to solve what to do if not all committers reveal their seeds or if we're not collected all 20 numbers in time. I'm thinking about that... |
So, I decided to create a separate This contract supports only one of two possible consensus modes at the same time: AuRa or HBBFT. The consensus mode is defined in the constructor. Initially I wanted to split the logic into two different contracts (the first for AuRa and second - for HBBFT) but later I decided to implement in one. For HBBFT the contract contains only one function - For AuRa there're several functions needed to generate random numbers in I propose to have so called Each phase is determined by the current block number: https://github.com/poanetwork/pos-contracts/blob/ab5f8d797fc1b3582f4feedada1fd6480e891f47/contracts/Random.sol#L118-L126 In The node can call Then after 100 blocks (during the Once all the validators make reveals, the XORed random number is stored in public array (max length of which is 20). Then the next Totally, we will have 20 random numbers refreshed permanently several times a staking epoch (which duration is 1 week). If we take 200 blocks as the length of To implement the described mechanism we need to make Parity call the functions of |
In general, I think this works and produces actual random numbers, especially since the round lengths are long enough to allow every validator to commit and reveal. We should consider it malicious behavior to not reveal (and maybe also to not commit), to make sure the last validator can't freely decide whether to reveal or not. But I still see a few problems with this: Storing the random numbers on the blockchain is only useful if they are either used within the same block or if there is no way to manipulate what they are going to be used for in the meantime. More concretely:
It would be nice to add a |
Yes, this should be treated as misbehavior.
I think for AuRa we could deny making the changes for the last few hours of staking epoch so that the users couldn't manipulate the outcome in this case. The users will see the random numbers at the last blocks of staking epoch but won't be able to influence the outcome.
I guess this is possible for HBBFT but I think we cannot do the same for AuRa because in AuRa we only have one validator producing the block, so we should trust him. So, for AuRa, I propose to implement the mechanism described above. |
Sounds good! 👍
Yes, I agree. |
Hi guys,
We'll most likely need to test the contracts with AuRa engine first.
Could we do the same things that described in issues #32, #33, and #34 for AuRa engine?
The text was updated successfully, but these errors were encountered: