From feb6620c346b62d938cfde4bd6677a1c680e29b2 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Thu, 7 Jun 2018 09:34:24 +0100 Subject: [PATCH 1/2] core: relax type requirement for bc in ApplyTransaction (#16901) --- core/state_processor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state_processor.go b/core/state_processor.go index 4dc58b9dea..8e238ce1f0 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -85,7 +85,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg // and uses the input parameters for its environment. It returns the receipt // for the transaction, gas used and an error if the transaction failed, // indicating the block was invalid. -func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, uint64, error) { +func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, uint64, error) { msg, err := tx.AsMessage(types.MakeSigner(config, header.Number)) if err != nil { return nil, 0, err From ea06da089264508601a9f967160b8c7f335071fa Mon Sep 17 00:00:00 2001 From: Sarlor Date: Thu, 7 Jun 2018 16:48:36 +0800 Subject: [PATCH 2/2] trie: avoid unnecessary slicing on shortnode decoding (#16917) optimization code --- trie/encoding.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trie/encoding.go b/trie/encoding.go index 221fa6d3aa..5f120de638 100644 --- a/trie/encoding.go +++ b/trie/encoding.go @@ -53,10 +53,9 @@ func hexToCompact(hex []byte) []byte { func compactToHex(compact []byte) []byte { base := keybytesToHex(compact) - base = base[:len(base)-1] - // apply terminator flag - if base[0] >= 2 { - base = append(base, 16) + // delete terminator flag + if base[0] < 2 { + base = base[:len(base)-1] } // apply odd flag chop := 2 - base[0]&1