Skip to content

Commit

Permalink
feat(gprimitives): serialize actor id as hex (#4446)
Browse files Browse the repository at this point in the history
  • Loading branch information
osipov-mit authored Jan 18, 2025
1 parent db08ac1 commit 20859f2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ethexe/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository.workspace = true
tokio = { workspace = true }
anyhow.workspace = true
futures.workspace = true
gprimitives = { workspace = true, features = ["serde"] }
gprimitives = { workspace = true, features = ["serde", "ethexe"] }
ethexe-db.workspace = true
ethexe-processor.workspace = true
tower = { workspace = true, features = ["util"] }
Expand Down
4 changes: 2 additions & 2 deletions ethexe/runtime/common/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ pub struct ActiveProgram {
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum Program {
Active(ActiveProgram),
Exited(ProgramId),
Terminated(ProgramId),
Exited(ActorId),
Terminated(ActorId),
}

impl Program {
Expand Down
1 change: 1 addition & 0 deletions gprimitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ gear-ss58.workspace = true
[features]
codec = ["parity-scale-codec", "scale-info"]
serde = ["dep:serde", "primitive-types/serde_no_std"]
ethexe = []
13 changes: 12 additions & 1 deletion gprimitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl FromStr for ActorId {
}
}

#[cfg(feature = "serde")]
#[cfg(all(feature = "serde", not(feature = "ethexe")))]
impl Serialize for ActorId {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -239,6 +239,17 @@ impl Serialize for ActorId {
}
}

#[cfg(all(feature = "serde", feature = "ethexe"))]
impl Serialize for ActorId {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let id: H160 = self.to_address_lossy();
id.serialize(serializer)
}
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for ActorId {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
Expand Down
4 changes: 2 additions & 2 deletions pallets/gear-builtin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ impl<T: Config> BuiltinDispatcher for BuiltinRegistry<T> {
}
Err(BuiltinActorError::GasAllowanceExceeded) => {
// Ideally, this should never happen, as we should have checked the gas allowance
// before even entring the `handle` method. However, if this error does occur,
// we should handle it by discarding the gas burned and requeueing the message.
// before even entering the `handle` method. However, if this error does occur,
// we should handle it by discarding the gas burned and requeuing the message.
// N.B.: if `gas_amount.burned` is not zero, the cost is borne by the validator.
process_allowance_exceed(dispatch, actor_id, 0)
}
Expand Down

0 comments on commit 20859f2

Please sign in to comment.