-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: Randomness module #117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments on the .netrc stuff, otherwise LGTM.
DEVELOPING.md
Outdated
To run end-to-end tests, you first need to create a file `.netrc` containing GitHub credentials in the project root. This enables an access to the private repositories during the Docker build process. The `.netrc` file should look as follows: | ||
```bash | ||
machine github.com | ||
login <YOUR_USERNAME> | ||
password <YOUR_GITHUB_TOKEN> | ||
``` | ||
|
||
The e2e testing can now be run with the following command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things:
- Do you know if this is secure? I.e., does no command print out the GitHub username/token from the container?
- Can we not use a
.env
file instead?
Either way, an example file would be nice, like example.netrc
or e2e.example.env
. Then in the md you can link to the example file :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build process doesn't print it out, and the container just contains the file. Probably not ideal, but it's not any less secure than other commonly suggested solutions.
// err = mempool.Insert(ctx, tx) | ||
// if err != nil { | ||
// return nil, err | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we probably wouldn't need to worry about the mempool at all. CometBFT is responsible for selecting txns from the mempool and proposing them in a new block. PrepareProposal
then receives the proposed txns.
We are also already directly including the new seed txn in the proposal by which point we'd have bypassed the mempool already.
} | ||
|
||
// TO-DO run DefaultProposalHandler.ProcessProposalHandler first? | ||
// TO-DO Validate()? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need to do some stateless checks here. We are using msg.Pi
and msg.Beta
below without checking their legitimacies first. If msg.Pi
and/or msg.Beta
is an empty string, hex.DecodeString
will return an empty byte slice and no error. This would bypass the if err != nil {}
checks and lead to a panic due to !bytes.Equal(beta, msgBeta)
.
Motivation
This PR fully implements the randomness module, which will be used as a source of randomness in SEDA protocol.
An example of a query:
Explanation of Changes
The implementation takes advantages of two CometBFT ABCI methods:
PrepareProposal
, which is run only by the block proposer while building a block, andProcessProposal
, which is run by all validators while validating a block. InPrepareProposal
the proposer computes the VRF proof by runningVRF_Prove(secret_key, alpha)
, wheresecret_key
is the consensus key andalpha
, or the input message, isprevious_seed || current_block_timestamp
. The block proposer then signs and prepends theNewSeed
transaction containing the VRF proofpi
and the VRF hash outputbeta
to the list of transactions in the block proposal.Upon receiving this nicely prepared proposal in
ProcessProposal
, the validators first check if the first transaction in the list is theNewSeed
sent by the current block proposer. If the check fails, they reject the block. If the check succeeds, the validators then runVRF_Verify(public_key, pi, alpha)
with the public key obtained from the validator store. The validator accepts or rejects the block based on the verification result.secp256k1
instead ofed25519
so that it is compatible with our VRF library.create-validator
transaction. A regular account is required when the block proposer signs and sends aNewSeed
transaction.Testing
Tested on a local single-node chain deployed manually and a two-node chain in e2e testing. In a single-node setting, the only proposer gets stuck due to the VRF bug and blocks don't get produced after some point. In a multi-node setting, this problem is prevented by the next proposer successfully creating a valid block.
To run the e2e test, create
.netrc
file in the project root and add the credentials for GitHub private repository access:Then run
make test-e2e
. (Currently not working due to a Cosmos SDK genesis JSON marshalling error.. Should be fixed soon.e2e works locally now but all CI tasks are failing due to issues with downloading the vrf-go repo, which is private.)Related PRs and Issues
Closes #112