Skip to content
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

Add precompiles to access validator set #441

Merged
merged 6 commits into from
Sep 13, 2019
Merged

Conversation

m-chrzan
Copy link
Contributor

@m-chrzan m-chrzan commented Sep 6, 2019

Description

Sister monorepo PR: celo-org/celo-monorepo#874

This PR adds two precompiled contracts that give the EVM access to the current validator set's information.

  • getValidator at 0xfa - takes as input an index, returns the address of the validator at that index. Reverts if out of bounds.
  • numberValidators at 0xf9 - returns the size of the current validator set.

Tested

Geth e2e tests in monorepo.

Related issues

Backwards compatibility

No breaking changes, only adds new precompiles.

@m-chrzan m-chrzan requested a review from asaj as a code owner September 6, 2019 20:51
@kevjue
Copy link
Contributor

kevjue commented Sep 9, 2019

The code LGTM. However, seems like there are some unit tests that are failing. I would of expected that, since the evmcontext object (which now has a new field) is well used within the unit tests.

I'll approve once the unit tests pass.

@kevjue kevjue assigned m-chrzan and unassigned kevjue Sep 9, 2019
@asaj
Copy link
Contributor

asaj commented Sep 9, 2019

Why not have a single precompile that returns the entire set? Seems like that would be more flexible going forward

@asaj asaj removed their assignment Sep 9, 2019
@m-chrzan
Copy link
Contributor Author

m-chrzan commented Sep 9, 2019

However, seems like there are some unit tests that are failing. I would of expected that, since the evmcontext object (which now has a new field) is well used within the unit tests.

Working through those right now.

Why not have a single precompile that returns the entire set? Seems like that would be more flexible going forward

I'd imagine we would set a higher gas cost (proportional to size of validator set) if we went with that approach. I wanted to allow contract authors to be able to optimize gas costs if they only need to read a few validator addresses (like our use case with requesting attestations.

Copy link
Contributor

@kevjue kevjue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@asaj asaj removed their assignment Sep 10, 2019
@asaj
Copy link
Contributor

asaj commented Sep 10, 2019

I'd imagine we would set a higher gas cost (proportional to size of validator set) if we went with that approach. I wanted to allow contract authors to be able to optimize gas costs if they only need to read a few validator addresses (like our use case with requesting attestations.

Should we include an isValidator precompile? I'm worried these precompiles are a bit too specific to our attestations use case, and won't generalize well (though we can always add more later on)

@m-chrzan
Copy link
Contributor Author

Should we include an isValidator precompile?

I've actually been considering adding this as well recently. Feels like it could easily be a follow up PR though.

