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

Compilance fix 6 #224

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
cargo run --release --verbose -p jsontests -- \
jsontests/res/ethtests/GeneralStateTests/stCodeCopyTest/ \
jsontests/res/ethtests/GeneralStateTests/stExample/ \
jsontests/res/ethtests/GeneralStateTests/stSelfBalance \
jsontests/res/ethtests/GeneralStateTests/stSLoadTest/ \
jsontests/res/ethtests/GeneralStateTests/VMTests/vmArithmeticTest/ \
jsontests/res/ethtests/GeneralStateTests/VMTests/vmBitwiseLogicOperation/ \
Expand Down
8 changes: 7 additions & 1 deletion jsontests/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ pub fn run_test(_filename: &str, _test_name: &str, test: Test, debug: bool) -> R
state,
logs: Vec::new(),
suicides: Vec::new(),
hots: BTreeSet::new(),
hots: {
let mut hots = BTreeSet::new();
for i in 1..10 {
hots.insert((u256_to_h256(U256::from(i)).into(), None));
}
hots
},
}],
};
let mut step_backend = run_backend.clone();
Expand Down
4 changes: 4 additions & 0 deletions src/backend/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ impl RuntimeBackend for InMemoryBackend {
}

fn deposit(&mut self, target: H160, value: U256) {
if value == U256::zero() {
return;
}

self.current_layer_mut()
.state
.entry(target)
Expand Down
20 changes: 10 additions & 10 deletions src/standard/invoker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ where
let gas_fee = args.gas_limit().saturating_mul(gas_price);
handler.withdrawal(caller, gas_fee)?;

handler.inc_nonce(caller)?;

let address = match &args {
TransactArgs::Call { address, .. } => *address,
TransactArgs::Create {
Expand Down Expand Up @@ -230,8 +232,6 @@ where
handler.mark_hot(address, None);
}

handler.inc_nonce(caller)?;

Ok((invoke, machine))
}
TransactArgs::Create {
Expand Down Expand Up @@ -310,19 +310,19 @@ where
let refunded_fee = refunded_gas.saturating_mul(invoke.gas_price);
let coinbase_reward = invoke.gas_fee.saturating_sub(refunded_fee);

handler.deposit(invoke.caller, refunded_fee);
handler.deposit(handler.block_coinbase(), coinbase_reward);

match result {
Ok(exit) => {
match &result {
Ok(_) => {
handler.pop_substate(MergeStrategy::Commit);
Ok(exit)
}
Err(err) => {
Err(_) => {
handler.pop_substate(MergeStrategy::Discard);
Err(err)
}
}

handler.deposit(invoke.caller, refunded_fee);
handler.deposit(handler.block_coinbase(), coinbase_reward);

result
}

fn enter_substack(
Expand Down
Loading