Skip to content

Commit 08b666a

Browse files
vadorovskySwen
andauthored
feat: DNS example (#1059)
* feat: `#[derive(LightHasher)]` macro and `AsByteVec` trait - `AsByteVec`, providing `as_byte_vec()` method, guarantees consistent way of serializing types to 2D byte vectors before hashing. We provide default implementations for primitives. More complex types need to implement `IntoBytes` themselves. - By using 2D vectors, we make it possible to represent structs with multiple fields. This way, we can handle struct fields (nested structs) the same way as primitive fields and deal with all types by using one trait. - The reason behing using vectors instead of slices is that in some cases, we cannot just cast the type without defining custom bytes. Vectors, although they might introduce copies, make sure we always own the bytes we are creating. - `#[derive(LightHasher)]` implements `AsByteVec` and `DataHasher` traits. The `DataHasher` implementation takes bytes returned by `AsByteVec` as an input. * test: Add more test cases for the `AsByteVec` trait - empty string - `Option` with `Some` and `None` and assertion that `None != Some(0)` - array (including an empty one) * doc: Add documentation to `LightHasher` macro * feat: DNS example Add an example program which stores simple DNS records as compressed accounts. It consists of the following endpoints: - create - update - delete Currently it has only Rust SBF tests. Co-authored-by: Michal Rostecki <vadorovsky@protonmail.com> * fix: Add `signer_check` utility * chore: Remove commented code * style: Rename to `compressed_output_account_with_address` * fix: Derive address from the domain name This gives a security guarantee for the program. Allowing the caller to pass a custom seed was not secure. * fix: Compute the hash of input accounts on-chain * perf(name-server): Reduce the instruction size - Avoid sending a full `CompressedAccount`. - SDK changes which make it easier: - Add `MerkleOutputContext` which stores only the Merkle tree pubkey. - Add `PackedAddressContext` for address Merkle tree and queue. - Add `pack_*` methods for above. - Add separate methods for single Merkle contexts (e.g. `pack_merkle_context`) and multiple ones (e.g. `pack_merkle_contexts`). - In contrast to the equivalents existing in system program SDK, do everything in one `iter().collect()` chain, not in 3 loops. - Add `RemainingAccounts` structure which takes out the burden of iteracting with `HashMap` directly. * chore: Remove unwanted file * feat: Use `LightHasher` macro * chore: Add name-service to pnpm-lock --------- Co-authored-by: Swen <swen.schaeferjohann@code.berlin>
1 parent 5dce514 commit 08b666a

File tree

18 files changed

+1252
-59
lines changed

18 files changed

+1252
-59
lines changed

.github/workflows/light-system-programs-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ jobs:
6868
sub-tests: '[
6969
"cargo test-sbf -p token-escrow -- --test-threads=1"
7070
]'
71-
71+
- program: name-service-test
72+
sub-tests: '[
73+
"cargo test-sbf -p name-service -- --test-threads=1"
74+
]'
7275

7376
steps:
7477
- name: Checkout sources

0 commit comments

Comments
 (0)