This commit is contained in:
Ellaismer 2018-03-29 03:36:51 -04:00
commit ba2a75c930
6 changed files with 158 additions and 75 deletions

View file

@ -3,59 +3,63 @@ go_import_path: github.com/ethereum/go-ethereum
sudo: false sudo: false
matrix: matrix:
include: include:
- os: linux # These are the latest Go versions.
dist: trusty - os: linux
sudo: required dist: trusty
go: '1.10' sudo: required
script: go: "1.10"
- sudo modprobe fuse script:
- sudo chmod 666 /dev/fuse - sudo modprobe fuse
- sudo chown root:$USER /etc/fuse.conf - sudo chmod 666 /dev/fuse
- go run build/ci.go install - sudo chown root:$USER /etc/fuse.conf
- go run build/ci.go test - go run build/ci.go install
before_deploy: - go run build/ci.go test
- sh build/deploy.sh before_deploy:
deploy: - sh build/deploy.sh
provider: releases deploy:
api_key: provider: releases
secure: Aynh6/R/IRY1rJtfAbwn/yaMISVIYhfbZF0IlOtPUrLpMvmA9jTU7paPYG7bzluKSJwPiwIkdKzYfrkoaqZ1O0CCJzyQZ2EURfm3PPTI8gtVi9CRV0XYVfbKzpLmDmWVu8cJ1sJ5Js/9Vyg1FVBJTBVjjKJ/gXI7JOj+joZvsRSdQvHnR+lpxo0UPPbzXIlpb3I1Wputk3QTvBzihcIuHXy+TBWvvW3ZNNUAh8n552cIAUIAmhjhE18IifstjgfHF1oPqMgBOTVjmQcn8965RQWV+rTsuB76Z79syyns4EFAXFd4vQlMShfYCXKLGjKp9SAq3zNDvdUlMLo1t6leD0PDEAu6bZxKbor1Yhh/OBLAftaF5DuFpEU/bH/YTqWPa1YjIJzUULuD9hkj4dhOfDkHWEOZ7B+FoQeP7zZ6RD2Cw98U8MzsvLl3UoyDJNxC/bR8nCJSkQlezNsGnIlmlH+SoGwn+yVdtF5dC7SPo5qgCq0r/f0P2YAKhiqt6CcmEvbmH0jyMIu7nUB0YIwlK7vu+kauV0dAHYqIkP8qVVt0AcMtNinoGHLng34+dLNcA49z44duaX3nIdxjUh2EuQINdsWsK3/ewCaJkpQxX+pnmtaoOUB05eD+0twa9In7k0RjP4RBcjGR281g18EE6lBGIUhKq/uEoJOOT3WAaq4= api_key:
file: multi-geth-$TRAVIS_OS_NAME.* secure: Aynh6/R/IRY1rJtfAbwn/yaMISVIYhfbZF0IlOtPUrLpMvmA9jTU7paPYG7bzluKSJwPiwIkdKzYfrkoaqZ1O0CCJzyQZ2EURfm3PPTI8gtVi9CRV0XYVfbKzpLmDmWVu8cJ1sJ5Js/9Vyg1FVBJTBVjjKJ/gXI7JOj+joZvsRSdQvHnR+lpxo0UPPbzXIlpb3I1Wputk3QTvBzihcIuHXy+TBWvvW3ZNNUAh8n552cIAUIAmhjhE18IifstjgfHF1oPqMgBOTVjmQcn8965RQWV+rTsuB76Z79syyns4EFAXFd4vQlMShfYCXKLGjKp9SAq3zNDvdUlMLo1t6leD0PDEAu6bZxKbor1Yhh/OBLAftaF5DuFpEU/bH/YTqWPa1YjIJzUULuD9hkj4dhOfDkHWEOZ7B+FoQeP7zZ6RD2Cw98U8MzsvLl3UoyDJNxC/bR8nCJSkQlezNsGnIlmlH+SoGwn+yVdtF5dC7SPo5qgCq0r/f0P2YAKhiqt6CcmEvbmH0jyMIu7nUB0YIwlK7vu+kauV0dAHYqIkP8qVVt0AcMtNinoGHLng34+dLNcA49z44duaX3nIdxjUh2EuQINdsWsK3/ewCaJkpQxX+pnmtaoOUB05eD+0twa9In7k0RjP4RBcjGR281g18EE6lBGIUhKq/uEoJOOT3WAaq4=
file_glob: true file: multi-geth-$TRAVIS_OS_NAME.*
draft: true file_glob: true
on: draft: true
repo: ellaism/multi-geth on:
tags: true repo: ellaism/multi-geth
skip_cleanup: true tags: true
tag_name: "$TRAVIS_TAG" skip_cleanup: true
- os: osx tag_name: "$TRAVIS_TAG"
go: '1.10'
script: - os: osx
- unset -f cd go: "1.10"
- brew update script:
- brew install caskroom/cask/brew-cask - unset -f cd # workaround for https://github.com/travis-ci/travis-ci/issues/8703
- brew cask install osxfuse - brew update
- go run build/ci.go install - brew install caskroom/cask/brew-cask
- go run build/ci.go test - brew cask install osxfuse
before_deploy: - go run build/ci.go install
- sh build/deploy.sh - go run build/ci.go test
deploy: before_deploy:
provider: releases - sh build/deploy.sh
api_key: deploy:
secure: Aynh6/R/IRY1rJtfAbwn/yaMISVIYhfbZF0IlOtPUrLpMvmA9jTU7paPYG7bzluKSJwPiwIkdKzYfrkoaqZ1O0CCJzyQZ2EURfm3PPTI8gtVi9CRV0XYVfbKzpLmDmWVu8cJ1sJ5Js/9Vyg1FVBJTBVjjKJ/gXI7JOj+joZvsRSdQvHnR+lpxo0UPPbzXIlpb3I1Wputk3QTvBzihcIuHXy+TBWvvW3ZNNUAh8n552cIAUIAmhjhE18IifstjgfHF1oPqMgBOTVjmQcn8965RQWV+rTsuB76Z79syyns4EFAXFd4vQlMShfYCXKLGjKp9SAq3zNDvdUlMLo1t6leD0PDEAu6bZxKbor1Yhh/OBLAftaF5DuFpEU/bH/YTqWPa1YjIJzUULuD9hkj4dhOfDkHWEOZ7B+FoQeP7zZ6RD2Cw98U8MzsvLl3UoyDJNxC/bR8nCJSkQlezNsGnIlmlH+SoGwn+yVdtF5dC7SPo5qgCq0r/f0P2YAKhiqt6CcmEvbmH0jyMIu7nUB0YIwlK7vu+kauV0dAHYqIkP8qVVt0AcMtNinoGHLng34+dLNcA49z44duaX3nIdxjUh2EuQINdsWsK3/ewCaJkpQxX+pnmtaoOUB05eD+0twa9In7k0RjP4RBcjGR281g18EE6lBGIUhKq/uEoJOOT3WAaq4= provider: releases
file: multi-geth-$TRAVIS_OS_NAME.* api_key:
file_glob: true secure: Aynh6/R/IRY1rJtfAbwn/yaMISVIYhfbZF0IlOtPUrLpMvmA9jTU7paPYG7bzluKSJwPiwIkdKzYfrkoaqZ1O0CCJzyQZ2EURfm3PPTI8gtVi9CRV0XYVfbKzpLmDmWVu8cJ1sJ5Js/9Vyg1FVBJTBVjjKJ/gXI7JOj+joZvsRSdQvHnR+lpxo0UPPbzXIlpb3I1Wputk3QTvBzihcIuHXy+TBWvvW3ZNNUAh8n552cIAUIAmhjhE18IifstjgfHF1oPqMgBOTVjmQcn8965RQWV+rTsuB76Z79syyns4EFAXFd4vQlMShfYCXKLGjKp9SAq3zNDvdUlMLo1t6leD0PDEAu6bZxKbor1Yhh/OBLAftaF5DuFpEU/bH/YTqWPa1YjIJzUULuD9hkj4dhOfDkHWEOZ7B+FoQeP7zZ6RD2Cw98U8MzsvLl3UoyDJNxC/bR8nCJSkQlezNsGnIlmlH+SoGwn+yVdtF5dC7SPo5qgCq0r/f0P2YAKhiqt6CcmEvbmH0jyMIu7nUB0YIwlK7vu+kauV0dAHYqIkP8qVVt0AcMtNinoGHLng34+dLNcA49z44duaX3nIdxjUh2EuQINdsWsK3/ewCaJkpQxX+pnmtaoOUB05eD+0twa9In7k0RjP4RBcjGR281g18EE6lBGIUhKq/uEoJOOT3WAaq4=
draft: true file: multi-geth-$TRAVIS_OS_NAME.*
on: file_glob: true
repo: ellaism/multi-geth draft: true
tags: true on:
skip_cleanup: true repo: ellaism/multi-geth
tag_name: "$TRAVIS_TAG" tags: true
- os: linux skip_cleanup: true
dist: trusty tag_name: "$TRAVIS_TAG"
go: '1.10'
env: # This builder only tests code linters on latest version of Go
- lint - os: linux
git: dist: trusty
submodules: false go: "1.10"
script: env:
- go run build/ci.go lint - lint
git:
submodules: false # avoid cloning ethereum/tests
script:
- go run build/ci.go lint

