aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-11-02 20:44:13 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-11-13 21:55:30 +0800
commit4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188 (patch)
tree5c55a3088c944ddf517aa4d7c85c5dc7f02d00e4 /eth
parent5cd86443ee071b5e3abe4995c777ce467c29f2c5 (diff)
downloaddexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.gz
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.bz2
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.lz
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.xz
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.zst
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.zip
core/types, params: EIP#155
Diffstat (limited to 'eth')
-rw-r--r--eth/api.go12
-rw-r--r--eth/api_backend.go12
-rw-r--r--eth/downloader/downloader_test.go3
-rw-r--r--eth/fetcher/fetcher_test.go3
-rw-r--r--eth/handler_test.go14
-rw-r--r--eth/helper_test.go4
6 files changed, 27 insertions, 21 deletions
diff --git a/eth/api.go b/eth/api.go
index 7932bbcb6..b3185c392 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -506,21 +506,15 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, txHash common.
if err != nil {
return nil, err
}
+
+ signer := types.MakeSigner(api.config, block.Number())
// Mutate the state and trace the selected transaction
for idx, tx := range block.Transactions() {
// Assemble the transaction call message
- from, err := tx.FromFrontier()
+ msg, err := tx.AsMessage(signer)
if err != nil {
return nil, fmt.Errorf("sender retrieval failed: %v", err)
}
- msg := callmsg{
- addr: from,
- to: tx.To(),
- gas: tx.Gas(),
- gasPrice: tx.GasPrice(),
- value: tx.Value(),
- data: tx.Data(),
- }
// Mutate the state if we haven't reached the tracing transaction yet
if uint64(idx) < txIndex {
vmenv := core.NewEnv(stateDb, api.config, api.eth.BlockChain(), msg, block.Header(), vm.Config{})
diff --git a/eth/api_backend.go b/eth/api_backend.go
index f17ad6a15..0925132ef 100644
--- a/eth/api_backend.go
+++ b/eth/api_backend.go
@@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/ethapi"
+ "github.com/ethereum/go-ethereum/params"
rpc "github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)
@@ -40,6 +41,14 @@ type EthApiBackend struct {
gpo *gasprice.GasPriceOracle
}
+func (b *EthApiBackend) ChainConfig() *params.ChainConfig {
+ return b.eth.chainConfig
+}
+
+func (b *EthApiBackend) CurrentBlock() *types.Block {
+ return b.eth.blockchain.CurrentBlock()
+}
+
func (b *EthApiBackend) SetHead(number uint64) {
b.eth.blockchain.SetHead(number)
}
@@ -99,8 +108,7 @@ func (b *EthApiBackend) GetTd(blockHash common.Hash) *big.Int {
func (b *EthApiBackend) GetVMEnv(ctx context.Context, msg core.Message, state ethapi.State, header *types.Header) (vm.Environment, func() error, error) {
statedb := state.(EthApiState).state
- addr, _ := msg.From()
- from := statedb.GetOrNewStateObject(addr)
+ from := statedb.GetOrNewStateObject(msg.From())
from.SetBalance(common.MaxBig)
vmError := func() error { return nil }
return core.NewEnv(statedb, b.eth.chainConfig, b.eth.blockchain, msg, header, vm.Config{}), vmError, nil
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index f5f2437fa..86638ae2d 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -118,7 +118,8 @@ func (dl *downloadTester) makeChain(n int, seed byte, parent *types.Block, paren
}
// If the block number is multiple of 3, send a bonus transaction to the miner
if parent == dl.genesis && i%3 == 0 {
- tx, err := types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testKey)
+ signer := types.MakeSigner(params.TestChainConfig, block.Number())
+ tx, err := types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(signer, testKey)
if err != nil {
panic(err)
}
diff --git a/eth/fetcher/fetcher_test.go b/eth/fetcher/fetcher_test.go
index 5d46c62fd..426bfd542 100644
--- a/eth/fetcher/fetcher_test.go
+++ b/eth/fetcher/fetcher_test.go
@@ -50,7 +50,8 @@ func makeChain(n int, seed byte, parent *types.Block) ([]common.Hash, map[common
// If the block number is multiple of 3, send a bonus transaction to the miner
if parent == genesis && i%3 == 0 {
- tx, err := types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testKey)
+ signer := types.MakeSigner(params.TestChainConfig, block.Number())
+ tx, err := types.NewTransaction(block.TxNonce(testAddress), common.Address{seed}, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(signer, testKey)
if err != nil {
panic(err)
}
diff --git a/eth/handler_test.go b/eth/handler_test.go
index 045bad0d4..f599e9e86 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -305,18 +305,19 @@ func testGetNodeData(t *testing.T, protocol int) {
acc1Addr := crypto.PubkeyToAddress(acc1Key.PublicKey)
acc2Addr := crypto.PubkeyToAddress(acc2Key.PublicKey)
+ signer := types.HomesteadSigner{}
// Create a chain generator with some simple transactions (blatantly stolen from @fjl/chain_markets_test)
generator := func(i int, block *core.BlockGen) {
switch i {
case 0:
// In block 1, the test bank sends account #1 some ether.
- tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
+ tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(signer, testBankKey)
block.AddTx(tx)
case 1:
// In block 2, the test bank sends some more ether to account #1.
// acc1Addr passes it on to account #2.
- tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
- tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key)
+ tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(signer, testBankKey)
+ tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(signer, acc1Key)
block.AddTx(tx1)
block.AddTx(tx2)
case 2:
@@ -396,18 +397,19 @@ func testGetReceipt(t *testing.T, protocol int) {
acc1Addr := crypto.PubkeyToAddress(acc1Key.PublicKey)
acc2Addr := crypto.PubkeyToAddress(acc2Key.PublicKey)
+ signer := types.HomesteadSigner{}
// Create a chain generator with some simple transactions (blatantly stolen from @fjl/chain_markets_test)
generator := func(i int, block *core.BlockGen) {
switch i {
case 0:
// In block 1, the test bank sends account #1 some ether.
- tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
+ tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(signer, testBankKey)
block.AddTx(tx)
case 1:
// In block 2, the test bank sends some more ether to account #1.
// acc1Addr passes it on to account #2.
- tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
- tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key)
+ tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(signer, testBankKey)
+ tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(signer, acc1Key)
block.AddTx(tx1)
block.AddTx(tx2)
case 2:
diff --git a/eth/helper_test.go b/eth/helper_test.go
index 73af04fcf..f23976785 100644
--- a/eth/helper_test.go
+++ b/eth/helper_test.go
@@ -110,7 +110,7 @@ func (p *testTxPool) Pending() map[common.Address]types.Transactions {
batches := make(map[common.Address]types.Transactions)
for _, tx := range p.pool {
- from, _ := tx.From()
+ from, _ := types.Sender(types.HomesteadSigner{}, tx)
batches[from] = append(batches[from], tx)
}
for _, batch := range batches {
@@ -122,7 +122,7 @@ func (p *testTxPool) Pending() map[common.Address]types.Transactions {
// newTestTransaction create a new dummy transaction.
func newTestTransaction(from *ecdsa.PrivateKey, nonce uint64, datasize int) *types.Transaction {
tx := types.NewTransaction(nonce, common.Address{}, big.NewInt(0), big.NewInt(100000), big.NewInt(0), make([]byte, datasize))
- tx, _ = tx.SignECDSA(from)
+ tx, _ = tx.SignECDSA(types.HomesteadSigner{}, from)
return tx
}