@m-chrzan m-chrzan merged commit d4b48f3 into master Sep 13, 2019
kevjue added a commit that referenced this pull request Sep 24, 2019
* Add precompiles to access validator set (#441)

* set max gas to double of the charged gas for the 'intrinsic' smart contract calls (#472)

* set max gas to double of the charged gas for the 'intrinsic' evm operations

* addressed PR comments

* addressed pr comment

* Adds Prepared Certificates to ensure Istanbul liveness (#366)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2
kevjue added a commit that referenced this pull request Sep 25, 2019
* contract_comm/currency/currency.go

* fixed the txn price-sorted min-heap

* merge master (#490)

* Add precompiles to access validator set (#441)

* set max gas to double of the charged gas for the 'intrinsic' smart contract calls (#472)

* set max gas to double of the charged gas for the 'intrinsic' evm operations

* addressed PR comments

* addressed pr comment

* Adds Prepared Certificates to ensure Istanbul liveness (#366)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2
kevjue added a commit that referenced this pull request Sep 25, 2019
* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2

* tx price heap fix (#471)

* contract_comm/currency/currency.go

* fixed the txn price-sorted min-heap

* merge master (#490)

* Add precompiles to access validator set (#441)

* set max gas to double of the charged gas for the 'intrinsic' smart contract calls (#472)

* set max gas to double of the charged gas for the 'intrinsic' evm operations

* addressed PR comments

* addressed pr comment

* Adds Prepared Certificates to ensure Istanbul liveness (#366)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2

* added new option --use-in-memory-discovery-table (#479)

* added new option --use-in-memory-discovery-table

* merge master (#489)

* Adds Prepared Certificates to ensure Istanbul liveness (#366)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2

* Allow v4/v5 on a bootnode simultaneously, allow mobile to use discv5 (#454)

* changes for isolating celo networks

* changes to get unit tests working

* changes to add salt in the discovery packets

* removed checking for the ip address when handling a reply

* added ping-ip-from-packet option to bootnode

* for handling expected replies, don't filter on expected sender ip address if --pingIPFromPacket is used

* Add v4 flag

* Add unhandled and quicken docker builds

* Add salt & logs

* Add v4 flag

* Add PeerDiscovery to mobile node config

* Remove logs

* Remove hardcoded bootnodes

* Add salt & turn on discv5

* Delete hardcoded eth bootnodes

* Make Discoveryv5 configurable

* Lint

* Add comment to bootnode v4/v5 handling

* Change PeerDiscovery -> NoDiscovery

* Remove mobile geth no discovery

* Reduce istanbul default timeout, cap exp backoff (#475)

* Reduce istanbul default timeout, cap exp backoff

* Ensure round 0 timeout factors in block period

* Sanitize logs (#495)

* Change registry lookup and infrastructure lookup error logs to debug level

* Sanitize logs regarding registry deployment

* Change empty abi logging and comment

* Lower log level from error to warning for potentially outdated istanbul messages

* Change back to an error message

* Add input length checks for precompiled contracts (#476)

* add input length checks

* check exact input length. add a new error for input length. check input in a few more places

* add tests that verify the input-length checks for contracts that don't require an evm instance

* fix formatting

* add comments to explain input length checks

* run the formatter

* e2e transfer test was failing because it passes in a transaction options object, making the input larger than 96 bytes

* e2e tests have revealed that our precompiled contracts need to be tolerant of inputs that are longer than the bytes that are actually read
kevjue pushed a commit that referenced this pull request Sep 26, 2019
* Log on ValidatorElections

* merge master (#496)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2

* tx price heap fix (#471)

* contract_comm/currency/currency.go

* fixed the txn price-sorted min-heap

* merge master (#490)

* Add precompiles to access validator set (#441)

* set max gas to double of the charged gas for the 'intrinsic' smart contract calls (#472)

* set max gas to double of the charged gas for the 'intrinsic' evm operations

* addressed PR comments

* addressed pr comment

* Adds Prepared Certificates to ensure Istanbul liveness (#366)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2

* added new option --use-in-memory-discovery-table (#479)

* added new option --use-in-memory-discovery-table

* merge master (#489)

* Adds Prepared Certificates to ensure Istanbul liveness (#366)

* Check message address against signature (#477)

* Check signing validator's address matches msg address

* Add comments about use of sig data in tests

* Try fix Circle build test failures

* Try fix Circle build test failures, take 2

* Allow v4/v5 on a bootnode simultaneously, allow mobile to use discv5 (#454)

* changes for isolating celo networks

* changes to get unit tests working

* changes to add salt in the discovery packets

* removed checking for the ip address when handling a reply

* added ping-ip-from-packet option to bootnode

* for handling expected replies, don't filter on expected sender ip address if --pingIPFromPacket is used

* Add v4 flag

* Add unhandled and quicken docker builds

* Add salt & logs

* Add v4 flag

* Add PeerDiscovery to mobile node config

* Remove logs

* Remove hardcoded bootnodes

* Add salt & turn on discv5

* Delete hardcoded eth bootnodes

* Make Discoveryv5 configurable

* Lint

* Add comment to bootnode v4/v5 handling

* Change PeerDiscovery -> NoDiscovery

* Remove mobile geth no discovery

* Reduce istanbul default timeout, cap exp backoff (#475)

* Reduce istanbul default timeout, cap exp backoff

* Ensure round 0 timeout factors in block period

* Sanitize logs (#495)

* Change registry lookup and infrastructure lookup error logs to debug level

* Sanitize logs regarding registry deployment

* Change empty abi logging and comment

* Lower log level from error to warning for potentially outdated istanbul messages

* Change back to an error message

* Add input length checks for precompiled contracts (#476)

* add input length checks

* check exact input length. add a new error for input length. check input in a few more places

* add tests that verify the input-length checks for contracts that don't require an evm instance

* fix formatting

* add comments to explain input length checks

* run the formatter

* e2e transfer test was failing because it passes in a transaction options object, making the input larger than 96 bytes

* e2e tests have revealed that our precompiled contracts need to be tolerant of inputs that are longer than the bytes that are actually read
@mcortesi mcortesi deleted the m-chrzan/validators-list branch December 4, 2019 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attestations SBAT access current validator set
3 participants