Skip to content

Commit

Permalink
consider beneficiary when cleaning touched accounts (EIP161) (#360)
Browse files Browse the repository at this point in the history
* consider beneficiary when cleaning touched account (EIP161)

* fix create contract test
  • Loading branch information
ayrat555 authored Aug 17, 2018
1 parent 5e38810 commit 0fa6c53
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Ethereum common tests are created for all clients to test against. We plan to pr
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 1089/1114 = 97.8% passing
- [x] EIP158
- [BlockchainTests](https://github.com/ethereum/tests/tree/develop/BlockchainTests) (Includes GeneralStateTests) 1219/1233 = 98.9% passing
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 1157/1181= 98.0% passing
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 1164/1181= 98.6% passing
- [ ] Byzantium
- [ ] Constantinople: View the community [Constantinople Project Tracker](https://github.com/ethereum/pm/issues/53).
Expand Down
4 changes: 3 additions & 1 deletion apps/blockchain/lib/blockchain/contract/create_contract.ex
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ defmodule Blockchain.Contract.CreateContract do
Account.put_code(state_after_init, address, output)
end

{:ok, {resultant_state, resultant_gas, accrued_sub_state}}
sub_state = SubState.add_touched_account(accrued_sub_state, address)

{:ok, {resultant_state, resultant_gas, sub_state}}
end
end

Expand Down
5 changes: 3 additions & 2 deletions apps/blockchain/lib/blockchain/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Blockchain.Transaction do
alias Blockchain.{Account, Contract, Transaction, MathHelper}
alias Blockchain.Transaction.Validity
alias Block.Header
alias EVM.{Gas, Configuration}
alias EVM.{Gas, Configuration, SubState}

# nonce: T_n
# gas_price: T_p
Expand Down Expand Up @@ -256,8 +256,9 @@ defmodule Blockchain.Transaction do
# Note, we only want to take the first 3 items from the tuples,
# as designated Θ_3 in the literature Θ_3
{state, remaining_gas_, sub_state_, _output} = Contract.message_call(params)
sub_state = SubState.add_touched_account(sub_state_, block_header.beneficiary)

{state, remaining_gas_, sub_state_}
{state, remaining_gas_, sub_state}
end
end

Expand Down
6 changes: 0 additions & 6 deletions apps/blockchain/test/blockchain/state_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ defmodule Blockchain.StateTest do
"stZeroCallsTest/ZeroValue_TransactionCALL_ToOneStorageKey",
"stZeroCallsTest/ZeroValue_TransactionCALL_ToEmpty",
"stZeroCallsTest/ZeroValue_TransactionCALL",
"stTransactionTest/UserTransactionZeroCostWithData",
"stTransactionTest/UserTransactionZeroCost",
"stTransactionTest/TransactionDataCosts652",
"stTransactionTest/SuicidesMixingCoinbase",
"stTransactionTest/OverflowGasRequire2",
"stTransactionTest/EmptyTransaction2",
"stSystemOperationsTest/suicideCoinbase",
"stSystemOperationsTest/doubleSelfdestructTest2",
"stSystemOperationsTest/doubleSelfdestructTest",
"stSpecialTest/failed_tx_xcf416c53",
"stRevertTest/RevertPrefound",
"stRevertTest/RevertOpcodeMultipleSubCalls",
Expand Down
2 changes: 1 addition & 1 deletion apps/evm/lib/evm/sub_state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule EVM.SubState do
@doc """
Checks whether the given `sub_state` is empty.
"""
def empty?(sub_state), do: sub_state == empty()
def empty?(sub_state), do: %{sub_state | touched_accounts: []} == empty()

@doc """
Adds log entry to substate's log entry list.
Expand Down

0 comments on commit 0fa6c53

Please sign in to comment.