Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared sequencer integration for fuel-core 0.40.0 #2451

Merged
merged 8 commits into from
Nov 25, 2024

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Nov 23, 2024

Description

This PR duplicates #1922, but on top of the fuel-core 0.40.0.
Since the current master is not ready to be released, but we want this feature in the testnet, we will create a minor release with added off-chain logic that posts data to the SS.

All changes are the same as in the original PR, except reqwest is bumped to 0.12, because it has a fix important for SS.

Before requesting review

  • I have reviewed the code myself

@xgreenx xgreenx self-assigned this Nov 23, 2024
@xgreenx xgreenx requested a review from a team November 23, 2024 14:49
@xgreenx xgreenx mentioned this pull request Nov 23, 2024
bin/fuel-core/src/cli/run/shared_sequencer.rs Outdated Show resolved Hide resolved
crates/services/shared-sequencer/src/config.rs Outdated Show resolved Hide resolved
crates/services/shared-sequencer/src/lib.rs Outdated Show resolved Hide resolved
crates/services/shared-sequencer/src/lib.rs Show resolved Hide resolved

let block = self.tendermint()?.block(height).await?;

for item in block.block.data.iter().skip(1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we skip one ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dentosal Added it, so I don't know=) I will remove this function for now, since it is not used

crates/services/shared-sequencer/src/service.rs Outdated Show resolved Hide resolved
crates/services/shared-sequencer/src/service.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@AurelienFT AurelienFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comments :)


impl Client {
/// Create a new shared sequencer client from config.
pub async fn new(endpoints: Endpoints, topic: [u8; 32]) -> anyhow::Result<Self> {
Copy link
Member

@rymnc rymnc Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it should also accept the expected client_id so that we don't misconfigure with the wrong network/chain.

on L68 we can perform the check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the client_id? Do you mean chain_id? I want to keep the current implementation as simple, as possible.

Plus, if the RPC is malicious, it can lie about its chain_id

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, chain_id :)


let k256_public_key =
k256::PublicKey::from_public_key_der(cached_public_key_bytes)?;
Ok(Some(k256_public_key.into()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: why don't we just set the public key into the enum variant instead of its raw form? we won't have to recalculate it when verifying_key() is called every time.

as i understand the code, make_payload() is leading to this function being called repeatedly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more question to @Dentosal =) Performance is not critical in make_payload because we call this function twice each 12 seconds

Copy link
Member

@rymnc rymnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass :)

Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. I have a few suggestions and questions, but nothing blocking.

use std::sync::Arc;

/// Non-initialized shared sequencer task.
pub struct NonInitializedTask<S> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I suggest renaming this to UninitializedTask to maintain parity with #2442

Comment on lines +76 to +77
// Ceil the gas price to the next integer.
let gas_price = gas_price.saturating_add(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of incrementing the gas price here? The comment says we're ceiling it, but it's already parsed as a u128 so that's not correct. If we get a float number in minimum_gas_price.parse(), we'll get an error, not a floored value.

crates/services/shared-sequencer/src/service.rs Outdated Show resolved Hide resolved
Comment on lines +33 to +55
fn try_from(val: Args) -> anyhow::Result<fuel_core_shared_sequencer::Config> {
let endpoints = match (val.tendermint_api, val.blockchain_api) {
(Some(tendermint_api), Some(blockchain_api)) => {
Some(fuel_core_shared_sequencer::Endpoints {
tendermint_rpc_api: tendermint_api,
blockchain_rest_api: blockchain_api,
})
}
(None, None) => None,
_ => {
return Err(anyhow::anyhow!(
"Both tendermint and blockchain API must be set or unset"
))
}
};

Ok(fuel_core_shared_sequencer::Config {
enabled: val.enable,
block_posting_frequency: val.block_posting_frequency.into(),
endpoints,
topic: *val.topic,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should allow the case where enable is false and the tendermint_api and blockchain_api are unset. That seems to be the purpose of having them be optional afaiu, otherwise we could just make tendermint_api and blockchain_api be required arguments and skip this match statement.

@xgreenx xgreenx merged commit 68edae4 into release/v0.40.1 Nov 25, 2024
8 of 9 checks passed
@xgreenx xgreenx deleted the feature/shared-sequencer-integration branch November 25, 2024 16:58
xgreenx added a commit that referenced this pull request Nov 25, 2024
## Version v0.40.1

- [2450](#2450): Added support
for posting blocks to the shared sequencer.

## What's Changed

- Shared sequencer integration for `fuel-core 0.40.0` by @xgreenx in
#2451

**Full Changelog**:
v0.40.0...v0.40.1
@xgreenx xgreenx mentioned this pull request Nov 27, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants