From ca52004ae696401821380a557af699af41c3d1fe Mon Sep 17 00:00:00 2001 From: austinabell Date: Wed, 26 Aug 2020 16:04:36 -0400 Subject: [PATCH 1/2] make message fields public and switch some usages --- vm/interpreter/src/default_runtime.rs | 21 ++++++------ vm/interpreter/src/vm.rs | 46 ++++++++++++++------------- vm/message/src/unsigned_message.rs | 20 ++++++------ 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/vm/interpreter/src/default_runtime.rs b/vm/interpreter/src/default_runtime.rs index 23f5b635e820..dced9736f635 100644 --- a/vm/interpreter/src/default_runtime.rs +++ b/vm/interpreter/src/default_runtime.rs @@ -238,15 +238,18 @@ where value: TokenAmount, params: Serialized, ) -> Result { - let msg = UnsignedMessage::builder() - .from(from) - .to(to) - .method_num(method) - .value(value) - .params(params) - .gas_limit(self.gas_available()) - .build() - .expect("Message creation fails"); + let msg = UnsignedMessage { + from, + to, + method_num: method, + value, + params, + gas_limit: self.gas_available(), + version: Default::default(), + sequence: Default::default(), + gas_fee_cap: Default::default(), + gas_premium: Default::default(), + }; // snapshot state tree let snapshot = self diff --git a/vm/interpreter/src/vm.rs b/vm/interpreter/src/vm.rs index 7dee91a31d32..b584b05ee929 100644 --- a/vm/interpreter/src/vm.rs +++ b/vm/interpreter/src/vm.rs @@ -139,17 +139,18 @@ where .get_actor(&*SYSTEM_ACTOR_ADDR)? .ok_or_else(|| "Failed to query system actor".to_string())?; - let rew_msg = UnsignedMessage::builder() - .from(*SYSTEM_ACTOR_ADDR) - .to(*REWARD_ACTOR_ADDR) - .sequence(sys_act.sequence) - .value(BigInt::zero()) - .gas_premium(BigInt::zero()) - .gas_fee_cap(BigInt::zero()) - .gas_limit(1 << 30) - .params(params) - .method_num(reward::Method::AwardBlockReward as u64) - .build()?; + let rew_msg = UnsignedMessage { + from: *SYSTEM_ACTOR_ADDR, + to: *REWARD_ACTOR_ADDR, + method_num: reward::Method::AwardBlockReward as u64, + params, + sequence: sys_act.sequence, + gas_limit: 1 << 30, + value: Default::default(), + version: Default::default(), + gas_fee_cap: Default::default(), + gas_premium: Default::default(), + }; // TODO revisit this ApplyRet structure, doesn't match go logic 1:1 and can be cleaner let ret = self.apply_implicit_message(&rew_msg); @@ -173,17 +174,18 @@ where .get_actor(&*SYSTEM_ACTOR_ADDR)? .ok_or_else(|| "Failed to query system actor".to_string())?; - let cron_msg = UnsignedMessage::builder() - .from(*SYSTEM_ACTOR_ADDR) - .to(*CRON_ACTOR_ADDR) - .sequence(sys_act.sequence) - .value(BigInt::zero()) - .gas_premium(BigInt::zero()) - .gas_fee_cap(BigInt::zero()) - .gas_limit(1 << 30) - .method_num(cron::Method::EpochTick as u64) - .params(Serialized::default()) - .build()?; + let cron_msg = UnsignedMessage { + from: *SYSTEM_ACTOR_ADDR, + to: *CRON_ACTOR_ADDR, + sequence: sys_act.sequence, + gas_limit: 1 << 30, + method_num: cron::Method::EpochTick as u64, + params: Default::default(), + value: Default::default(), + version: Default::default(), + gas_fee_cap: Default::default(), + gas_premium: Default::default(), + }; let ret = self.apply_implicit_message(&cron_msg); if let Some(err) = ret.act_error { diff --git a/vm/message/src/unsigned_message.rs b/vm/message/src/unsigned_message.rs index 66ff364ee109..a8efe5414756 100644 --- a/vm/message/src/unsigned_message.rs +++ b/vm/message/src/unsigned_message.rs @@ -42,23 +42,23 @@ use vm::{MethodNum, Serialized, TokenAmount}; #[builder(name = "MessageBuilder")] pub struct UnsignedMessage { #[builder(default)] - version: i64, - from: Address, - to: Address, + pub version: i64, + pub from: Address, + pub to: Address, #[builder(default)] - sequence: u64, + pub sequence: u64, #[builder(default)] - value: TokenAmount, + pub value: TokenAmount, #[builder(default)] - method_num: MethodNum, + pub method_num: MethodNum, #[builder(default)] - params: Serialized, + pub params: Serialized, #[builder(default)] - gas_limit: i64, + pub gas_limit: i64, #[builder(default)] - gas_fee_cap: TokenAmount, + pub gas_fee_cap: TokenAmount, #[builder(default)] - gas_premium: TokenAmount, + pub gas_premium: TokenAmount, } impl UnsignedMessage { From b0664631cbc8467aecc2106cbc46d3a4104de6ae Mon Sep 17 00:00:00 2001 From: austinabell Date: Thu, 27 Aug 2020 08:03:06 -0400 Subject: [PATCH 2/2] bump message patch version for release --- Cargo.lock | 2 +- vm/message/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 674f33ef0574..9619b1c88aaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2609,7 +2609,7 @@ dependencies = [ [[package]] name = "forest_message" -version = "0.4.0" +version = "0.4.1" dependencies = [ "base64 0.12.3", "derive_builder", diff --git a/vm/message/Cargo.toml b/vm/message/Cargo.toml index 3ef3ffb96793..4dfc8d70603d 100644 --- a/vm/message/Cargo.toml +++ b/vm/message/Cargo.toml @@ -2,7 +2,7 @@ name = "forest_message" description = "Filecoin message types" license = "MIT OR Apache-2.0" -version = "0.4.0" +version = "0.4.1" authors = ["ChainSafe Systems "] edition = "2018" repository = "https://github.com/ChainSafe/forest"