forked from cerc-io/plugeth
mobile: port wrappers to EIP155 and EIP158 fork
This commit is contained in:
parent
4c16c82500
commit
4a439c2359
@ -17,10 +17,8 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
|
||||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
"github.com/ethereum/go-ethereum/p2p/discover"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
"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
|
// 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://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30308"),
|
||||||
discv5.MustParseNode("enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30309"),
|
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,
|
|
||||||
}
|
|
||||||
|
@ -39,7 +39,7 @@ type signer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *signer) Sign(addr *Address, tx *Transaction) (*Transaction, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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) SetFrom(from *Address) { opts.opts.From = from.address }
|
||||||
func (opts *TransactOpts) SetNonce(nonce int64) { opts.opts.Nonce = big.NewInt(nonce) }
|
func (opts *TransactOpts) SetNonce(nonce int64) { opts.opts.Nonce = big.NewInt(nonce) }
|
||||||
func (opts *TransactOpts) SetSigner(s Signer) {
|
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})
|
sig, err := s.Sign(&Address{addr}, &Transaction{tx})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
@ -33,6 +32,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/light"
|
"github.com/ethereum/go-ethereum/light"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p/nat"
|
"github.com/ethereum/go-ethereum/p2p/nat"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/whisper/whisperv2"
|
"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
|
// Register the Ethereum protocol if requested
|
||||||
if config.EthereumEnabled {
|
if config.EthereumEnabled {
|
||||||
ethConf := ð.Config{
|
ethConf := ð.Config{
|
||||||
ChainConfig: &core.ChainConfig{
|
ChainConfig: ¶ms.ChainConfig{
|
||||||
HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock),
|
HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock),
|
||||||
DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock),
|
DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock),
|
||||||
DAOForkSupport: config.EthereumChainConfig.DAOForkSupport,
|
DAOForkSupport: config.EthereumChainConfig.DAOForkSupport,
|
||||||
HomesteadGasRepriceBlock: big.NewInt(config.EthereumChainConfig.HomesteadGasRepriceBlock),
|
EIP150Block: big.NewInt(config.EthereumChainConfig.EIP150Block),
|
||||||
HomesteadGasRepriceHash: config.EthereumChainConfig.HomesteadGasRepriceHash.hash,
|
EIP150Hash: config.EthereumChainConfig.EIP150Hash.hash,
|
||||||
|
EIP155Block: big.NewInt(config.EthereumChainConfig.EIP155Block),
|
||||||
|
EIP158Block: big.NewInt(config.EthereumChainConfig.EIP158Block),
|
||||||
},
|
},
|
||||||
Genesis: config.EthereumGenesis,
|
Genesis: config.EthereumGenesis,
|
||||||
LightMode: true,
|
LightMode: true,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// 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/>.
|
// 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
|
package geth
|
||||||
|
|
||||||
@ -26,11 +26,13 @@ import (
|
|||||||
// MainnetChainConfig returns the chain configurations for the main Ethereum network.
|
// MainnetChainConfig returns the chain configurations for the main Ethereum network.
|
||||||
func MainnetChainConfig() *ChainConfig {
|
func MainnetChainConfig() *ChainConfig {
|
||||||
return &ChainConfig{
|
return &ChainConfig{
|
||||||
HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
|
HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
|
||||||
DAOForkBlock: params.MainNetDAOForkBlock.Int64(),
|
DAOForkBlock: params.MainNetDAOForkBlock.Int64(),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock.Int64(),
|
EIP150Block: params.MainNetHomesteadGasRepriceBlock.Int64(),
|
||||||
HomesteadGasRepriceHash: Hash{params.MainNetHomesteadGasRepriceHash},
|
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.
|
// TestnetChainConfig returns the chain configurations for the Ethereum test network.
|
||||||
func TestnetChainConfig() *ChainConfig {
|
func TestnetChainConfig() *ChainConfig {
|
||||||
return &ChainConfig{
|
return &ChainConfig{
|
||||||
HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
|
HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
|
||||||
DAOForkBlock: 0,
|
DAOForkBlock: 0,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock.Int64(),
|
EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(),
|
||||||
HomesteadGasRepriceHash: Hash{params.TestNetHomesteadGasRepriceHash},
|
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.
|
// ChainConfig is the core config which determines the blockchain settings.
|
||||||
type ChainConfig struct {
|
type ChainConfig struct {
|
||||||
HomesteadBlock int64 // Homestead switch block
|
HomesteadBlock int64 // Homestead switch block
|
||||||
DAOForkBlock int64 // TheDAO hard-fork switch block
|
DAOForkBlock int64 // TheDAO hard-fork switch block
|
||||||
DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork
|
DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork
|
||||||
HomesteadGasRepriceBlock int64 // Homestead gas reprice switch block
|
EIP150Block int64 // Homestead gas reprice switch block
|
||||||
HomesteadGasRepriceHash Hash // Homestead gas reprice switch block hash
|
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
|
// NewChainConfig creates a new chain configuration that transitions immediately
|
@ -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) GetNonce() int64 { return int64(tx.tx.Nonce()) }
|
||||||
|
|
||||||
func (tx *Transaction) GetHash() *Hash { return &Hash{tx.tx.Hash()} }
|
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) GetCost() *BigInt { return &BigInt{tx.tx.Cost()} }
|
||||||
|
|
||||||
func (tx *Transaction) GetFrom() (*Address, error) {
|
func (tx *Transaction) GetFrom() (*Address, error) {
|
||||||
from, err := tx.tx.From()
|
from, err := types.Sender(types.HomesteadSigner{}, tx.tx)
|
||||||
return &Address{from}, err
|
return &Address{from}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ func (tx *Transaction) GetTo() *Address {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tx *Transaction) WithSignature(sig []byte) (*Transaction, error) {
|
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
|
return &Transaction{t}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,28 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"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 the core config which determines the blockchain settings.
|
||||||
//
|
//
|
||||||
// ChainConfig is stored in the database on a per block basis. This means
|
// ChainConfig is stored in the database on a per block basis. This means
|
||||||
|
Loading…
Reference in New Issue
Block a user