erigon-pulse/tests/statedb_insert_chain_transaction_test.go

827 lines
22 KiB
Go
Raw Normal View History

2019-11-08 10:21:44 +00:00
package tests
import (
"context"
2019-11-08 14:55:56 +00:00
"crypto/ecdsa"
2019-11-13 10:52:03 +00:00
"fmt"
2019-11-08 10:21:44 +00:00
"math/big"
"testing"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
2021-06-06 07:45:49 +00:00
"github.com/stretchr/testify/require"
"github.com/ledgerwatch/erigon/turbo/stages/mock"
"github.com/ledgerwatch/erigon/accounts/abi/bind"
"github.com/ledgerwatch/erigon/accounts/abi/bind/backends"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/tests/contracts"
2019-11-08 10:21:44 +00:00
)
func TestInsertIncorrectStateRootDifferentAccounts(t *testing.T) {
2019-11-08 14:55:56 +00:00
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-08 14:55:56 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
1: {
getBlockTx(from, to, uint256.NewInt(2000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
})
2019-11-08 10:21:44 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-08 14:55:56 +00:00
// BLOCK 1
incorrectHeader := *chain.Headers[0] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
2019-11-08 10:21:44 +00:00
if chain.Headers[0].Root == incorrectHeader.Root {
2019-11-08 14:55:56 +00:00
t.Fatal("roots are the same")
}
2019-11-08 10:21:44 +00:00
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-08 14:55:56 +00:00
t.Fatal("should fail")
}
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
// insert a correct block
m, chain, err = GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(data.addresses[1], to, uint256.NewInt(5000)),
2019-11-08 14:55:56 +00:00
data.keys[1],
},
})
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
if err = m.InsertChain(chain); err != nil {
t.Fatal(err)
}
2023-06-15 09:09:11 +00:00
tx, err := m.DB.BeginRw(context.Background())
2021-06-06 07:45:49 +00:00
require.NoError(t, err)
defer tx.Rollback()
st := state.New(m.NewStateReader(tx))
2019-11-08 14:55:56 +00:00
if !st.Exist(to) {
t.Error("expected account to exist")
}
2019-11-08 10:21:44 +00:00
if balance := st.GetBalance(from); balance.Uint64() != 1000000000 {
t.Fatalf("got %v, expected %v", balance, 1000000000)
2019-11-08 14:55:56 +00:00
}
if balance := st.GetBalance(data.addresses[1]); balance.Uint64() != 999995000 {
t.Fatalf("got %v, expected %v", balance, 999995000)
2019-11-14 16:14:25 +00:00
}
if balance := st.GetBalance(to); balance.Uint64() != 5000 {
t.Fatalf("got %v, expected %v", balance, 5000)
2019-11-08 14:55:56 +00:00
}
}
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
func TestInsertIncorrectStateRootSameAccount(t *testing.T) {
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-08 14:55:56 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
1: {
getBlockTx(from, to, uint256.NewInt(2000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
2019-11-08 10:21:44 +00:00
})
2019-11-08 14:55:56 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
// BLOCK 1
incorrectHeader := *chain.Headers[0] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
2019-11-08 10:21:44 +00:00
if chain.Headers[0].Root == incorrectHeader.Root {
2019-11-08 10:21:44 +00:00
t.Fatal("roots are the same")
}
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-08 10:21:44 +00:00
t.Fatal("should fail")
}
2019-11-08 14:55:56 +00:00
// insert a correct block
m, chain, err = GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(5000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
2019-11-08 10:21:44 +00:00
})
2019-11-08 14:55:56 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
if err = m.InsertChain(chain); err != nil {
2019-11-08 10:21:44 +00:00
t.Fatal(err)
}
2021-06-06 07:45:49 +00:00
tx, err := m.DB.BeginRo(context.Background())
require.NoError(t, err)
defer tx.Rollback()
st := state.New(m.NewStateReader(tx))
2019-11-08 14:55:56 +00:00
if !st.Exist(to) {
2019-11-08 10:21:44 +00:00
t.Error("expected account to exist")
}
if balance := st.GetBalance(from); balance.Uint64() != 999995000 {
t.Fatalf("got %v, expected %v", balance, 999995000)
2019-11-08 14:55:56 +00:00
}
if balance := st.GetBalance(to); balance.Uint64() != 5000 {
t.Fatalf("got %v, expected %v", balance, 5000)
2019-11-08 10:21:44 +00:00
}
}
2019-11-08 14:55:56 +00:00
func TestInsertIncorrectStateRootSameAccountSameAmount(t *testing.T) {
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-08 14:55:56 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
1: {
getBlockTx(from, to, uint256.NewInt(2000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
})
2019-11-08 10:21:44 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-08 14:55:56 +00:00
// BLOCK 1
incorrectHeader := *chain.Headers[0] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
2019-11-08 10:21:44 +00:00
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-08 14:55:56 +00:00
t.Fatal("should fail")
}
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
// insert a correct block
m, chain, err = GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
})
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
if err = m.InsertChain(chain); err != nil {
2019-11-08 14:55:56 +00:00
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
2021-06-06 07:45:49 +00:00
tx, err := m.DB.BeginRo(context.Background())
require.NoError(t, err)
defer tx.Rollback()
st := state.New(m.NewStateReader(tx))
2019-11-08 14:55:56 +00:00
if !st.Exist(to) {
t.Error("expected account to exist")
}
2019-11-08 10:21:44 +00:00
if balance := st.GetBalance(from); balance.Uint64() != 999999000 {
t.Fatalf("got %v, expected %v", balance, 999999000)
2019-11-08 14:55:56 +00:00
}
if balance := st.GetBalance(to); balance.Uint64() != 1000 {
t.Fatalf("got %v, expected %v", balance, 1000)
2019-11-08 14:55:56 +00:00
}
}
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
func TestInsertIncorrectStateRootAllFundsRoot(t *testing.T) {
data := getGenesis(big.NewInt(3000))
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-08 14:55:56 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
1: {
getBlockTx(from, to, uint256.NewInt(2000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
2019-11-08 10:21:44 +00:00
})
2019-11-08 14:55:56 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
// BLOCK 1
incorrectHeader := *chain.Headers[0] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
2019-11-08 10:21:44 +00:00
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-08 10:21:44 +00:00
t.Fatal("should fail")
}
2019-11-08 14:55:56 +00:00
// insert a correct block
m, chain, err = GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
})
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
if err = m.InsertChain(chain); err != nil {
2019-11-08 14:55:56 +00:00
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
2021-06-06 07:45:49 +00:00
tx, err := m.DB.BeginRo(context.Background())
require.NoError(t, err)
defer tx.Rollback()
st := state.New(m.NewStateReader(tx))
2019-11-08 14:55:56 +00:00
if !st.Exist(to) {
t.Error("expected account to exist")
}
2019-11-08 10:21:44 +00:00
if balance := st.GetBalance(from); balance.Uint64() != 2000 {
t.Fatalf("got %v, expected %v", balance, 2000)
2019-11-08 14:55:56 +00:00
}
if balance := st.GetBalance(to); balance.Uint64() != 1000 {
t.Fatalf("got %v, expected %v", balance, 1000)
2019-11-08 14:55:56 +00:00
}
}
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
func TestInsertIncorrectStateRootAllFunds(t *testing.T) {
data := getGenesis(big.NewInt(3000))
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-08 14:55:56 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(3000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
1: {
getBlockTx(data.addresses[1], to, uint256.NewInt(2000)),
2019-11-08 14:55:56 +00:00
data.keys[1],
},
})
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
// BLOCK 1
incorrectHeader := *chain.Headers[0] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
2019-11-08 10:21:44 +00:00
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-08 14:55:56 +00:00
t.Fatal("should fail")
}
// insert a correct block
m, chain, err = GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-08 14:55:56 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(1000)),
2019-11-08 14:55:56 +00:00
fromKey,
},
})
if err != nil {
t.Fatal(err)
}
2019-11-08 10:21:44 +00:00
if err = m.InsertChain(chain); err != nil {
2019-11-08 10:21:44 +00:00
t.Fatal(err)
}
2021-06-06 07:45:49 +00:00
tx, err := m.DB.BeginRo(context.Background())
require.NoError(t, err)
defer tx.Rollback()
st := state.New(m.NewStateReader(tx))
2019-11-08 14:55:56 +00:00
if !st.Exist(to) {
2019-11-08 10:21:44 +00:00
t.Error("expected account to exist")
}
if balance := st.GetBalance(from); balance.Uint64() != 2000 {
t.Fatalf("got %v, expected %v", balance, 2000)
2019-11-08 14:55:56 +00:00
}
if balance := st.GetBalance(to); balance.Uint64() != 1000 {
t.Fatalf("got %v, expected %v", balance, 1000)
2019-11-08 10:21:44 +00:00
}
}
2019-11-11 15:21:07 +00:00
func TestAccountDeployIncorrectRoot(t *testing.T) {
2019-11-13 10:52:03 +00:00
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-11 15:21:07 +00:00
var contractAddress libcommon.Address
eipContract := new(contracts.Testcontract)
2019-11-11 15:21:07 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-13 10:52:03 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(10)),
2019-11-13 10:52:03 +00:00
fromKey,
},
1: {
getBlockDeployTestContractTx(data.transactOpts[0], &contractAddress, eipContract),
2019-11-13 10:52:03 +00:00
fromKey,
},
2019-11-11 15:21:07 +00:00
})
2019-11-13 10:52:03 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-11 15:21:07 +00:00
// BLOCK 1
if err = m.InsertChain(chain.Slice(0, 1)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if st.Exist(contractAddress) {
t.Error("expected contractAddress to not exist at the block 0", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
incorrectHeader := *chain.Headers[1] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[0].Root
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[1].Transactions(), chain.Blocks[1].Uncles(), chain.Receipts[1], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
2019-11-11 15:21:07 +00:00
// BLOCK 2 - INCORRECT
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-11 15:21:07 +00:00
t.Fatal("should fail")
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if st.Exist(contractAddress) {
t.Error("expected contractAddress to not exist at the block 1", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 2 - CORRECT
if err = m.InsertChain(chain.Slice(1, 2)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if !st.Exist(contractAddress) {
t.Error("expected contractAddress to not exist at the block 1", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
}
func TestAccountCreateIncorrectRoot(t *testing.T) {
2019-11-13 10:52:03 +00:00
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-11 15:21:07 +00:00
var contractAddress libcommon.Address
eipContract := new(contracts.Testcontract)
2019-11-11 15:21:07 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-13 10:52:03 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(10)),
2019-11-13 10:52:03 +00:00
fromKey,
},
1: {
getBlockDeployTestContractTx(data.transactOpts[0], &contractAddress, eipContract),
2019-11-13 10:52:03 +00:00
fromKey,
},
2: {
getBlockTestContractTx(data.transactOpts[0], eipContract.Create, big.NewInt(2)),
2019-11-13 10:52:03 +00:00
fromKey,
},
2019-11-11 15:21:07 +00:00
})
2019-11-13 10:52:03 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-11 15:21:07 +00:00
// BLOCK 1
if err = m.InsertChain(chain.Slice(0, 1)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if st.Exist(contractAddress) {
t.Error("expected contractAddress to not exist at the block 0", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 2
if err = m.InsertChain(chain.Slice(1, 2)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if !st.Exist(contractAddress) {
t.Error("expected contractAddress to exist at the block 2", contractAddress.Hash().String())
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 3 - INCORRECT
incorrectHeader := *chain.Headers[2] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[2].Transactions(), chain.Blocks[2].Uncles(), chain.Receipts[2], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
2019-11-11 15:21:07 +00:00
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-11 15:21:07 +00:00
t.Fatal("should fail")
}
// BLOCK 3
if err = m.InsertChain(chain.Slice(2, 3)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
}
func TestAccountUpdateIncorrectRoot(t *testing.T) {
2019-11-13 10:52:03 +00:00
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-11 15:21:07 +00:00
var contractAddress libcommon.Address
eipContract := new(contracts.Testcontract)
2019-11-11 15:21:07 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-13 10:52:03 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(10)),
2019-11-13 10:52:03 +00:00
fromKey,
},
1: {
getBlockDeployTestContractTx(data.transactOpts[0], &contractAddress, eipContract),
2019-11-13 10:52:03 +00:00
fromKey,
},
2: {
getBlockTestContractTx(data.transactOpts[0], eipContract.Create, big.NewInt(2)),
2019-11-13 10:52:03 +00:00
fromKey,
},
3: {
getBlockTestContractTx(data.transactOpts[0], eipContract.Update, big.NewInt(0)),
2019-11-13 10:52:03 +00:00
fromKey,
},
2019-11-11 15:21:07 +00:00
})
2019-11-13 10:52:03 +00:00
if err != nil {
t.Fatal(err)
}
2019-11-11 15:21:07 +00:00
// BLOCK 1
if err = m.InsertChain(chain.Slice(0, 1)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if st.Exist(contractAddress) {
t.Error("expected contractAddress to not exist at the block 0", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 2
if err = m.InsertChain(chain.Slice(1, 2)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if !st.Exist(contractAddress) {
t.Error("expected contractAddress to exist at the block 2", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 3
if err = m.InsertChain(chain.Slice(2, 3)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
// BLOCK 4 - INCORRECT
incorrectHeader := *chain.Headers[3] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[3].Transactions(), chain.Blocks[3].Uncles(), chain.Receipts[3], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
2019-11-11 15:21:07 +00:00
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-11 15:21:07 +00:00
t.Fatal("should fail")
}
// BLOCK 4
if err = m.InsertChain(chain.Slice(3, 4)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
}
func TestAccountDeleteIncorrectRoot(t *testing.T) {
2019-11-13 10:52:03 +00:00
data := getGenesis()
from := data.addresses[0]
fromKey := data.keys[0]
to := libcommon.Address{1}
2019-11-11 15:21:07 +00:00
var contractAddress libcommon.Address
eipContract := new(contracts.Testcontract)
2019-11-11 15:21:07 +00:00
m, chain, err := GenerateBlocks(t, data.genesisSpec, map[int]txn{
2019-11-13 10:52:03 +00:00
0: {
getBlockTx(from, to, uint256.NewInt(10)),
2019-11-13 10:52:03 +00:00
fromKey,
},
1: {
getBlockDeployTestContractTx(data.transactOpts[0], &contractAddress, eipContract),
2019-11-13 10:52:03 +00:00
fromKey,
},
2: {
getBlockTestContractTx(data.transactOpts[0], eipContract.Create, big.NewInt(2)),
2019-11-13 10:52:03 +00:00
fromKey,
},
3: {
getBlockTestContractTx(data.transactOpts[0], eipContract.Remove),
2019-11-13 10:52:03 +00:00
fromKey,
},
2019-11-11 15:21:07 +00:00
})
if err != nil {
t.Fatal(err)
}
// BLOCK 1
if err = m.InsertChain(chain.Slice(0, 1)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if st.Exist(contractAddress) {
t.Error("expected contractAddress to not exist at the block 0", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 2
if err = m.InsertChain(chain.Slice(1, 2)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
err = m.DB.View(context.Background(), func(tx kv.Tx) error {
st := state.New(m.NewStateReader(tx))
2021-06-06 07:45:49 +00:00
if !st.Exist(from) {
t.Error("expected account to exist")
}
2019-11-11 15:21:07 +00:00
2021-06-06 07:45:49 +00:00
if !st.Exist(contractAddress) {
t.Error("expected contractAddress to exist at the block 1", contractAddress.Hash().String())
}
return nil
})
require.NoError(t, err)
2019-11-11 15:21:07 +00:00
// BLOCK 3
if err = m.InsertChain(chain.Slice(2, 3)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
// BLOCK 4 - INCORRECT
incorrectHeader := *chain.Headers[3] // Copy header, not just pointer
incorrectHeader.Root = chain.Headers[1].Root
incorrectBlock := types.NewBlock(&incorrectHeader, chain.Blocks[3].Transactions(), chain.Blocks[3].Uncles(), chain.Receipts[3], nil)
incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{&incorrectHeader}, TopBlock: incorrectBlock}
if err = m.InsertChain(incorrectChain); err == nil {
2019-11-11 15:21:07 +00:00
t.Fatal("should fail")
}
// BLOCK 4
if err = m.InsertChain(chain.Slice(3, 4)); err != nil {
2019-11-11 15:21:07 +00:00
t.Fatal(err)
}
}
2019-11-08 14:55:56 +00:00
type initialData struct {
2019-11-13 10:52:03 +00:00
keys []*ecdsa.PrivateKey
addresses []libcommon.Address
2019-11-13 10:52:03 +00:00
transactOpts []*bind.TransactOpts
genesisSpec *types.Genesis
2019-11-08 14:55:56 +00:00
}
func getGenesis(funds ...*big.Int) initialData {
accountFunds := big.NewInt(1000000000)
if len(funds) > 0 {
accountFunds = funds[0]
}
keys := make([]*ecdsa.PrivateKey, 3)
keys[0], _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
keys[1], _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
keys[2], _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
addresses := make([]libcommon.Address, 0, len(keys))
2019-11-13 11:12:58 +00:00
transactOpts := make([]*bind.TransactOpts, 0, len(keys))
allocs := types.GenesisAlloc{}
2019-11-08 14:55:56 +00:00
for _, key := range keys {
addr := crypto.PubkeyToAddress(key.PublicKey)
addresses = append(addresses, addr)
to, err := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1))
if err != nil {
panic(err)
}
transactOpts = append(transactOpts, to)
2019-11-08 14:55:56 +00:00
allocs[addr] = types.GenesisAccount{Balance: accountFunds}
2019-11-08 14:55:56 +00:00
}
return initialData{
2019-11-13 10:52:03 +00:00
keys: keys,
addresses: addresses,
transactOpts: transactOpts,
genesisSpec: &types.Genesis{
Config: &chain.Config{
ChainID: big.NewInt(1),
HomesteadBlock: new(big.Int),
TangerineWhistleBlock: new(big.Int),
SpuriousDragonBlock: big.NewInt(1),
ByzantiumBlock: big.NewInt(1),
ConstantinopleBlock: big.NewInt(1),
2019-11-08 10:21:44 +00:00
},
2019-11-08 14:55:56 +00:00
Alloc: allocs,
},
}
}
2019-11-08 10:21:44 +00:00
2023-06-15 09:09:11 +00:00
type txn struct {
2019-11-08 14:55:56 +00:00
txFn blockTx
key *ecdsa.PrivateKey
}
func GenerateBlocks(t *testing.T, gspec *types.Genesis, txs map[int]txn) (*mock.MockSentry, *core.ChainPack, error) {
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
m := mock.MockWithGenesis(t, gspec, key, false)
2019-11-08 14:55:56 +00:00
contractBackend := backends.NewTestSimulatedBackendWithConfig(t, gspec.Alloc, gspec.Config, gspec.GasLimit)
2019-11-08 10:21:44 +00:00
chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, len(txs), func(i int, block *core.BlockGen) {
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
var tx types.Transaction
2019-11-13 10:52:03 +00:00
var isContractCall bool
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
signer := types.LatestSignerForChainID(nil)
2019-11-08 10:21:44 +00:00
2019-11-08 14:55:56 +00:00
if txToSend, ok := txs[i]; ok {
2019-11-13 10:52:03 +00:00
tx, isContractCall = txToSend.txFn(block, contractBackend)
2021-04-06 09:52:53 +00:00
var err error
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
tx, err = types.SignTx(tx, *signer, txToSend.key)
2019-11-08 10:21:44 +00:00
if err != nil {
2019-11-08 14:55:56 +00:00
return
2019-11-08 10:21:44 +00:00
}
}
if tx != nil {
2019-11-13 10:52:03 +00:00
if !isContractCall {
2021-04-06 09:52:53 +00:00
err := contractBackend.SendTransaction(context.Background(), tx)
2019-11-13 10:52:03 +00:00
if err != nil {
return
}
2019-11-08 10:21:44 +00:00
}
block.AddTx(tx)
}
2019-11-08 14:55:56 +00:00
contractBackend.Commit()
})
if err != nil {
return nil, nil, fmt.Errorf("generate chain: %w", err)
}
return m, chain, err
2019-11-08 14:55:56 +00:00
}
2019-11-08 10:21:44 +00:00
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
type blockTx func(_ *core.BlockGen, backend bind.ContractBackend) (types.Transaction, bool)
2019-11-08 10:21:44 +00:00
func getBlockTx(from libcommon.Address, to libcommon.Address, amount *uint256.Int) blockTx {
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
return func(block *core.BlockGen, _ bind.ContractBackend) (types.Transaction, bool) {
return types.NewTransaction(block.TxNonce(from), to, amount, 21000, new(uint256.Int), nil), false
2019-11-13 10:52:03 +00:00
}
}
func getBlockDeployTestContractTx(transactOpts *bind.TransactOpts, contractAddress *libcommon.Address, eipContract *contracts.Testcontract) blockTx {
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
return func(_ *core.BlockGen, backend bind.ContractBackend) (types.Transaction, bool) {
contractAddressRes, tx, eipContractRes, err := contracts.DeployTestcontract(transactOpts, backend)
2019-11-13 10:52:03 +00:00
if err != nil {
panic(err)
}
*contractAddress = contractAddressRes
*eipContract = *eipContractRes
return tx, true
}
}
func getBlockTestContractTx(transactOpts *bind.TransactOpts, contractCall interface{}, newBalance ...*big.Int) blockTx {
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
return func(_ *core.BlockGen, backend bind.ContractBackend) (types.Transaction, bool) {
2019-11-13 10:52:03 +00:00
var (
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
tx types.Transaction
2019-11-13 10:52:03 +00:00
err error
)
switch fn := contractCall.(type) {
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
case func(opts *bind.TransactOpts) (types.Transaction, error):
2019-11-13 10:52:03 +00:00
tx, err = fn(transactOpts)
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
case func(opts *bind.TransactOpts, newBalance *big.Int) (types.Transaction, error):
2019-11-13 10:52:03 +00:00
if len(newBalance) != 1 {
panic("*big.Int type new balance is expected")
}
tx, err = fn(transactOpts, newBalance[0])
default:
panic("non expected function type")
}
if err != nil {
panic(err)
}
return tx, true
2019-11-08 10:21:44 +00:00
}
}