Skip to content

Commit

Permalink
Merge pull request #18 from HerodotusDev/adjustments-ids
Browse files Browse the repository at this point in the history
Custom MMR IDs
  • Loading branch information
fmkra authored Jul 19, 2024
2 parents 71c3fb4 + caf9834 commit e4d1665
Show file tree
Hide file tree
Showing 33 changed files with 793 additions and 782 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ target
.DS_Store

l1/broadcast/**

.snfoundry_cache
.snfoundry_trace
profile.pb.gz
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
scarb 0.7.0
scarb nightly-2024-04-20
starknet-foundry 0.23.0
54 changes: 47 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,58 @@ This repository contains and implements smart contracts deployed on Starknet.

This repository contains the following modules:

- Core - Implements the core logic behind Herodotus.
- Remappers - Implements a util allowing to map arbitrary timestamps to L1 block numbers.
- Turbo - Acts as a frontend to the Core contracts, provides great UX to developers and simplifies the integration.
- L1 - Smart contracts deployed on Ethereum L1 responsible for synchronizing with L1.
- Core - Implements the core logic behind Herodotus.
- Remappers - Implements a util allowing to map arbitrary timestamps to L1 block numbers.
- Turbo - Acts as a frontend to the Core contracts, provides great UX to developers and simplifies the integration.
- L1 - Smart contracts deployed on Ethereum L1 responsible for synchronizing with L1.

# Core

This module is responsible for:

- Processing new block headers and growing the MMR.
- Receiving and handling L1 messages containing blockhashes and Poseidon roots of the MMR which generation has been SHARP proven.
- Verifying state proofs and saving the proven values in the `FactsRegistry`
- Processing new block headers and growing the MMR.
- Receiving and handling L1 messages containing blockhashes and Poseidon roots of the MMR which generation has been SHARP proven.
- Verifying state proofs and saving the proven values in the `FactsRegistry`

## Error codes

### Headers Store

- `ONLY_COMMITMENTS_INBOX` - Only commitments inbox (address saved in `commitments_inbox` variable) can send messages to this function.

- `SRC_MMR_NOT_FOUND` - Source MMR (one from which the branch is created) with provided MMR ID does not exist in the store.

- `SRC_MMR_ID_0_NOT_ALLOWED` - Source MMR (one from which the branch is created) with ID 0 is not allowed.

- `NEW_MMR_ID_0_NOT_ALLOWED` - New MMR (one that is created from source branch) with ID 0 is not allowed.

- `ROOT_0_NOT_ALLOWED` - Creating MMR with root 0 is not allowed.

- `NEW_MMR_ALREADY_EXISTS` - New MMR (one that is created from source branch) with provided ID already exists in the store.

- `MMR_NOT_FOUND` - MMR with provided ID does not exist in the store.

- `PROOF_AND_REF_BLOCK_NOT_ALLOWED` - `process_batch` can't be called with both proof and reference block. Please select either one.

- `INVALID_HEADER_RLP` - Provided header RLP is invalid.

- `INVALID_MMR_PROOF` - Provided MMR proof (`proof` or `peaks` or both) is invalid.

- `INVALID_START_BLOCK` - Cannot read block number from the first header RLP.

- `BLOCK_NOT_RECEIVED` - Block which was referenced in `process_batch` was not written to the store with `receive_hash` function.

- `INVALID_INITIAL_HEADER_RLP` - First header RLP didn't match the reference block.

- `MMR_APPEND_FAILED` - Append to MMR function failed, most likely due to invalid peaks.

- `INVALID_PARENT_HASH_RLP` - Could not read parent hash from the provided header RLP.

### Commitments Inbox

- `ONLY_OWNER` - Only owner can call this function.

- `ONLY_L1_MESSAGE_SENDER` - Only L1 message sender can call this function.

# Timestamps to block numbers mapper

Expand Down
20 changes: 20 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "cairo_lib"
version = "0.2.0"
source = "git+https://github.com/HerodotusDev/cairo-lib.git?branch=update-cairo#0db686d55a4f52835c2127539953178bd01e19f3"

[[package]]
name = "herodotus_eth_starknet"
version = "0.1.0"
dependencies = [
"cairo_lib",
"snforge_std",
]

[[package]]
name = "snforge_std"
version = "0.23.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.23.0#f2bff8f796763ada77fe6033ec1b034ceee22abd"
8 changes: 4 additions & 4 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ casm = true
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest

[dependencies]
starknet = "2.2.0"
cairo_lib = { git = "https://github.com/HerodotusDev/cairo-lib.git" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.4.1" }
starknet = "2.6.3"
cairo_lib = { git = "https://github.com/HerodotusDev/cairo-lib.git", branch = "update-cairo" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.23.0" }

[tool.snforge]
exit_first = true
Expand All @@ -21,4 +21,4 @@ exit_first = true
[tool.sncast]
account = "herodotus"
network = "testnet"
url = "https://starknet-testnet.public.blastapi.io"
url = "https://starknet-sepolia.public.blastapi.io"
6 changes: 0 additions & 6 deletions l1/.env.example

This file was deleted.

34 changes: 0 additions & 34 deletions l1/.github/workflows/test.yml

This file was deleted.

16 changes: 0 additions & 16 deletions l1/.gitignore

This file was deleted.

57 changes: 0 additions & 57 deletions l1/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions l1/foundry.toml

This file was deleted.

1 change: 0 additions & 1 deletion l1/lib/forge-std
Submodule forge-std deleted from 74cfb7
1 change: 0 additions & 1 deletion l1/lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from fd81a9
5 changes: 0 additions & 5 deletions l1/remappings.txt

This file was deleted.

25 changes: 0 additions & 25 deletions l1/script/L1MessagesSender.s.sol

This file was deleted.

Loading

0 comments on commit e4d1665

Please sign in to comment.