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

[Feature] new network.id opcode #2419

Merged
merged 5 commits into from
Apr 12, 2024
Merged

[Feature] new network.id opcode #2419

merged 5 commits into from
Apr 12, 2024

Conversation

evan-schott
Copy link
Contributor

@evan-schott evan-schott commented Apr 2, 2024

Motivation

This PR introduces the opcode network.id to access the ID of the current network (ex: 0 for mainnet, or 3 for testnet3). This opcode can be used as a safeguard against replay attacks, as signatures or hashes of data can now be bound to a specific network. Users can now test program authorizations on testnet without worrying that the same authorizations be maliciously reused on mainnet.

Open questions

  1. Should network.id be allowed in transition functions?
    • We could not think of any potential use cases of such a feature that could not just be modified to attesting to a network ID value (as a transition function input), and then passing that value to finalize to verify it is correct.
    • Additionally, @bendyarm has pointed out that including this may result in potential difficulties with resolving the compile time value of network.id as it could be obfuscated if it were involved in computation.
  2. Should all block metadata be readily accessible? Relevant ARC

@evan-schott evan-schott requested a review from d0cd April 2, 2024 23:15
@evan-schott
Copy link
Contributor Author

Copy link
Contributor

@d0cd d0cd 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 feedback and nits.
The main question we should answer is whether or not to allow network.id in a non-finalize context.

ledger/src/tests.rs Outdated Show resolved Hide resolved
synthesizer/process/src/stack/evaluate.rs Show resolved Hide resolved
synthesizer/process/src/stack/execute.rs Show resolved Hide resolved
@d0cd
Copy link
Contributor

d0cd commented Apr 9, 2024

Should we add the network ID to the block-specific random seed?

https://github.com/AleoHQ/snarkVM/blob/69b5b17a9d7f32e4f3abbc562ef080adfb654877/synthesizer/program/src/logic/finalize_global_state/mod.rs#L57-L63

It's not necessary for this PR, but could be a useful property. Networks with different IDs have different RNG state.

@howardwu howardwu merged commit d48f6fb into mainnet-staging Apr 12, 2024
80 checks passed
@howardwu howardwu deleted the feat/network-id branch April 12, 2024 22:47
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