use new contract in unit tests that has self-destruct ability, so we can test eip-158 since simply moving an account to new path doesn't count as 'touchin' it
This commit is contained in:
parent
face00ca01
commit
9b6e486799
@ -33,39 +33,42 @@ import (
|
||||
|
||||
// TODO: add test that filters on address
|
||||
var (
|
||||
contractLeafKey, emptyContractLeafKey, contract2LeafKey []byte
|
||||
emptyDiffs = make([]statediff.StateNode, 0)
|
||||
emptyStorage = make([]statediff.StorageNode, 0)
|
||||
block0, block1, block2, block3 *types.Block
|
||||
builder statediff.Builder
|
||||
miningReward = int64(2000000000000000000)
|
||||
minerAddress = common.HexToAddress("0x0")
|
||||
minerLeafKey = testhelpers.AddressToLeafKey(minerAddress)
|
||||
contractLeafKey []byte
|
||||
emptyDiffs = make([]statediff.StateNode, 0)
|
||||
emptyStorage = make([]statediff.StorageNode, 0)
|
||||
block0, block1, block2, block3 *types.Block
|
||||
builder statediff.Builder
|
||||
miningReward = int64(2000000000000000000)
|
||||
minerAddress = common.HexToAddress("0x0")
|
||||
minerLeafKey = testhelpers.AddressToLeafKey(minerAddress)
|
||||
|
||||
balanceChange10000 = int64(10000)
|
||||
balanceChange1000 = int64(1000)
|
||||
block1BankBalance = int64(99990000)
|
||||
block1Account1Balance = int64(10000)
|
||||
block2Account2Balance = int64(1000)
|
||||
contractContractRoot = "0x821e2556a290c86405f8160a2d662042a431ba456b9db265c79bb837c04be5f0"
|
||||
newContractRoot = "0x71e0d14b2b93e5c7f9748e69e1fe5f17498a1c3ac3cec29f96af13d7f8a4e070"
|
||||
originalStorageLocation = common.HexToHash("0")
|
||||
originalStorageKey = crypto.Keccak256Hash(originalStorageLocation[:])
|
||||
newStorageLocation = common.HexToHash("2")
|
||||
newStorageKey = crypto.Keccak256Hash(newStorageLocation[:])
|
||||
originalStorageValue = common.Hex2Bytes("01")
|
||||
originalStorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("20290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"),
|
||||
originalStorageValue,
|
||||
balanceChange10000 = int64(10000)
|
||||
balanceChange1000 = int64(1000)
|
||||
block1BankBalance = int64(99990000)
|
||||
block1Account1Balance = int64(10000)
|
||||
block2Account2Balance = int64(1000)
|
||||
contractContractRoot = "0x34fbee27a0db0e761bd121ba12d25fcc7bb12ff3fda9a0330e9dcdc91f676aa2"
|
||||
newContractRoot = "0x89fb2012ce3e90bc3ba52a6831ff4722b93f6ea45d0d1311ce4432bd4abd2268"
|
||||
ownerAddrStorageLocation = common.HexToHash("0")
|
||||
ownerAddrStorageKey = crypto.Keccak256Hash(ownerAddrStorageLocation[:])
|
||||
originalStorageDataLocation = common.HexToHash("1")
|
||||
originalDataStorageKey = crypto.Keccak256Hash(originalStorageDataLocation[:])
|
||||
newDataStorageLocation = common.HexToHash("3")
|
||||
newStorageKey = crypto.Keccak256Hash(newDataStorageLocation[:])
|
||||
ownerAddrStorageValue = common.Hex2Bytes("94703c4b2bd70c169f5717101caee543299fc946c7") // prefixed AccountAddr1
|
||||
originalDataStorageValue = common.Hex2Bytes("01")
|
||||
originalDataStorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("310e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"),
|
||||
originalDataStorageValue,
|
||||
})
|
||||
updatedStorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
ownerAddrStorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("390decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"),
|
||||
originalStorageValue,
|
||||
ownerAddrStorageValue,
|
||||
})
|
||||
newStorageValue = common.Hex2Bytes("03")
|
||||
newStorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("305787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace"),
|
||||
newStorageValue,
|
||||
newDataStorageValue = common.Hex2Bytes("03")
|
||||
newDataStorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("32575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b"),
|
||||
newDataStorageValue,
|
||||
})
|
||||
bankAccountAtBlock0, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce0,
|
||||
@ -77,16 +80,6 @@ var (
|
||||
common.Hex2Bytes("2000bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
|
||||
bankAccountAtBlock0,
|
||||
})
|
||||
emptyContractAtBlock1, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce0,
|
||||
Balance: big.NewInt(0),
|
||||
CodeHash: testhelpers.NullCodeHash.Bytes(),
|
||||
Root: testhelpers.EmptyContractRoot,
|
||||
})
|
||||
emptyContractAtBlock1LeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
common.Hex2Bytes("38f0847834712d0d4a56cc9fd09ca7a91cd58d022e0f3790ef365ae82a471419"),
|
||||
emptyContractAtBlock1,
|
||||
})
|
||||
account1AtBlock1, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce0,
|
||||
Balance: big.NewInt(balanceChange10000),
|
||||
@ -108,7 +101,7 @@ var (
|
||||
minerAccountAtBlock1,
|
||||
})
|
||||
bankAccountAtBlock1, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce2,
|
||||
Nonce: testhelpers.Nonce1,
|
||||
Balance: big.NewInt(testhelpers.TestBankFunds.Int64() - balanceChange10000),
|
||||
CodeHash: testhelpers.NullCodeHash.Bytes(),
|
||||
Root: testhelpers.EmptyContractRoot,
|
||||
@ -130,7 +123,7 @@ var (
|
||||
contractAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce1,
|
||||
Balance: big.NewInt(0),
|
||||
CodeHash: common.HexToHash("0x753f98a8d4328b15636e46f66f2cb4bc860100aa17967cc145fcd17d1d4710ea").Bytes(),
|
||||
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
|
||||
Root: common.HexToHash(contractContractRoot),
|
||||
})
|
||||
contractAccountAtBlock2LeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
@ -138,7 +131,7 @@ var (
|
||||
contractAccountAtBlock2,
|
||||
})
|
||||
bankAccountAtBlock2, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce3,
|
||||
Nonce: testhelpers.Nonce2,
|
||||
Balance: big.NewInt(block1BankBalance - balanceChange1000),
|
||||
CodeHash: testhelpers.NullCodeHash.Bytes(),
|
||||
Root: testhelpers.EmptyContractRoot,
|
||||
@ -180,7 +173,7 @@ var (
|
||||
contractAccountAtBlock3, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce1,
|
||||
Balance: big.NewInt(0),
|
||||
CodeHash: common.HexToHash("0x753f98a8d4328b15636e46f66f2cb4bc860100aa17967cc145fcd17d1d4710ea").Bytes(),
|
||||
CodeHash: common.HexToHash("0xaaea5efba4fd7b45d7ec03918ac5d8b31aa93b48986af0e6b591f0f087c80127").Bytes(),
|
||||
Root: common.HexToHash(newContractRoot),
|
||||
})
|
||||
contractAccountAtBlock3LeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
@ -188,7 +181,7 @@ var (
|
||||
contractAccountAtBlock3,
|
||||
})
|
||||
bankAccountAtBlock3, _ = rlp.EncodeToBytes(state.Account{
|
||||
Nonce: testhelpers.Nonce4,
|
||||
Nonce: testhelpers.Nonce3,
|
||||
Balance: big.NewInt(99989000),
|
||||
CodeHash: testhelpers.NullCodeHash.Bytes(),
|
||||
Root: testhelpers.EmptyContractRoot,
|
||||
@ -201,7 +194,7 @@ var (
|
||||
block1BranchNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
crypto.Keccak256(bankAccountAtBlock1LeafNode),
|
||||
[]byte{},
|
||||
crypto.Keccak256(emptyContractAtBlock1LeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(minerAccountAtBlock1LeafNode),
|
||||
@ -220,7 +213,7 @@ var (
|
||||
block2BranchNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
crypto.Keccak256(bankAccountAtBlock2LeafNode),
|
||||
[]byte{},
|
||||
crypto.Keccak256(emptyContractAtBlock1LeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(minerAccountAtBlock2LeafNode),
|
||||
@ -239,7 +232,7 @@ var (
|
||||
block3BranchNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
crypto.Keccak256(bankAccountAtBlock3LeafNode),
|
||||
[]byte{},
|
||||
crypto.Keccak256(emptyContractAtBlock1LeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(minerAccountAtBlock2LeafNode),
|
||||
@ -255,12 +248,29 @@ var (
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
})
|
||||
block2StorageBranchNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(ownerAddrStorageLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(originalDataStorageLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
})
|
||||
block3StorageBranchNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(updatedStorageLeafNode),
|
||||
[]byte{},
|
||||
crypto.Keccak256(newStorageLeafNode),
|
||||
crypto.Keccak256(ownerAddrStorageLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
@ -269,6 +279,8 @@ var (
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(originalDataStorageLeafNode),
|
||||
crypto.Keccak256(newDataStorageLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
@ -279,7 +291,6 @@ var (
|
||||
func TestBuilder(t *testing.T) {
|
||||
blocks, chain := testhelpers.MakeChain(3, testhelpers.Genesis)
|
||||
contractLeafKey = testhelpers.AddressToLeafKey(testhelpers.ContractAddr)
|
||||
emptyContractLeafKey = testhelpers.AddressToLeafKey(testhelpers.EmptyContractAddr)
|
||||
defer chain.Stop()
|
||||
block0 = testhelpers.Genesis
|
||||
block1 = blocks[0]
|
||||
@ -350,13 +361,6 @@ func TestBuilder(t *testing.T) {
|
||||
NodeValue: bankAccountAtBlock1LeafNode,
|
||||
StorageDiffs: emptyStorage,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: emptyContractLeafKey,
|
||||
NodeValue: emptyContractAtBlock1LeafNode,
|
||||
StorageDiffs: emptyStorage,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x05'},
|
||||
NodeType: statediff.Leaf,
|
||||
@ -417,10 +421,16 @@ func TestBuilder(t *testing.T) {
|
||||
NodeValue: contractAccountAtBlock2LeafNode,
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: originalStorageLeafNode,
|
||||
LeafKey: ownerAddrStorageKey.Bytes(),
|
||||
NodeValue: ownerAddrStorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0b'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalDataStorageKey.Bytes(),
|
||||
NodeValue: originalDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -462,16 +472,10 @@ func TestBuilder(t *testing.T) {
|
||||
NodeValue: contractAccountAtBlock3LeafNode,
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: updatedStorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x04'},
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: newStorageKey.Bytes(),
|
||||
NodeValue: newStorageLeafNode,
|
||||
NodeValue: newDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -512,7 +516,6 @@ func TestBuilder(t *testing.T) {
|
||||
func TestBuilderWithIntermediateNodes(t *testing.T) {
|
||||
blocks, chain := testhelpers.MakeChain(3, testhelpers.Genesis)
|
||||
contractLeafKey = testhelpers.AddressToLeafKey(testhelpers.ContractAddr)
|
||||
emptyContractLeafKey = testhelpers.AddressToLeafKey(testhelpers.EmptyContractAddr)
|
||||
defer chain.Stop()
|
||||
block0 = testhelpers.Genesis
|
||||
block1 = blocks[0]
|
||||
@ -592,13 +595,6 @@ func TestBuilderWithIntermediateNodes(t *testing.T) {
|
||||
NodeValue: bankAccountAtBlock1LeafNode,
|
||||
StorageDiffs: emptyStorage,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: emptyContractLeafKey,
|
||||
NodeValue: emptyContractAtBlock1LeafNode,
|
||||
StorageDiffs: emptyStorage,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x05'},
|
||||
NodeType: statediff.Leaf,
|
||||
@ -666,9 +662,20 @@ func TestBuilderWithIntermediateNodes(t *testing.T) {
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
NodeType: statediff.Branch,
|
||||
NodeValue: block2StorageBranchNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: originalStorageLeafNode,
|
||||
LeafKey: ownerAddrStorageKey.Bytes(),
|
||||
NodeValue: ownerAddrStorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0b'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalDataStorageKey.Bytes(),
|
||||
NodeValue: originalDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -721,16 +728,10 @@ func TestBuilderWithIntermediateNodes(t *testing.T) {
|
||||
NodeValue: block3StorageBranchNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: updatedStorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x04'},
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: newStorageKey.Bytes(),
|
||||
NodeValue: newStorageLeafNode,
|
||||
NodeValue: newDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -859,10 +860,16 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
|
||||
NodeValue: contractAccountAtBlock2LeafNode,
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: originalStorageLeafNode,
|
||||
LeafKey: ownerAddrStorageKey.Bytes(),
|
||||
NodeValue: ownerAddrStorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x0b'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalDataStorageKey.Bytes(),
|
||||
NodeValue: originalDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -897,16 +904,10 @@ func TestBuilderWithWatchedAddressList(t *testing.T) {
|
||||
NodeValue: contractAccountAtBlock3LeafNode,
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: updatedStorageLeafNode,
|
||||
},
|
||||
{
|
||||
Path: []byte{'\x04'},
|
||||
Path: []byte{'\x0c'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: newStorageKey.Bytes(),
|
||||
NodeValue: newStorageLeafNode,
|
||||
NodeValue: newDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -947,7 +948,7 @@ func TestBuilderWithWatchedAddressAndStorageKeyList(t *testing.T) {
|
||||
block3 = blocks[2]
|
||||
params := statediff.Params{
|
||||
WatchedAddresses: []common.Address{testhelpers.Account1Addr, testhelpers.ContractAddr},
|
||||
WatchedStorageSlots: []common.Hash{originalStorageKey},
|
||||
WatchedStorageSlots: []common.Hash{originalDataStorageKey},
|
||||
}
|
||||
builder = statediff.NewBuilder(chain.StateCache())
|
||||
|
||||
@ -1029,10 +1030,10 @@ func TestBuilderWithWatchedAddressAndStorageKeyList(t *testing.T) {
|
||||
NodeValue: contractAccountAtBlock2LeafNode,
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{},
|
||||
Path: []byte{'\x0b'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: originalStorageLeafNode,
|
||||
LeafKey: originalDataStorageKey.Bytes(),
|
||||
NodeValue: originalDataStorageLeafNode,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1061,18 +1062,11 @@ func TestBuilderWithWatchedAddressAndStorageKeyList(t *testing.T) {
|
||||
BlockHash: block3.Hash(),
|
||||
Nodes: []statediff.StateNode{
|
||||
{
|
||||
Path: []byte{'\x06'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: contractAccountAtBlock3LeafNode,
|
||||
StorageDiffs: []statediff.StorageNode{
|
||||
{
|
||||
Path: []byte{'\x02'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: originalStorageKey.Bytes(),
|
||||
NodeValue: updatedStorageLeafNode,
|
||||
},
|
||||
},
|
||||
Path: []byte{'\x06'},
|
||||
NodeType: statediff.Leaf,
|
||||
LeafKey: contractLeafKey,
|
||||
NodeValue: contractAccountAtBlock3LeafNode,
|
||||
StorageDiffs: emptyStorage,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1101,6 +1095,7 @@ func TestBuilderWithWatchedAddressAndStorageKeyList(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestBuilderWithMoreAndRemovedStorage(t *testing.T) {
|
||||
blocks, chain := testhelpers.MakeChain(5, testhelpers.Genesis)
|
||||
contractLeafKey = testhelpers.AddressToLeafKey(testhelpers.ContractAddr)
|
||||
@ -1229,24 +1224,36 @@ func TestBuilderWithEIP158RemovedAccount(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// Write a test that tests when accounts are deleted, or moved to a new path
|
||||
|
||||
/*
|
||||
pragma solidity ^0.5.10;
|
||||
|
||||
contract test {
|
||||
address payable owner;
|
||||
|
||||
modifier onlyOwner {
|
||||
require(
|
||||
msg.sender == owner,
|
||||
"Only owner can call this function."
|
||||
);
|
||||
_;
|
||||
}
|
||||
|
||||
uint256[100] data;
|
||||
|
||||
constructor() public {
|
||||
owner = msg.sender;
|
||||
data = [1];
|
||||
}
|
||||
|
||||
function Put(uint256 addr, uint256 value) {
|
||||
function Put(uint256 addr, uint256 value) public {
|
||||
data[addr] = value;
|
||||
}
|
||||
|
||||
function Get(uint256 addr) constant returns (uint256 value) {
|
||||
return data[addr];
|
||||
function close() public onlyOwner { //onlyOwner is custom modifier
|
||||
selfdestruct(owner); // `owner` is the owners address
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -44,16 +44,8 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||
switch i {
|
||||
case 0:
|
||||
// In block 1, the test bank sends account #1 some ether.
|
||||
// And the bank makes an empty contract account (to be removed by EIP-158)
|
||||
nonce := block.TxNonce(TestBankAddress)
|
||||
tx1, _ := types.SignTx(types.NewTransaction(nonce, Account1Addr, big.NewInt(10000), params.TxGas, nil, nil), signer, TestBankKey)
|
||||
nonce++
|
||||
// this creates an empty contract at 2f30668e69d30b6fc1609db5447c101e40dda113ac28be157d20bb61da8e5861
|
||||
// it is created since we are not yet at EIP158 or Byzantium activation
|
||||
tx2, _ := types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 1000000, big.NewInt(0), EmptyContractCode), signer, TestBankKey)
|
||||
EmptyContractAddr = crypto.CreateAddress(TestBankAddress, nonce)
|
||||
block.AddTx(tx1)
|
||||
block.AddTx(tx2)
|
||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(TestBankAddress), Account1Addr, big.NewInt(10000), params.TxGas, nil, nil), signer, TestBankKey)
|
||||
block.AddTx(tx)
|
||||
case 1:
|
||||
// In block 2, the test bank sends some more ether to account #1.
|
||||
// account1Addr passes it on to account #2.
|
||||
@ -68,11 +60,11 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||
block.AddTx(tx2)
|
||||
block.AddTx(tx3)
|
||||
case 2:
|
||||
// Block 3 has a single tx from the bankAccount to the contract, that transfers no value
|
||||
// Block is mined by account2
|
||||
// Block 3 has a single tx from the bankAccount to the contract, that transfers no value, that is mined by account2
|
||||
block.SetCoinbase(Account2Addr)
|
||||
//get function: 60cd2685
|
||||
//put function: c16431b9
|
||||
//close function: 43d726d6
|
||||
data := common.Hex2Bytes("C16431B900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003")
|
||||
tx, _ := types.SignTx(types.NewTransaction(block.TxNonce(TestBankAddress), ContractAddr, big.NewInt(0), 100000, nil, data), signer, TestBankKey)
|
||||
block.AddTx(tx)
|
||||
@ -103,13 +95,5 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||
block.AddTx(tx2)
|
||||
case 5:
|
||||
// Block 6 has a tx which creates a contract with leafkey 2f30668e69d30b6fc1609db5447c101e40dda113ac28be157d20bb61da8e5861
|
||||
// which means the empty contract at 2f30668e69d30b6fc1609db5447c101e40dda113ac28be157d20bb61da8e5861 must be moved to a new path
|
||||
// this should count as "touching" that account and cause it to be removed according to EIP-158
|
||||
// Block is mined by Account2Addr
|
||||
block.SetCoinbase(Account2Addr)
|
||||
nonce := block.TxNonce(Account3Addr)
|
||||
tx, _ := types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 1000000, big.NewInt(0), ContractCode), signer, Account3Key)
|
||||
ContractAddr2 = crypto.CreateAddress(Account3Addr, nonce) //0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592
|
||||
block.AddTx(tx)
|
||||
}
|
||||
}
|
||||
|
@ -57,18 +57,16 @@ var (
|
||||
TestBankFunds = big.NewInt(100000000)
|
||||
Genesis = core.GenesisBlockForTesting(Testdb, TestBankAddress, TestBankFunds)
|
||||
|
||||
Account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
||||
Account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
||||
Account3Key, _ = crypto.HexToECDSA("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
|
||||
Account1Addr = crypto.PubkeyToAddress(Account1Key.PublicKey) //0x703c4b2bD70c169f5717101CaeE543299Fc946C7
|
||||
Account2Addr = crypto.PubkeyToAddress(Account2Key.PublicKey) //0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e
|
||||
Account3Addr = crypto.PubkeyToAddress(Account3Key.PublicKey) //0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e
|
||||
Account1LeafKey = AddressToLeafKey(Account1Addr)
|
||||
Account2LeafKey = AddressToLeafKey(Account2Addr)
|
||||
Account3LeafKey = AddressToLeafKey(Account3Addr)
|
||||
ContractCode = common.Hex2Bytes("608060405234801561001057600080fd5b50602060405190810160405280600160ff16815250600090600161003592919061003b565b506100a5565b826064810192821561006f579160200282015b8281111561006e578251829060ff1690559160200191906001019061004e565b5b50905061007c9190610080565b5090565b6100a291905b8082111561009e576000816000905550600101610086565b5090565b90565b610124806100b46000396000f3fe6080604052348015600f57600080fd5b5060043610604f576000357c01000000000000000000000000000000000000000000000000000000009004806360cd2685146054578063c16431b9146093575b600080fd5b607d60048036036020811015606857600080fd5b810190808035906020019092919050505060c8565b6040518082815260200191505060405180910390f35b60c66004803603604081101560a757600080fd5b81019080803590602001909291908035906020019092919050505060e0565b005b6000808260648110151560d757fe5b01549050919050565b8060008360648110151560ef57fe5b0181905550505056fea165627a7a7230582064e918c3140a117bf3aa65865a9b9e83fae21ad1720506e7933b2a9f54bb40260029")
|
||||
EmptyContractCode []byte
|
||||
ContractAddr, EmptyContractAddr, ContractAddr2 common.Address
|
||||
Account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
||||
Account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
||||
Account3Key, _ = crypto.HexToECDSA("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
|
||||
Account1Addr = crypto.PubkeyToAddress(Account1Key.PublicKey) //0x703c4b2bD70c169f5717101CaeE543299Fc946C7
|
||||
Account2Addr = crypto.PubkeyToAddress(Account2Key.PublicKey) //0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e
|
||||
Account3Addr = crypto.PubkeyToAddress(Account3Key.PublicKey) //0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e
|
||||
Account1LeafKey = AddressToLeafKey(Account1Addr)
|
||||
Account2LeafKey = AddressToLeafKey(Account2Addr)
|
||||
ContractCode = common.Hex2Bytes("608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506040518060200160405280600160ff16815250600190600161007492919061007a565b506100e4565b82606481019282156100ae579160200282015b828111156100ad578251829060ff1690559160200191906001019061008d565b5b5090506100bb91906100bf565b5090565b6100e191905b808211156100dd5760008160009055506001016100c5565b5090565b90565b6101ca806100f36000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806343d726d61461003b578063c16431b914610045575b600080fd5b61004361007d565b005b61007b6004803603604081101561005b57600080fd5b81019080803590602001909291908035906020019092919050505061015c565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610122576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101746022913960400191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b806001836064811061016a57fe5b0181905550505056fe4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f6e2ea265627a7a72305820e3747183708fb6bff3f6f7a80fb57dcc1c19f83f9cb25457a3ed5c0424bde66864736f6c634300050a0032")
|
||||
ContractAddr common.Address
|
||||
|
||||
EmptyRootNode, _ = rlp.EncodeToBytes([]byte{})
|
||||
EmptyContractRoot = crypto.Keccak256Hash(EmptyRootNode)
|
||||
@ -76,5 +74,4 @@ var (
|
||||
Nonce1 = uint64(1)
|
||||
Nonce2 = uint64(2)
|
||||
Nonce3 = uint64(3)
|
||||
Nonce4 = uint64(4)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user