From baa7eb901ec74a47e8d6f85e4313f2b3980df727 Mon Sep 17 00:00:00 2001 From: Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com> Date: Tue, 19 Jun 2018 14:35:59 +0300 Subject: [PATCH 1/5] mobile: correct comment typo in geth.go (#17021) --- mobile/geth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/geth.go b/mobile/geth.go index 645b360eb3..63ef062345 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -193,7 +193,7 @@ func (n *Node) Start() error { return n.node.Start() } -// Stop terminates a running node along with all it's services. In the node was +// Stop terminates a running node along with all it's services. If the node was // not started, an error is returned. func (n *Node) Stop() error { return n.node.Stop() From 3e57c33147bf05329dd9ef9868c04e301ac8bb58 Mon Sep 17 00:00:00 2001 From: Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com> Date: Tue, 19 Jun 2018 14:36:35 +0300 Subject: [PATCH 2/5] accounts/usbwallet: correct comment typo (#17008) --- accounts/usbwallet/ledger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index 7ad32dd1e8..2583fbc4da 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -302,7 +302,7 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction for i, component := range derivationPath { binary.BigEndian.PutUint32(path[1+4*i:], component) } - // Create the transaction RLP based on whether legacy or EIP155 signing was requeste + // Create the transaction RLP based on whether legacy or EIP155 signing was requested var ( txrlp []byte err error From 9b1536b26a78341008c5efe962f916d12220e720 Mon Sep 17 00:00:00 2001 From: Wenbiao Zheng Date: Tue, 19 Jun 2018 19:41:13 +0800 Subject: [PATCH 3/5] core: remove dead code, limit test code scope (#17006) * core: move test util var/func to test file * core: remove useless func --- core/blockchain_test.go | 34 ++++++++++++++++++++++++++++++++++ core/chain_makers.go | 33 --------------------------------- core/types/transaction.go | 9 --------- core/vm/memory_table.go | 6 ------ 4 files changed, 34 insertions(+), 48 deletions(-) diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 5dbf63d1d6..f409bb7b08 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -25,6 +25,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" @@ -35,6 +36,39 @@ import ( "github.com/ethereum/go-ethereum/params" ) +// So we can deterministically seed different blockchains +var ( + canonicalSeed = 1 + forkSeed = 2 +) + +// newCanonical creates a chain database, and injects a deterministic canonical +// chain. Depending on the full flag, if creates either a full block chain or a +// header only chain. +func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *BlockChain, error) { + var ( + db = ethdb.NewMemDatabase() + genesis = new(Genesis).MustCommit(db) + ) + + // Initialize a fresh chain with only a genesis block + blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}) + // Create and inject the requested chain + if n == 0 { + return db, blockchain, nil + } + if full { + // Full block-chain requested + blocks := makeBlockChain(genesis, n, engine, db, canonicalSeed) + _, err := blockchain.InsertChain(blocks) + return db, blockchain, err + } + // Header-only chain requested + headers := makeHeaderChain(genesis.Header(), n, engine, db, canonicalSeed) + _, err := blockchain.InsertHeaderChain(headers, 1) + return db, blockchain, err +} + // Test fork of length N starting from block i func testFork(t *testing.T, blockchain *BlockChain, i, n int, full bool, comparator func(td1, td2 *big.Int)) { // Copy old chain up to #i into a new db diff --git a/core/chain_makers.go b/core/chain_makers.go index fcba90bb87..c1e4b4264a 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -30,12 +30,6 @@ import ( "github.com/ethereum/go-ethereum/params" ) -// So we can deterministically seed different blockchains -var ( - canonicalSeed = 1 - forkSeed = 2 -) - // BlockGen creates blocks for testing. // See GenerateChain for a detailed explanation. type BlockGen struct { @@ -252,33 +246,6 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S } } -// newCanonical creates a chain database, and injects a deterministic canonical -// chain. Depending on the full flag, if creates either a full block chain or a -// header only chain. -func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *BlockChain, error) { - var ( - db = ethdb.NewMemDatabase() - genesis = new(Genesis).MustCommit(db) - ) - - // Initialize a fresh chain with only a genesis block - blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}) - // Create and inject the requested chain - if n == 0 { - return db, blockchain, nil - } - if full { - // Full block-chain requested - blocks := makeBlockChain(genesis, n, engine, db, canonicalSeed) - _, err := blockchain.InsertChain(blocks) - return db, blockchain, err - } - // Header-only chain requested - headers := makeHeaderChain(genesis.Header(), n, engine, db, canonicalSeed) - _, err := blockchain.InsertHeaderChain(headers, 1) - return db, blockchain, err -} - // makeHeaderChain creates a deterministic chain of headers rooted at parent. func makeHeaderChain(parent *types.Header, n int, engine consensus.Engine, db ethdb.Database, seed int) []*types.Header { blocks := makeBlockChain(types.NewBlockWithHeader(parent), n, engine, db, seed) diff --git a/core/types/transaction.go b/core/types/transaction.go index c1cb7a043a..b824a77f61 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -35,15 +35,6 @@ var ( ErrInvalidSig = errors.New("invalid transaction v, r, s values") ) -// deriveSigner makes a *best* guess about which signer to use. -func deriveSigner(V *big.Int) Signer { - if V.Sign() != 0 && isProtectedV(V) { - return NewEIP155Signer(deriveChainId(V)) - } else { - return HomesteadSigner{} - } -} - type Transaction struct { data txdata // caches diff --git a/core/vm/memory_table.go b/core/vm/memory_table.go index bec0235bcc..ab49ebb38b 100644 --- a/core/vm/memory_table.go +++ b/core/vm/memory_table.go @@ -65,12 +65,6 @@ func memoryCall(stack *Stack) *big.Int { return math.BigMax(x, y) } -func memoryCallCode(stack *Stack) *big.Int { - x := calcMemSize(stack.Back(5), stack.Back(6)) - y := calcMemSize(stack.Back(3), stack.Back(4)) - - return math.BigMax(x, y) -} func memoryDelegateCall(stack *Stack) *big.Int { x := calcMemSize(stack.Back(4), stack.Back(5)) y := calcMemSize(stack.Back(2), stack.Back(3)) From 28aca90716381d4a9110545432d128879c0a55b6 Mon Sep 17 00:00:00 2001 From: Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com> Date: Tue, 19 Jun 2018 14:43:20 +0300 Subject: [PATCH 4/5] accounts/usbwallet: correct comment typo (#16998) --- accounts/usbwallet/internal/trezor/trezor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/usbwallet/internal/trezor/trezor.go b/accounts/usbwallet/internal/trezor/trezor.go index 8ae9e726e4..80cc75efc4 100644 --- a/accounts/usbwallet/internal/trezor/trezor.go +++ b/accounts/usbwallet/internal/trezor/trezor.go @@ -36,7 +36,7 @@ func Type(msg proto.Message) uint16 { } // Name returns the friendly message type name of a specific protocol buffer -// type numbers. +// type number. func Name(kind uint16) string { name := MessageType_name[int32(kind)] if len(name) < 12 { From f1986f86f2229ea5ff587c65c9229a65f40bf591 Mon Sep 17 00:00:00 2001 From: Wenbiao Zheng Date: Tue, 19 Jun 2018 19:48:10 +0800 Subject: [PATCH 5/5] signer: remove useless errorWrapper (#17003) --- signer/core/api.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/signer/core/api.go b/signer/core/api.go index 1372646de0..9a2a49ccc6 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -189,15 +189,6 @@ type ( var ErrRequestDenied = errors.New("Request denied") -type errorWrapper struct { - msg string - err error -} - -func (ew errorWrapper) String() string { - return fmt.Sprintf("%s\n%s", ew.msg, ew.err) -} - // NewSignerAPI creates a new API that can be used for Account management. // ksLocation specifies the directory where to store the password protected private // key that is generated when a new Account is created.