Skip to content

Commit

Permalink
Update derive_more and change derivative to educe
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT committed Feb 3, 2025
1 parent 1e852a3 commit 75aac1d
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 112 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ async-trait = "0.1"
aws-sdk-kms = "1.37"
cynic = { version = "3.1.0", features = ["http-reqwest"] }
clap = "4.4"
derivative = { version = "2" }
derive_more = { version = "0.99" }
educe = { version = "0.6", features = ["Eq", "PartialEq", "Hash", "Debug"] }
derive_more = { version = "1", features = ["into", "from", "display"]}
enum-iterator = "1.2"
hex = { version = "0.4", features = ["serde"] }
hyper = { version = "0.14.26" }
Expand Down
2 changes: 1 addition & 1 deletion crates/chain-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description = "Fuel Chain config types"
[dependencies]
anyhow = { workspace = true }
bech32 = { version = "0.9.0", default-features = false, optional = true }
derivative = { workspace = true }
educe = { workspace = true }
fuel-core-storage = { workspace = true, features = ["alloc"] }
fuel-core-types = { workspace = true, default-features = false, features = [
"alloc",
Expand Down
7 changes: 4 additions & 3 deletions crates/chain-config/src/config/chain.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use educe::Educe;
use fuel_core_storage::MerkleRoot;
use fuel_core_types::{
blockchain::header::StateTransitionBytecodeVersion,
Expand Down Expand Up @@ -28,8 +29,8 @@ use crate::SnapshotMetadata;
pub const LOCAL_TESTNET: &str = "local_testnet";
pub const BYTECODE_NAME: &str = "state_transition_bytecode.wasm";

#[derive(Clone, derivative::Derivative, Deserialize, Serialize, Eq, PartialEq)]
#[derivative(Debug)]
#[derive(Clone, Educe, Deserialize, Serialize, Eq, PartialEq)]
#[educe(Debug)]
pub struct ChainConfig {
pub chain_name: String,
pub consensus_parameters: ConsensusParameters,
Expand All @@ -39,7 +40,7 @@ pub struct ChainConfig {
/// Note: The state transition bytecode is stored in a separate file
/// under the `BYTECODE_NAME` name in serialization form.
#[serde(skip)]
#[derivative(Debug(format_with = "fmt_truncated_hex::<16>"))]
#[educe(Debug(method(fmt_truncated_hex::<16>)))]
pub state_transition_bytecode: Vec<u8>,
pub consensus: ConsensusConfig,
}
Expand Down
26 changes: 12 additions & 14 deletions crates/database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,28 @@ use fuel_core_types::services::executor::Error as ExecutorError;
#[allow(missing_docs)]
pub enum Error {
/// Error occurred during serialization or deserialization of the entity.
#[display(fmt = "error performing serialization or deserialization")]
#[display("error performing serialization or deserialization")]
Codec,
/// The version of database or data is invalid (possibly not migrated).
#[display(
fmt = "Invalid database version, expected {expected:#x}, found {found:#x}"
)]
#[display("Invalid database version, expected {expected:#x}, found {found:#x}")]
InvalidDatabaseVersion {
/// the current database version
found: u32,
/// the database version expected by this build of fuel-core
expected: u32,
},
/// Multiple heights found in the commit to the database.
#[display(fmt = "Multiple heights found in the commit {heights:?}")]
#[display("Multiple heights found in the commit {heights:?}")]
MultipleHeightsInCommit {
/// List of heights found in the commit.
heights: Vec<u64>,
},
/// Failed to advance the height.
#[display(fmt = "Failed to advance the height")]
#[display("Failed to advance the height")]
FailedToAdvanceHeight,
/// The new and old heights are not linked.
#[display(
fmt = "New and old heights are not linked: prev_height: {prev_height:#x}, new_height: {new_height:#x}"
"New and old heights are not linked: prev_height: {prev_height:#x}, new_height: {new_height:#x}"
)]
HeightsAreNotLinked {
/// The old height.
Expand All @@ -53,35 +51,35 @@ pub enum Error {
},
/// The new height is not found, but the old height is set.
#[display(
fmt = "The new height is not found, but the old height is set: prev_height: {prev_height:#x}"
"The new height is not found, but the old height is set: prev_height: {prev_height:#x}"
)]
NewHeightIsNotSet {
/// The old height known by the database.
prev_height: u64,
},
#[display(fmt = "The historical database doesn't have any history yet")]
#[display("The historical database doesn't have any history yet")]
NoHistoryIsAvailable,
#[display(
fmt = "The historical database doesn't have history for the requested height {requested_height:#x}, \
"The historical database doesn't have history for the requested height {requested_height:#x}, \
the oldest available height is {oldest_available_height:#x}"
)]
NoHistoryForRequestedHeight {
requested_height: u64,
oldest_available_height: u64,
},
#[display(fmt = "Reached the end of the history")]
#[display("Reached the end of the history")]
ReachedEndOfHistory,

