Skip to content

Commit 416d3e8

Browse files
bors[bot]damip
andauthored
Merge #2137
2137: repair SCE ledger updates r=damip a=damip Co-authored-by: Damir Vodenicarevic <damipator@gmail.com>
2 parents 932e06c + 0051177 commit 416d3e8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

massa-execution/src/interface_impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ impl Interface for InterfaceImpl {
100100
}
101101
let address = Address(massa_hash::hash::Hash::compute_from(&data));
102102
let res = address.to_bs58_check();
103-
context.ledger_step.set_module(address, module.clone());
103+
context
104+
.ledger_step
105+
.set_module(address, Some(module.clone()));
104106
context.owned_addresses.insert(address);
105107
context.created_addr_index += 1;
106108
Ok(res)

massa-execution/src/sce_ledger.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ impl SCELedgerEntry {
3232
}
3333

3434
// module
35-
self.opt_module = update.update_opt_module.clone();
35+
if let Some(opt_module) = &update.update_opt_module {
36+
self.opt_module = opt_module.clone();
37+
}
3638

3739
// data
3840
for (data_key, data_update) in update.update_data.iter() {
@@ -198,7 +200,7 @@ impl DeserializeCompact for SCELedgerEntry {
198200
#[derive(Debug, Clone, Default)]
199201
pub struct SCELedgerEntryUpdate {
200202
pub update_balance: Option<Amount>,
201-
pub update_opt_module: Option<Bytecode>,
203+
pub update_opt_module: Option<Option<Bytecode>>,
202204
pub update_data: HHashMap<Hash, Option<Vec<u8>>>, // None for row deletion
203205
}
204206

@@ -503,7 +505,11 @@ impl SCELedgerStep {
503505
match changes.0.get(addr) {
504506
Some(SCELedgerChange::Delete) => return None,
505507
Some(SCELedgerChange::Set(new_entry)) => return new_entry.opt_module.clone(),
506-
Some(SCELedgerChange::Update(update)) => return update.update_opt_module.clone(),
508+
Some(SCELedgerChange::Update(update)) => {
509+
if let Some(updates_opt_module) = &update.update_opt_module {
510+
return updates_opt_module.clone();
511+
}
512+
}
507513
None => {}
508514
}
509515
}
@@ -550,9 +556,9 @@ impl SCELedgerStep {
550556
.apply_change(addr, &SCELedgerChange::Update(update));
551557
}
552558

553-
pub fn set_module(&mut self, addr: Address, module: Vec<u8>) {
559+
pub fn set_module(&mut self, addr: Address, opt_module: Option<Vec<u8>>) {
554560
let update = SCELedgerEntryUpdate {
555-
update_opt_module: Some(module),
561+
update_opt_module: Some(opt_module),
556562
..Default::default()
557563
};
558564
self.caused_changes

0 commit comments

Comments
 (0)