Skip to content

Commit dbf6a10

Browse files
authored
Compilance fix 6 (#224)
* Compliance fix #6 * Fix order of deposit inc_nonce in transact
1 parent 11e36de commit dbf6a10

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
cargo run --release --verbose -p jsontests -- \
3939
jsontests/res/ethtests/GeneralStateTests/stCodeCopyTest/ \
4040
jsontests/res/ethtests/GeneralStateTests/stExample/ \
41+
jsontests/res/ethtests/GeneralStateTests/stSelfBalance \
4142
jsontests/res/ethtests/GeneralStateTests/stSLoadTest/ \
4243
jsontests/res/ethtests/GeneralStateTests/VMTests/vmArithmeticTest/ \
4344
jsontests/res/ethtests/GeneralStateTests/VMTests/vmBitwiseLogicOperation/ \

jsontests/src/run.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ pub fn run_test(_filename: &str, _test_name: &str, test: Test, debug: bool) -> R
8181
state,
8282
logs: Vec::new(),
8383
suicides: Vec::new(),
84-
hots: BTreeSet::new(),
84+
hots: {
85+
let mut hots = BTreeSet::new();
86+
for i in 1..10 {
87+
hots.insert((u256_to_h256(U256::from(i)).into(), None));
88+
}
89+
hots
90+
},
8591
}],
8692
};
8793
let mut step_backend = run_backend.clone();

src/backend/in_memory.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ impl RuntimeBackend for InMemoryBackend {
240240
}
241241

242242
fn deposit(&mut self, target: H160, value: U256) {
243+
if value == U256::zero() {
244+
return;
245+
}
246+
243247
self.current_layer_mut()
244248
.state
245249
.entry(target)

src/standard/invoker/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ where
132132
let gas_fee = args.gas_limit().saturating_mul(gas_price);
133133
handler.withdrawal(caller, gas_fee)?;
134134

135+
handler.inc_nonce(caller)?;
136+
135137
let address = match &args {
136138
TransactArgs::Call { address, .. } => *address,
137139
TransactArgs::Create {
@@ -230,8 +232,6 @@ where
230232
handler.mark_hot(address, None);
231233
}
232234

233-
handler.inc_nonce(caller)?;
234-
235235
Ok((invoke, machine))
236236
}
237237
TransactArgs::Create {
@@ -310,19 +310,19 @@ where
310310
let refunded_fee = refunded_gas.saturating_mul(invoke.gas_price);
311311
let coinbase_reward = invoke.gas_fee.saturating_sub(refunded_fee);
312312

313-
handler.deposit(invoke.caller, refunded_fee);
314-
handler.deposit(handler.block_coinbase(), coinbase_reward);
315-
316-
match result {
317-
Ok(exit) => {
313+
match &result {
314+
Ok(_) => {
318315
handler.pop_substate(MergeStrategy::Commit);
319-
Ok(exit)
320316
}
321-
Err(err) => {
317+
Err(_) => {
322318
handler.pop_substate(MergeStrategy::Discard);
323-
Err(err)
324319
}
325320
}
321+
322+
handler.deposit(invoke.caller, refunded_fee);
323+
handler.deposit(handler.block_coinbase(), coinbase_reward);
324+
325+
result
326326
}
327327

328328
fn enter_substack(

0 commit comments

Comments
 (0)