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

Properly allocate runtime IDs #1693

Closed
Yawning opened this issue May 10, 2019 · 6 comments
Closed

Properly allocate runtime IDs #1693

Yawning opened this issue May 10, 2019 · 6 comments
Assignees
Labels
c:breaking/consensus Category: breaking consensus changes p:1 Priority: core feature s:needs adr Needs a design document, discussion and decision (ADR)

Comments

@Yawning
Copy link
Contributor

Yawning commented May 10, 2019

This is more of a policy decision than an actual coding one. For the sake of sanity, we should start properly allocating runtime IDs. Currently absolutely everything uses 0000000000000000000000000000000000000000000000000000000000000000 which is sub-optimal to the extreme.

I'm tempted to explicitly reject the default runtime ID value since that's what the uninitialized value will be on the Go side, but that might be overly disruptive, and it will be pointless if people just start using runtime ID 1 instead.

Things that need runtime IDs:

  • runtime-ethereum
  • simple-keyvalue
  • keymanager

Note: It's not inconceivable that the same runtime will have multiple runtime IDs, since it doubles as a deployment identifier. Test runtimes that should never see production deployment should probably live in a dedicated part of the runtime ID space as well.

@Yawning Yawning added p:1 Priority: core feature c:breaking/consensus Category: breaking consensus changes labels May 10, 2019
@kostko kostko added the s:needs adr Needs a design document, discussion and decision (ADR) label May 10, 2019
@kostko
Copy link
Member

kostko commented Jun 29, 2019

Is there a reason why the runtime ID is currently considered to be a public key? This doesn't seem right with the current design. Should we switch to something else just to make it clear? For example in roothash (and soon in storage, e.g., #1857) we use the namespace type (which has the exact same representation just without public key semantics).

@Yawning
Copy link
Contributor Author

Yawning commented Jul 1, 2019

Is there a reason why the runtime ID is currently considered to be a public key?

No concrete reason. Was thinking we might want to allow runtime authors to sign things with the runtime signing key (as opposed to say, the SGX signing key) at some point, but I'm not sure that's needed. It likely depends on how updates are handled.

@kostko kostko changed the title Properly allocate runtime IDs. Properly allocate runtime IDs Nov 11, 2019
@kostko kostko mentioned this issue Dec 4, 2019
15 tasks
@kostko kostko mentioned this issue Dec 15, 2019
16 tasks
@kostko
Copy link
Member

kostko commented Dec 24, 2019

I think we should segment runtime identifiers as follows:

  • The first byte of the runtime ID is reserved and can only be set to one of the predefined values. This is enforced by the consensus layer and other applications relying on runtime kinds.
  • The first byte is interpreted as a bit vector, each bit specifying a flag. Bit 0 is the most significant bit.
  • Bit 0 specifies whether the runtime is a test runtime (0 = production, 1 = test). Test runtimes are only allowed if a registry consensus parameter DebugAllowTestRuntimes is set. We could additionally only allow debug enclaves to be used with test runtimes.
  • Bit 1 specifies whether the runtime is a key manager runtime (0 = not key manager, 1 = key manager). Only key manager runtime IDs are allowed to be used for the key manager runtime, enforced by the registry.
  • Bit 2 specifies whether the runtime is a stateless runtime (0 = stateful, 1 = stateless).
  • Bits 3-7 are reserved and must be set to zero.

Does this give us enough room for future extensions or do we need to reserve more than the first byte?

@Yawning
Copy link
Contributor Author

Yawning commented Dec 27, 2019

Does the rest of the runtime ID need to have high entropy? Otherwise I'd say we can reserve more bits (first 32-64 bits), because we do have 256 bits to work with.

@kostko
Copy link
Member

kostko commented Dec 27, 2019

No, runtime IDs don't need high entropy IMO, so yeah I agree that reserving more makes sense here.

@Yawning
Copy link
Contributor Author

Yawning commented Jan 10, 2020

Fixed by #2530

@Yawning Yawning closed this as completed Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:breaking/consensus Category: breaking consensus changes p:1 Priority: core feature s:needs adr Needs a design document, discussion and decision (ADR)
Projects
None yet
Development

No branches or pull requests

2 participants