Skip to content

Provide endpoint for querying L1 costs #110

@MujkicA

Description

@MujkicA

The following interface was discussed with the client team:

struct Bundle {
	sequence_number: u64,
	blocks_range: Range<BlockHeight>,
	// The DA block height of the last transaciton in the bundle.
	da_block_height: DaBlockHeight,
	// Cost of the bundle
	cost: u128,
	// Size of the bundle
	size: u64,
	// Total cost of all bundles for the whole history.
	total_cost: u256,
	// Total size of all bundles for the whole history.
	total_size: u256,
}

trait CommitterAPI {
	fn get_n_last_bundle(&self, number: u64) -> Result<Bundle>;
}

To support the proposed interface, the database schema will need to be updated to store the final costs and sizes associated with each bundle. It's important to note that we can only provide cost information for contiguous block ranges, which were selected to be a bundle by our gas_per_uncompressed_bytes minimization algorithm.

The number of blocks contained in a bundle is variable but can be bounded through a config parameter with a preference towards including more blocks to achieve better compression. Limited experimentation on the testnet has shown good results when targeting up to 3600 blocks per bundle.

The client team also requested retrieving bundles based on a range of block heights:

fn get_bundles_by_range(&self, range: Range<u64>) -> Result<Vec<Bundle>>;

This method allows querying for bundles that overlap with a specific block range. For example, if the existing bundles have the following inclusive ranges:
[10, 19] [20, 29] [30, 39] [40, 49]
And the requested range is [25, 35], the system will return all bundles that intersect with the requested range:
[20, 29], [30, 39]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions