Skip to content

Commit 4a439c2

Browse files
committed
mobile: port wrappers to EIP155 and EIP158 fork
1 parent 4c16c82 commit 4a439c2

File tree

6 files changed

+58
-48
lines changed

6 files changed

+58
-48
lines changed

cmd/utils/bootnodes.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
package utils
1818

1919
import (
20-
"github.com/ethereum/go-ethereum/core"
2120
"github.com/ethereum/go-ethereum/p2p/discover"
2221
"github.com/ethereum/go-ethereum/p2p/discv5"
23-
"github.com/ethereum/go-ethereum/params"
2422
)
2523

2624
// MainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on
@@ -52,21 +50,3 @@ var DiscoveryV5Bootnodes = []*discv5.Node{
5250
discv5.MustParseNode("enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30308"),
5351
discv5.MustParseNode("enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30309"),
5452
}
55-
56-
// MainnetChainConfig is the chain parameters to run a node on the main network.
57-
var MainnetChainConfig = &core.ChainConfig{
58-
HomesteadBlock: params.MainNetHomesteadBlock,
59-
DAOForkBlock: params.MainNetDAOForkBlock,
60-
DAOForkSupport: true,
61-
HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock,
62-
HomesteadGasRepriceHash: params.MainNetHomesteadGasRepriceHash,
63-
}
64-
65-
// TestnetChainConfig is the chain parameters to run a node on the test network.
66-
var TestnetChainConfig = &core.ChainConfig{
67-
HomesteadBlock: params.TestNetHomesteadBlock,
68-
DAOForkBlock: params.TestNetDAOForkBlock,
69-
DAOForkSupport: false,
70-
HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock,
71-
HomesteadGasRepriceHash: params.TestNetHomesteadGasRepriceHash,
72-
}

mobile/bind.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type signer struct {
3939
}
4040

4141
func (s *signer) Sign(addr *Address, tx *Transaction) (*Transaction, error) {
42-
sig, err := s.sign(addr.address, tx.tx)
42+
sig, err := s.sign(types.HomesteadSigner{}, addr.address, tx.tx)
4343
if err != nil {
4444
return nil, err
4545
}
@@ -89,7 +89,7 @@ func (opts *TransactOpts) GetGasLimit() int64 { return opts.opts.GasLimit.Int6
8989
func (opts *TransactOpts) SetFrom(from *Address) { opts.opts.From = from.address }
9090
func (opts *TransactOpts) SetNonce(nonce int64) { opts.opts.Nonce = big.NewInt(nonce) }
9191
func (opts *TransactOpts) SetSigner(s Signer) {
92-
opts.opts.Signer = func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
92+
opts.opts.Signer = func(signer types.Signer, addr common.Address, tx *types.Transaction) (*types.Transaction, error) {
9393
sig, err := s.Sign(&Address{addr}, &Transaction{tx})
9494
if err != nil {
9595
return nil, err

mobile/geth.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import (
2525
"path/filepath"
2626

2727
"github.com/ethereum/go-ethereum/common"
28-
"github.com/ethereum/go-ethereum/core"
2928
"github.com/ethereum/go-ethereum/core/state"
3029
"github.com/ethereum/go-ethereum/eth"
3130
"github.com/ethereum/go-ethereum/ethclient"
3231
"github.com/ethereum/go-ethereum/les"
3332
"github.com/ethereum/go-ethereum/light"
3433
"github.com/ethereum/go-ethereum/node"
3534
"github.com/ethereum/go-ethereum/p2p/nat"
35+
"github.com/ethereum/go-ethereum/params"
3636
"github.com/ethereum/go-ethereum/whisper/whisperv2"
3737
)
3838

@@ -129,12 +129,14 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) {
129129
// Register the Ethereum protocol if requested
130130
if config.EthereumEnabled {
131131
ethConf := &eth.Config{
132-
ChainConfig: &core.ChainConfig{
133-
HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock),
134-
DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock),
135-
DAOForkSupport: config.EthereumChainConfig.DAOForkSupport,
136-
HomesteadGasRepriceBlock: big.NewInt(config.EthereumChainConfig.HomesteadGasRepriceBlock),
137-
HomesteadGasRepriceHash: config.EthereumChainConfig.HomesteadGasRepriceHash.hash,
132+
ChainConfig: &params.ChainConfig{
133+
HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock),
134+
DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock),
135+
DAOForkSupport: config.EthereumChainConfig.DAOForkSupport,
136+
EIP150Block: big.NewInt(config.EthereumChainConfig.EIP150Block),
137+
EIP150Hash: config.EthereumChainConfig.EIP150Hash.hash,
138+
EIP155Block: big.NewInt(config.EthereumChainConfig.EIP155Block),
139+
EIP158Block: big.NewInt(config.EthereumChainConfig.EIP158Block),
138140
},
139141
Genesis: config.EthereumGenesis,
140142
LightMode: true,

mobile/core.go renamed to mobile/params.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
// Contains all the wrappers from the core package.
17+
// Contains all the wrappers from the params package.
1818

1919
package geth
2020

@@ -26,11 +26,13 @@ import (
2626
// MainnetChainConfig returns the chain configurations for the main Ethereum network.
2727
func MainnetChainConfig() *ChainConfig {
2828
return &ChainConfig{
29-
HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
30-
DAOForkBlock: params.MainNetDAOForkBlock.Int64(),
31-
DAOForkSupport: true,
32-
HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock.Int64(),
33-
HomesteadGasRepriceHash: Hash{params.MainNetHomesteadGasRepriceHash},
29+
HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
30+
DAOForkBlock: params.MainNetDAOForkBlock.Int64(),
31+
DAOForkSupport: true,
32+
EIP150Block: params.MainNetHomesteadGasRepriceBlock.Int64(),
33+
EIP150Hash: Hash{params.MainNetHomesteadGasRepriceHash},
34+
EIP155Block: params.MainNetSpuriousDragon.Int64(),
35+
EIP158Block: params.MainNetSpuriousDragon.Int64(),
3436
}
3537
}
3638

@@ -43,11 +45,13 @@ func MainnetGenesis() string {
4345
// TestnetChainConfig returns the chain configurations for the Ethereum test network.
4446
func TestnetChainConfig() *ChainConfig {
4547
return &ChainConfig{
46-
HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
47-
DAOForkBlock: 0,
48-
DAOForkSupport: false,
49-
HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock.Int64(),
50-
HomesteadGasRepriceHash: Hash{params.TestNetHomesteadGasRepriceHash},
48+
HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
49+
DAOForkBlock: 0,
50+
DAOForkSupport: false,
51+
EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(),
52+
EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash},
53+
EIP155Block: params.TestNetSpuriousDragon.Int64(),
54+
EIP158Block: params.TestNetSpuriousDragon.Int64(),
5155
}
5256
}
5357

@@ -58,11 +62,13 @@ func TestnetGenesis() string {
5862

5963
// ChainConfig is the core config which determines the blockchain settings.
6064
type ChainConfig struct {
61-
HomesteadBlock int64 // Homestead switch block
62-
DAOForkBlock int64 // TheDAO hard-fork switch block
63-
DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork
64-
HomesteadGasRepriceBlock int64 // Homestead gas reprice switch block
65-
HomesteadGasRepriceHash Hash // Homestead gas reprice switch block hash
65+
HomesteadBlock int64 // Homestead switch block
66+
DAOForkBlock int64 // TheDAO hard-fork switch block
67+
DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork
68+
EIP150Block int64 // Homestead gas reprice switch block
69+
EIP150Hash Hash // Homestead gas reprice switch block hash
70+
EIP155Block int64 // Replay protection switch block
71+
EIP158Block int64 // Empty account pruning switch block
6672
}
6773

6874
// NewChainConfig creates a new chain configuration that transitions immediately

mobile/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ func (tx *Transaction) GetValue() *BigInt { return &BigInt{tx.tx.Value()} }
139139
func (tx *Transaction) GetNonce() int64 { return int64(tx.tx.Nonce()) }
140140

141141
func (tx *Transaction) GetHash() *Hash { return &Hash{tx.tx.Hash()} }
142-
func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash()} }
142+
func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash(types.HomesteadSigner{})} }
143143
func (tx *Transaction) GetCost() *BigInt { return &BigInt{tx.tx.Cost()} }
144144

145145
func (tx *Transaction) GetFrom() (*Address, error) {
146-
from, err := tx.tx.From()
146+
from, err := types.Sender(types.HomesteadSigner{}, tx.tx)
147147
return &Address{from}, err
148148
}
149149

@@ -155,7 +155,7 @@ func (tx *Transaction) GetTo() *Address {
155155
}
156156

157157
func (tx *Transaction) WithSignature(sig []byte) (*Transaction, error) {
158-
t, err := tx.tx.WithSignature(sig)
158+
t, err := tx.tx.WithSignature(types.HomesteadSigner{}, sig)
159159
return &Transaction{t}, err
160160
}
161161

params/config.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ import (
2222
"github.com/ethereum/go-ethereum/common"
2323
)
2424

25+
// MainnetChainConfig is the chain parameters to run a node on the main network.
26+
var MainnetChainConfig = &ChainConfig{
27+
HomesteadBlock: MainNetHomesteadBlock,
28+
DAOForkBlock: MainNetDAOForkBlock,
29+
DAOForkSupport: true,
30+
EIP150Block: MainNetHomesteadGasRepriceBlock,
31+
EIP150Hash: MainNetHomesteadGasRepriceHash,
32+
EIP155Block: MainNetSpuriousDragon,
33+
EIP158Block: MainNetSpuriousDragon,
34+
}
35+
36+
// TestnetChainConfig is the chain parameters to run a node on the test network.
37+
var TestnetChainConfig = &ChainConfig{
38+
HomesteadBlock: TestNetHomesteadBlock,
39+
DAOForkBlock: TestNetDAOForkBlock,
40+
DAOForkSupport: false,
41+
EIP150Block: TestNetHomesteadGasRepriceBlock,
42+
EIP150Hash: TestNetHomesteadGasRepriceHash,
43+
EIP155Block: TestNetSpuriousDragon,
44+
EIP158Block: TestNetSpuriousDragon,
45+
}
46+
2547
// ChainConfig is the core config which determines the blockchain settings.
2648
//
2749
// ChainConfig is stored in the database on a per block basis. This means

0 commit comments

Comments
 (0)