diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-11-14 19:03:29 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-11-15 00:00:14 +0800 |
commit | 4a439c2359991bdc49463ae66da11da895cc6eb7 (patch) | |
tree | bb5ef79628597c67af9f13c2aa7ddcf59452d482 | |
parent | 4c16c82500645de83907743555e7256af86a9423 (diff) | |
download | go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.gz go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.bz2 go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.lz go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.xz go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.zst go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.zip |
mobile: port wrappers to EIP155 and EIP158 fork
-rw-r--r-- | cmd/utils/bootnodes.go | 20 | ||||
-rw-r--r-- | mobile/bind.go | 4 | ||||
-rw-r--r-- | mobile/geth.go | 16 | ||||
-rw-r--r-- | mobile/params.go (renamed from mobile/core.go) | 38 | ||||
-rw-r--r-- | mobile/types.go | 6 | ||||
-rw-r--r-- | params/config.go | 22 |
6 files changed, 58 insertions, 48 deletions
diff --git a/cmd/utils/bootnodes.go b/cmd/utils/bootnodes.go index 50b658467..07e64b25f 100644 --- a/cmd/utils/bootnodes.go +++ b/cmd/utils/bootnodes.go @@ -17,10 +17,8 @@ package utils import ( - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/discv5" - "github.com/ethereum/go-ethereum/params" ) // MainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on @@ -52,21 +50,3 @@ var DiscoveryV5Bootnodes = []*discv5.Node{ discv5.MustParseNode("enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30308"), discv5.MustParseNode("enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30309"), } - -// MainnetChainConfig is the chain parameters to run a node on the main network. -var MainnetChainConfig = &core.ChainConfig{ - HomesteadBlock: params.MainNetHomesteadBlock, - DAOForkBlock: params.MainNetDAOForkBlock, - DAOForkSupport: true, - HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock, - HomesteadGasRepriceHash: params.MainNetHomesteadGasRepriceHash, -} - -// TestnetChainConfig is the chain parameters to run a node on the test network. -var TestnetChainConfig = &core.ChainConfig{ - HomesteadBlock: params.TestNetHomesteadBlock, - DAOForkBlock: params.TestNetDAOForkBlock, - DAOForkSupport: false, - HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock, - HomesteadGasRepriceHash: params.TestNetHomesteadGasRepriceHash, -} diff --git a/mobile/bind.go b/mobile/bind.go index 79fb0e0e8..50adc6b0f 100644 --- a/mobile/bind.go +++ b/mobile/bind.go @@ -39,7 +39,7 @@ type signer struct { } func (s *signer) Sign(addr *Address, tx *Transaction) (*Transaction, error) { - sig, err := s.sign(addr.address, tx.tx) + sig, err := s.sign(types.HomesteadSigner{}, addr.address, tx.tx) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (opts *TransactOpts) GetGasLimit() int64 { return opts.opts.GasLimit.Int6 func (opts *TransactOpts) SetFrom(from *Address) { opts.opts.From = from.address } func (opts *TransactOpts) SetNonce(nonce int64) { opts.opts.Nonce = big.NewInt(nonce) } func (opts *TransactOpts) SetSigner(s Signer) { - opts.opts.Signer = func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { + opts.opts.Signer = func(signer types.Signer, addr common.Address, tx *types.Transaction) (*types.Transaction, error) { sig, err := s.Sign(&Address{addr}, &Transaction{tx}) if err != nil { return nil, err diff --git a/mobile/geth.go b/mobile/geth.go index 4d1f48ec3..d7f0800e0 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -25,7 +25,6 @@ import ( "path/filepath" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethclient" @@ -33,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/light" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/nat" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/whisper/whisperv2" ) @@ -129,12 +129,14 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { // Register the Ethereum protocol if requested if config.EthereumEnabled { ethConf := ð.Config{ - ChainConfig: &core.ChainConfig{ - HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock), - DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock), - DAOForkSupport: config.EthereumChainConfig.DAOForkSupport, - HomesteadGasRepriceBlock: big.NewInt(config.EthereumChainConfig.HomesteadGasRepriceBlock), - HomesteadGasRepriceHash: config.EthereumChainConfig.HomesteadGasRepriceHash.hash, + ChainConfig: ¶ms.ChainConfig{ + HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock), + DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock), + DAOForkSupport: config.EthereumChainConfig.DAOForkSupport, + EIP150Block: big.NewInt(config.EthereumChainConfig.EIP150Block), + EIP150Hash: config.EthereumChainConfig.EIP150Hash.hash, + EIP155Block: big.NewInt(config.EthereumChainConfig.EIP155Block), + EIP158Block: big.NewInt(config.EthereumChainConfig.EIP158Block), }, Genesis: config.EthereumGenesis, LightMode: true, diff --git a/mobile/core.go b/mobile/params.go index a49a4e660..bf0df7014 100644 --- a/mobile/core.go +++ b/mobile/params.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. -// Contains all the wrappers from the core package. +// Contains all the wrappers from the params package. package geth @@ -26,11 +26,13 @@ import ( // MainnetChainConfig returns the chain configurations for the main Ethereum network. func MainnetChainConfig() *ChainConfig { return &ChainConfig{ - HomesteadBlock: params.MainNetHomesteadBlock.Int64(), - DAOForkBlock: params.MainNetDAOForkBlock.Int64(), - DAOForkSupport: true, - HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock.Int64(), - HomesteadGasRepriceHash: Hash{params.MainNetHomesteadGasRepriceHash}, + HomesteadBlock: params.MainNetHomesteadBlock.Int64(), + DAOForkBlock: params.MainNetDAOForkBlock.Int64(), + DAOForkSupport: true, + EIP150Block: params.MainNetHomesteadGasRepriceBlock.Int64(), + EIP150Hash: Hash{params.MainNetHomesteadGasRepriceHash}, + EIP155Block: params.MainNetSpuriousDragon.Int64(), + EIP158Block: params.MainNetSpuriousDragon.Int64(), } } @@ -43,11 +45,13 @@ func MainnetGenesis() string { // TestnetChainConfig returns the chain configurations for the Ethereum test network. func TestnetChainConfig() *ChainConfig { return &ChainConfig{ - HomesteadBlock: params.TestNetHomesteadBlock.Int64(), - DAOForkBlock: 0, - DAOForkSupport: false, - HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock.Int64(), - HomesteadGasRepriceHash: Hash{params.TestNetHomesteadGasRepriceHash}, + HomesteadBlock: params.TestNetHomesteadBlock.Int64(), + DAOForkBlock: 0, + DAOForkSupport: false, + EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(), + EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash}, + EIP155Block: params.TestNetSpuriousDragon.Int64(), + EIP158Block: params.TestNetSpuriousDragon.Int64(), } } @@ -58,11 +62,13 @@ func TestnetGenesis() string { // ChainConfig is the core config which determines the blockchain settings. type ChainConfig struct { - HomesteadBlock int64 // Homestead switch block - DAOForkBlock int64 // TheDAO hard-fork switch block - DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork - HomesteadGasRepriceBlock int64 // Homestead gas reprice switch block - HomesteadGasRepriceHash Hash // Homestead gas reprice switch block hash + HomesteadBlock int64 // Homestead switch block + DAOForkBlock int64 // TheDAO hard-fork switch block + DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork + EIP150Block int64 // Homestead gas reprice switch block + EIP150Hash Hash // Homestead gas reprice switch block hash + EIP155Block int64 // Replay protection switch block + EIP158Block int64 // Empty account pruning switch block } // NewChainConfig creates a new chain configuration that transitions immediately diff --git a/mobile/types.go b/mobile/types.go index 8f54d36f0..bb5ccc625 100644 --- a/mobile/types.go +++ b/mobile/types.go @@ -139,11 +139,11 @@ func (tx *Transaction) GetValue() *BigInt { return &BigInt{tx.tx.Value()} } func (tx *Transaction) GetNonce() int64 { return int64(tx.tx.Nonce()) } func (tx *Transaction) GetHash() *Hash { return &Hash{tx.tx.Hash()} } -func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash()} } +func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash(types.HomesteadSigner{})} } func (tx *Transaction) GetCost() *BigInt { return &BigInt{tx.tx.Cost()} } func (tx *Transaction) GetFrom() (*Address, error) { - from, err := tx.tx.From() + from, err := types.Sender(types.HomesteadSigner{}, tx.tx) return &Address{from}, err } @@ -155,7 +155,7 @@ func (tx *Transaction) GetTo() *Address { } func (tx *Transaction) WithSignature(sig []byte) (*Transaction, error) { - t, err := tx.tx.WithSignature(sig) + t, err := tx.tx.WithSignature(types.HomesteadSigner{}, sig) return &Transaction{t}, err } diff --git a/params/config.go b/params/config.go index d63236ef8..d27973a32 100644 --- a/params/config.go +++ b/params/config.go @@ -22,6 +22,28 @@ import ( "github.com/ethereum/go-ethereum/common" ) +// MainnetChainConfig is the chain parameters to run a node on the main network. +var MainnetChainConfig = &ChainConfig{ + HomesteadBlock: MainNetHomesteadBlock, + DAOForkBlock: MainNetDAOForkBlock, + DAOForkSupport: true, + EIP150Block: MainNetHomesteadGasRepriceBlock, + EIP150Hash: MainNetHomesteadGasRepriceHash, + EIP155Block: MainNetSpuriousDragon, + EIP158Block: MainNetSpuriousDragon, +} + +// TestnetChainConfig is the chain parameters to run a node on the test network. +var TestnetChainConfig = &ChainConfig{ + HomesteadBlock: TestNetHomesteadBlock, + DAOForkBlock: TestNetDAOForkBlock, + DAOForkSupport: false, + EIP150Block: TestNetHomesteadGasRepriceBlock, + EIP150Hash: TestNetHomesteadGasRepriceHash, + EIP155Block: TestNetSpuriousDragon, + EIP158Block: TestNetSpuriousDragon, +} + // ChainConfig is the core config which determines the blockchain settings. // // ChainConfig is stored in the database on a per block basis. This means |