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

CIP-26 precompile #1307

Merged
merged 57 commits into from
Jan 29, 2021
Merged

CIP-26 precompile #1307

merged 57 commits into from
Jan 29, 2021

Conversation

mrsmkl
Copy link
Contributor

@mrsmkl mrsmkl commented Jan 20, 2021

Description

#1250

Recover if cannot load the round state.
Changed so that the BLS keys are now uncompressed when the snapshot is created.

Other changes

Tested

I ran some tests to make sure that stored snapshots include the uncompressed keys.
Also checked that it won't get stuck if there's an old roundstate.

Related issues

Backwards compatibility

consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator.go Outdated Show resolved Hide resolved
@trianglesphere trianglesphere removed their request for review January 22, 2021 18:06
Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

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

Left some comments!

consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/validator.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
@@ -185,7 +190,7 @@ func (s *Snapshot) UnmarshalJSON(b []byte) error {
s.Epoch = j.Epoch
s.Number = j.Number
s.Hash = j.Hash
s.ValSet = validator.NewSet(j.Validators)
s.ValSet = validator.NewSetWithCache(j.Validators)
Copy link
Contributor

Choose a reason for hiding this comment

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

here's something strange. Not related to this PR actually.

A ValidatorSet is actually a ([]validators, randomness), but when we "save" it we don't save the randomness, and thus on unmarshall we don't have it, nor we care.

Which makes me wonder if we really want a validatorSet or if we should save the randomenss.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like randomness is only needed in the round state to determine next proposer, so it's not needed in the snapshots.

Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

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

Left some comments!

consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
consensus/istanbul/validator.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/blockchain.go Outdated Show resolved Hide resolved
@@ -138,6 +138,7 @@ const (
FractionMulExpGas uint64 = 50 // Cost of performing multiplication and exponentiation of fractions to an exponent of up to 10^3.
ProofOfPossessionGas uint64 = 350000 // Cost of verifying a BLS proof of possession.
GetValidatorGas uint64 = 1000 // Cost of reading a validator's address.
GetValidatorBLSGas uint64 = 1000 // Cost of reading a validator's BLS public key.
Copy link
Contributor

Choose a reason for hiding this comment

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

how did we obtained this value?? cc @prestwich @kobigurk

Copy link
Contributor

Choose a reason for hiding this comment

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

@mrsmkl's reasoning was that since it's cached, the cost is the same as GetValidatorGas, because it's just reading a value from a similar place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The benchmarking code is in this repo: https://github.com/mrsmkl/b12-sol/

trie/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
consensus/istanbul/backend/snapshot.go Show resolved Hide resolved
consensus/istanbul/validator/default.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

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

Great for going over all my comments!!! Looks much better now. There's a typo on one godoc that missing, but we're ready to go

@mrsmkl mrsmkl merged commit 5ab2a45 into master Jan 29, 2021
@mrsmkl mrsmkl deleted the mrsmkl/precompile-bls-key branch January 29, 2021 19:00
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.

3 participants