#[cfg(feature = "backup")]
#[display(fmt = "BackupEngine initialization error: {}", _0)]
#[display("BackupEngine initialization error: {}", _0)]
BackupEngineInitError(anyhow::Error),

#[cfg(feature = "backup")]
#[display(fmt = "Backup error: {}", _0)]
#[display("Backup error: {}", _0)]
BackupError(anyhow::Error),

#[cfg(feature = "backup")]
#[display(fmt = "Restore error: {}", _0)]
#[display("Restore error: {}", _0)]
RestoreError(anyhow::Error),

/// Not related to database error.
Expand Down
28 changes: 14 additions & 14 deletions crates/services/importer/src/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,34 @@ pub mod test;

#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
#[display(fmt = "The commit is already in the progress: {_0}.")]
#[display("The commit is already in the progress: {_0}.")]
SemaphoreError(TryAcquireError),
#[display("The wrong state of database during insertion of the genesis block.")]
InvalidUnderlyingDatabaseGenesisState,
#[display(
fmt = "The wrong state of database during insertion of the genesis block."
"The wrong state of storage after execution of the block.\
The actual root is {_1:?}, when the expected root is {_0:?}."
)]
InvalidUnderlyingDatabaseGenesisState,
#[display(fmt = "The wrong state of storage after execution of the block.\
The actual root is {_1:?}, when the expected root is {_0:?}.")]
InvalidDatabaseStateAfterExecution(Option<MerkleRoot>, Option<MerkleRoot>),
#[display(fmt = "Got overflow during increasing the height.")]
#[display("Got overflow during increasing the height.")]
Overflow,
#[display(fmt = "The non-generic block can't have zero height.")]
#[display("The non-generic block can't have zero height.")]
ZeroNonGenericHeight,
#[display(fmt = "The actual height is {_1}, when the next expected height is {_0}.")]
#[display("The actual height is {_1}, when the next expected height is {_0}.")]
IncorrectBlockHeight(BlockHeight, BlockHeight),
#[display(
fmt = "Got another block id after validation of the block. Expected {_0} != Actual {_1}"
"Got another block id after validation of the block. Expected {_0} != Actual {_1}"
)]
BlockIdMismatch(BlockId, BlockId),
#[display(fmt = "Some of the block fields are not valid: {_0}.")]
#[display("Some of the block fields are not valid: {_0}.")]
FailedVerification(anyhow::Error),
#[display(fmt = "The execution of the block failed: {_0}.")]
#[display("The execution of the block failed: {_0}.")]
FailedExecution(executor::Error),
#[display(fmt = "It is not possible to execute the genesis block.")]
#[display("It is not possible to execute the genesis block.")]
ExecuteGenesis,
#[display(fmt = "The database already contains the data at the height {_0}.")]
#[display("The database already contains the data at the height {_0}.")]
NotUnique(BlockHeight),
#[display(fmt = "The previous block processing is not finished yet.")]
#[display("The previous block processing is not finished yet.")]
PreviousBlockProcessingNotFinished,
#[from]
StorageError(StorageError),
Expand Down
8 changes: 4 additions & 4 deletions crates/services/producer/src/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ pub mod gas_price;

#[derive(Debug, derive_more::Display)]
pub enum Error {
#[display(fmt = "Genesis block is absent")]
#[display("Genesis block is absent")]
NoGenesisBlock,
#[display(
fmt = "The block height {height} should be higher than the previous block height {previous_block}"
"The block height {height} should be higher than the previous block height {previous_block}"
)]
BlockHeightShouldBeHigherThanPrevious {
height: BlockHeight,
previous_block: BlockHeight,
},
#[display(fmt = "Previous block height {_0} doesn't exist")]
#[display("Previous block height {_0} doesn't exist")]
MissingBlock(BlockHeight),
#[display(
fmt = "Best finalized da_height {best} is behind previous block da_height {previous_block}"
"Best finalized da_height {best} is behind previous block da_height {previous_block}"
)]
InvalidDaFinalizationState {
best: DaBlockHeight,
Expand Down
Loading

0 comments on commit 75aac1d

Please sign in to comment.