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

Expose message fields #655

Merged
merged 3 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions vm/interpreter/src/default_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,18 @@ where
value: TokenAmount,
params: Serialized,
) -> Result<Serialized, ActorError> {
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(),
RajarupanSampanthan marked this conversation as resolved.
Show resolved Hide resolved
};

// snapshot state tree
let snapshot = self
Expand Down
46 changes: 24 additions & 22 deletions vm/interpreter/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions vm/message/src/unsigned_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down