View file

@ -235,10 +235,10 @@ func (self *StateDB) GetCodeHash(addr common.Address) common.Hash {
return common.BytesToHash(stateObject.CodeHash()) return common.BytesToHash(stateObject.CodeHash())
} }
func (self *StateDB) GetState(a common.Address, b common.Hash) common.Hash { func (self *StateDB) GetState(addr common.Address, bhash common.Hash) common.Hash {
stateObject := self.getStateObject(a) stateObject := self.getStateObject(addr)
if stateObject != nil { if stateObject != nil {
return stateObject.GetState(self.db, b) return stateObject.GetState(self.db, bhash)
} }
return common.Hash{} return common.Hash{}
} }
@ -250,8 +250,8 @@ func (self *StateDB) Database() Database {
// StorageTrie returns the storage trie of an account. // StorageTrie returns the storage trie of an account.
// The return value is a copy and is nil for non-existent accounts. // The return value is a copy and is nil for non-existent accounts.
func (self *StateDB) StorageTrie(a common.Address) Trie { func (self *StateDB) StorageTrie(addr common.Address) Trie {
stateObject := self.getStateObject(a) stateObject := self.getStateObject(addr)
if stateObject == nil { if stateObject == nil {
return nil return nil
} }
@ -271,7 +271,7 @@ func (self *StateDB) HasSuicided(addr common.Address) bool {
* SETTERS * SETTERS
*/ */
// AddBalance adds amount to the account associated with addr // AddBalance adds amount to the account associated with addr.
func (self *StateDB) AddBalance(addr common.Address, amount *big.Int) { func (self *StateDB) AddBalance(addr common.Address, amount *big.Int) {
stateObject := self.GetOrNewStateObject(addr) stateObject := self.GetOrNewStateObject(addr)
if stateObject != nil { if stateObject != nil {
@ -279,7 +279,7 @@ func (self *StateDB) AddBalance(addr common.Address, amount *big.Int) {
} }
} }
// SubBalance subtracts amount from the account associated with addr // SubBalance subtracts amount from the account associated with addr.
func (self *StateDB) SubBalance(addr common.Address, amount *big.Int) { func (self *StateDB) SubBalance(addr common.Address, amount *big.Int) {
stateObject := self.GetOrNewStateObject(addr) stateObject := self.GetOrNewStateObject(addr)
if stateObject != nil { if stateObject != nil {
@ -308,7 +308,7 @@ func (self *StateDB) SetCode(addr common.Address, code []byte) {
} }
} }
func (self *StateDB) SetState(addr common.Address, key common.Hash, value common.Hash) { func (self *StateDB) SetState(addr common.Address, key, value common.Hash) {
stateObject := self.GetOrNewStateObject(addr) stateObject := self.GetOrNewStateObject(addr)
if stateObject != nil { if stateObject != nil {
stateObject.SetState(self.db, key, value) stateObject.SetState(self.db, key, value)
@ -337,7 +337,7 @@ func (self *StateDB) Suicide(addr common.Address) bool {
} }
// //
// Setting, updating & deleting state object methods // Setting, updating & deleting state object methods.
// //
// updateStateObject writes the given object to the trie. // updateStateObject writes the given object to the trie.
@ -388,7 +388,7 @@ func (self *StateDB) setStateObject(object *stateObject) {
self.stateObjects[object.Address()] = object self.stateObjects[object.Address()] = object
} }
// Retrieve a state object or create a new state object if nil // Retrieve a state object or create a new state object if nil.
func (self *StateDB) GetOrNewStateObject(addr common.Address) *stateObject { func (self *StateDB) GetOrNewStateObject(addr common.Address) *stateObject {
stateObject := self.getStateObject(addr) stateObject := self.getStateObject(addr)
if stateObject == nil || stateObject.deleted { if stateObject == nil || stateObject.deleted {

View file

@ -42,7 +42,7 @@ type Config struct {
} }
// Interpreter is used to run Ethereum based contracts and will utilise the // Interpreter is used to run Ethereum based contracts and will utilise the
// passed evmironment to query external sources for state information. // passed environment to query external sources for state information.
// The Interpreter will run the byte code VM based on the passed // The Interpreter will run the byte code VM based on the passed
// configuration. // configuration.
type Interpreter struct { type Interpreter struct {
@ -184,7 +184,7 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er
} }
} }
// consume the gas and return an error if not enough gas is available. // consume the gas and return an error if not enough gas is available.
// cost is explicitly set so that the capture state defer method cas get the proper cost // cost is explicitly set so that the capture state defer method can get the proper cost
cost, err = operation.gasCost(in.gasTable, in.evm, contract, stack, mem, memorySize) cost, err = operation.gasCost(in.gasTable, in.evm, contract, stack, mem, memorySize)
if err != nil || !contract.UseGas(cost) { if err != nil || !contract.UseGas(cost) {
return nil, ErrOutOfGas return nil, ErrOutOfGas

View file

@ -66,10 +66,10 @@ var (
ropstenCheckpoint = trustedCheckpoint{ ropstenCheckpoint = trustedCheckpoint{
name: "ropsten", name: "ropsten",
sectionIdx: 83, sectionIdx: 87,
sectionHead: common.HexToHash("3ca623586bc0da35f1fc8d9b6b55950f3b1f69be9c6501846a2df672adb61236"), sectionHead: common.HexToHash("ebc0adcb30ed21cbe95bd77499cc1af0bada621fee3644cb80dbcf1444c123fe"),
chtRoot: common.HexToHash("8f08ec7783969768c6ef06e5fe3398223cbf4ae2907b676da7b6fe6c7f55b059"), chtRoot: common.HexToHash("d9830f4893c821ddf149b8cb9d3e3bfe3109d2eea8e3c4a4ede7c8b2ee8a7800"),
bloomTrieRoot: common.HexToHash("02d86d3c6a87f8f8a92c2a59bbba2132ff6f9f61b0915a5dc28a9d8279219fd0"), bloomTrieRoot: common.HexToHash("c76e12d713f65b84c5a36d06bc77d0c8419248ea0b36e0812a78b76aa6da0ddb"),
} }
) )

View file

@ -558,9 +558,10 @@ func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error) {
} }
if len(req.Topics) > 0 { if len(req.Topics) > 0 {
topics = make([][]byte, 0, len(req.Topics)) topics = make([][]byte, len(req.Topics))
for _, topic := range req.Topics { for i, topic := range req.Topics {
topics = append(topics, topic[:]) topics[i] = make([]byte, TopicLength)
copy(topics[i], topic[:])
} }
} }

View file

@ -0,0 +1,78 @@
// Copyright 2018 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// 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/>.
package whisperv6
import (
"bytes"
"crypto/ecdsa"
"testing"
"time"
"github.com/ethereum/go-ethereum/common"
set "gopkg.in/fatih/set.v0"
)
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
w := &Whisper{
privateKeys: make(map[string]*ecdsa.PrivateKey),
symKeys: make(map[string][]byte),
envelopes: make(map[common.Hash]*Envelope),
expirations: make(map[uint32]*set.SetNonTS),
peers: make(map[*Peer]struct{}),
messageQueue: make(chan *Envelope, messageQueueLimit),
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
quit: make(chan struct{}),
syncAllowance: DefaultSyncAllowance,
}
w.filters = NewFilters(w)
keyID, err := w.GenerateSymKey()
if err != nil {
t.Fatalf("Error generating symmetric key: %v", err)
}
api := PublicWhisperAPI{
w: w,
lastUsed: make(map[string]time.Time),
}
t1 := [4]byte{0xde, 0xea, 0xbe, 0xef}
t2 := [4]byte{0xca, 0xfe, 0xde, 0xca}
crit := Criteria{
SymKeyID: keyID,
Topics: []TopicType{TopicType(t1), TopicType(t2)},
}
_, err = api.NewMessageFilter(crit)
if err != nil {
t.Fatalf("Error creating the filter: %v", err)
}
found := false
candidates := w.filters.getWatchersByTopic(TopicType(t1))
for _, f := range candidates {
if len(f.Topics) == 2 {
if bytes.Equal(f.Topics[0], t1[:]) && bytes.Equal(f.Topics[1], t2[:]) {
found = true
}
}
}
if !found {
t.Fatalf("Could not find filter with both topics")
}
}