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

Fix deposit domain #1055

Merged
merged 7 commits into from
May 22, 2019
Merged

Fix deposit domain #1055

merged 7 commits into from
May 22, 2019

Conversation

protolambda
Copy link
Collaborator

Forks are ignored for deposit validity: deposits are always accepted (if coming from the correct contract(s)).

Credits to @cemozerr for pointing out that the Validator and Beacon spec were inconsistent here.
Credits to @schroedingerscode for pointing out that the domain format changed some time ago (fork version and domain type swapped)

After looking into the inconsistency discussion on gitter, it occurred to me that deposits are not bound to an eth 2.0 fork, but to the eth 1.0 contract, and maybe shouldn't be signed. Vaguely remembering previous discussions about singatures with @JustinDrake in Sydney. This was confirmed to stay zeroed across forks (or previous GENESIS_FORK_VERSION), and here's the fix.

Note: I swapped back fork-version and domain type, as the change here looks unintentional, and signing/verifying with just the domain-type is more straight-forward this way.

…are always accepted, if coming from the correct contract(s).
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
@JustinDrake
Copy link
Collaborator

The current solution may be insufficient in the context of multiple deposit contracts. One approach is to assign each deposit contract a version and for deposits replace state.fork with deposit_contract.version in the calculation of domains.

@djrtwo
Copy link
Contributor

djrtwo commented May 8, 2019

I'm inclined to assume we have one deposit contract and to handle the exceptional case if we happen to change deposit contracts. Note that the rest of the eth1data machinery is not sufficient for multiple deposit contracts either

@protolambda
Copy link
Collaborator Author

Note that the rest of the eth1data machinery is not sufficient for multiple deposit contracts either

Deposit index is very much a singleton mechanism indeed.

Maybe it can be solved on the eth1 side, i.e. make the deposit contract flexible for permissioned integration of secondary contracts (for whatever reason you need a second contract to deal with deposits). However, I think the only reason for another contract is some kind of bug / unfortunate event, and in that case I suppose we fork the beacon chain for a new contract.

So what's the way forward? Create a helper function to more explicitly create a correct signature domain for deposits? I think this would be neat to just do with typing, if we had them...

A helper would be something like bls_domain(domain_type, fork_version), call bls_domain(DOMAIN_TYPE_DEPOSIT, b'\x00\x00\x00\x00')

@djrtwo
Copy link
Contributor

djrtwo commented May 12, 2019

so get_domain calls bls_domain, and when constructing a deposit domain, one calls bls_domain directly?

seems reasonable.

@djrtwo
Copy link
Contributor

djrtwo commented May 21, 2019

Made the adjustment of pulling out bls_domain into separate function and calling it directly when handling deposit domains.

Ready for review @protolambda @JustinDrake

@djrtwo djrtwo requested a review from JustinDrake May 21, 2019 17:40
@protolambda
Copy link
Collaborator Author

Defaulting to zero lets us avoid another pseudo-configurable constant. Generally also nicer to just read what the signature is about, i.e. the domain, and no more. And bls_domain nicely black-boxes the actual bytes being formatted into a BLS domain.

@djrtwo
Copy link
Contributor

djrtwo commented May 22, 2019

lgtm

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

Approving with one type hinting change request. 👍

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
@djrtwo djrtwo merged commit e509015 into dev May 22, 2019
@djrtwo djrtwo deleted the fix-deposit-forkv branch May 22, 2019 20:55
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.

4 participants