Skip to content

Commit

Permalink
Remove unnecessary ledger rpcs (#904)
Browse files Browse the repository at this point in the history
* Remove unnecessary rpcs about batches and slots

* Remove unnecessary transaction ledger rpcs

* Remove unnecessary ledger event rpcs

* Lint and remove unnecessary functions

* Fix udeps

* Remove more unnecessary responses

* Fix parse issue

* Fix test parsing

* Rename soft batches to soft confirmations part1

* Rename soft batches to soft confirmations part2

* Rename soft batches to soft confirmations part3

* Rename soft batches to soft confirmations part4 comments

* Rename soft batches to soft confirmations part5 error messages

* Rename soft batches to soft confirmations par6 more comments

* fmt

* Fix naming in commit soft confirmation

* Remove commit slot

* Remove unnecessary batch by hash table

* Fix merge errors

* Add empty ledger tests with our rpcs

* Lints

* Remove unused dev dep
  • Loading branch information
ercecan authored Aug 12, 2024
1 parent 39a901d commit 22b54c9
Show file tree
Hide file tree
Showing 41 changed files with 685 additions and 2,364 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 21 additions & 18 deletions bin/citrea/src/rollup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {

let genesis_root = prover_storage.get_root_hash(1);

let prev_data = match ledger_db.get_head_soft_batch()? {
Some((number, soft_batch)) => {
Some((prover_storage.get_root_hash(number.0 + 1)?, soft_batch.hash))
}
let prev_data = match ledger_db.get_head_soft_confirmation()? {
Some((number, soft_confirmation)) => Some((
prover_storage.get_root_hash(number.0 + 1)?,
soft_confirmation.hash,
)),
None => None,
};
let init_variant = match prev_data {
Expand All @@ -86,8 +87,8 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
};

let current_l2_height = ledger_db
.get_head_soft_batch()
.map_err(|e| anyhow!("Failed to get head soft batch: {}", e))?
.get_head_soft_confirmation()
.map_err(|e| anyhow!("Failed to get head soft confirmation: {}", e))?
.map(|(l2_height, _)| l2_height)
.unwrap_or(BatchNumber(0));

Expand Down Expand Up @@ -164,10 +165,11 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {

let genesis_root = prover_storage.get_root_hash(1);

let prev_data = match ledger_db.get_head_soft_batch()? {
Some((number, soft_batch)) => {
Some((prover_storage.get_root_hash(number.0 + 1)?, soft_batch.hash))
}
let prev_data = match ledger_db.get_head_soft_confirmation()? {
Some((number, soft_confirmation)) => Some((
prover_storage.get_root_hash(number.0 + 1)?,
soft_confirmation.hash,
)),
None => None,
};
let init_variant = match prev_data {
Expand All @@ -181,8 +183,8 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
let code_commitment = self.get_code_commitment();

let current_l2_height = ledger_db
.get_head_soft_batch()
.map_err(|e| anyhow!("Failed to get head soft batch: {}", e))?
.get_head_soft_confirmation()
.map_err(|e| anyhow!("Failed to get head soft confirmation: {}", e))?
.map(|(l2_height, _)| l2_height)
.unwrap_or(BatchNumber(0));

Expand Down Expand Up @@ -263,10 +265,11 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {

let genesis_root = prover_storage.get_root_hash(1);

let prev_data = match ledger_db.get_head_soft_batch()? {
Some((number, soft_batch)) => {
Some((prover_storage.get_root_hash(number.0 + 1)?, soft_batch.hash))
}
let prev_data = match ledger_db.get_head_soft_confirmation()? {
Some((number, soft_confirmation)) => Some((
prover_storage.get_root_hash(number.0 + 1)?,
soft_confirmation.hash,
)),
None => None,
};
let init_variant = match prev_data {
Expand All @@ -280,8 +283,8 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
let code_commitment = self.get_code_commitment();

let current_l2_height = ledger_db
.get_head_soft_batch()
.map_err(|e| anyhow!("Failed to get head soft batch: {}", e))?
.get_head_soft_confirmation()
.map_err(|e| anyhow!("Failed to get head soft confirmation: {}", e))?
.map(|(l2_height, _)| l2_height)
.unwrap_or(BatchNumber(0));

Expand Down
Loading

0 comments on commit 22b54c9

Please sign in to comment.