8000 Use strong types to semantically differentiate plain data · Issue #661 · agglayer/agglayer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content < 8000 link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/keyboard-shortcuts-dialog.47de85e2c17af43cefd5.module.css" />
Use strong types to semantically differentiate plain data #661
Closed
@iljakuklic

Description

@iljakuklic

To enhance the safety and robustness, various plain data types should be replaced with strongly typed wrappers, to semantically differentiate between them. This applies mostly to numbers and hashes.

The value we get from tooling will be improved too:

  • Compiler checking for potential mismatches.
  • Self-documenting function signatures. (Rustdoc is capable of looking up functions from signature, precise types help there.)
  • I also noticed that lately rust language server does some light type directed search to rank completions.

An incomplete list (feel free to add):

  • Booleans (bool)
    • a custom enum is often more expressive and readable, e.g. ForceUpdate::{Yes, No}.
  • Numbers (u32, u64 for most part)
    • mostly various IDs and indices and counters
    • NetworkId, RollupId
    • RollupIndex, ExitIndex
    • EpochNumber, CertificateHeight, L1BlockHeight, ...
  • Hashes (H256, [u8; 32], agglayer_types::Digest)
    • ${WHATEVER}ExitRoot, L1InfoRoot< 6C16 /li>
    • CertificateId

Related:

Metadata

Metadata

Labels

agglayer-noderustPull requests that update Rust code

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0