diff --git a/.travis.yml b/.travis.yml index 29566152c0..28d4c2ffa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,59 +3,63 @@ go_import_path: github.com/ethereum/go-ethereum sudo: false matrix: include: - - os: linux - dist: trusty - sudo: required - go: '1.10' - script: - - sudo modprobe fuse - - sudo chmod 666 /dev/fuse - - sudo chown root:$USER /etc/fuse.conf - - go run build/ci.go install - - go run build/ci.go test - before_deploy: - - sh build/deploy.sh - deploy: - provider: releases - api_key: - 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: multi-geth-$TRAVIS_OS_NAME.* - file_glob: true - draft: true - on: - repo: ellaism/multi-geth - tags: true - skip_cleanup: true - tag_name: "$TRAVIS_TAG" - - os: osx - go: '1.10' - script: - - unset -f cd - - brew update - - brew install caskroom/cask/brew-cask - - brew cask install osxfuse - - go run build/ci.go install - - go run build/ci.go test - before_deploy: - - sh build/deploy.sh - deploy: - provider: releases - api_key: - 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: multi-geth-$TRAVIS_OS_NAME.* - file_glob: true - draft: true - on: - repo: ellaism/multi-geth - tags: true - skip_cleanup: true - tag_name: "$TRAVIS_TAG" - - os: linux - dist: trusty - go: '1.10' - env: - - lint - git: - submodules: false - script: - - go run build/ci.go lint + # These are the latest Go versions. + - os: linux + dist: trusty + sudo: required + go: "1.10" + script: + - sudo modprobe fuse + - sudo chmod 666 /dev/fuse + - sudo chown root:$USER /etc/fuse.conf + - go run build/ci.go install + - go run build/ci.go test + before_deploy: + - sh build/deploy.sh + deploy: + provider: releases + api_key: + 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: multi-geth-$TRAVIS_OS_NAME.* + file_glob: true + draft: true + on: + repo: ellaism/multi-geth + tags: true + skip_cleanup: true + tag_name: "$TRAVIS_TAG" + + - os: osx + go: "1.10" + script: + - unset -f cd # workaround for https://github.com/travis-ci/travis-ci/issues/8703 + - brew update + - brew install caskroom/cask/brew-cask + - brew cask install osxfuse + - go run build/ci.go install + - go run build/ci.go test + before_deploy: + - sh build/deploy.sh + deploy: + provider: releases + api_key: + 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: multi-geth-$TRAVIS_OS_NAME.* + file_glob: true + draft: true + on: + repo: ellaism/multi-geth + tags: true + skip_cleanup: true + tag_name: "$TRAVIS_TAG" + + # This builder only tests code linters on latest version of Go + - os: linux + dist: trusty + go: "1.10" + env: + - lint + git: + submodules: false # avoid cloning ethereum/tests + script: + - go run build/ci.go lint diff --git a/core/state/statedb.go b/core/state/statedb.go index 5473ff8da7..bd67e789d5 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -235,10 +235,10 @@ func (self *StateDB) GetCodeHash(addr common.Address) common.Hash { return common.BytesToHash(stateObject.CodeHash()) } -func (self *StateDB) GetState(a common.Address, b common.Hash) common.Hash { - stateObject := self.getStateObject(a) +func (self *StateDB) GetState(addr common.Address, bhash common.Hash) common.Hash { + stateObject := self.getStateObject(addr) if stateObject != nil { - return stateObject.GetState(self.db, b) + return stateObject.GetState(self.db, bhash) } return common.Hash{} } @@ -250,8 +250,8 @@ func (self *StateDB) Database() Database { // StorageTrie returns the storage trie of an account. // The return value is a copy and is nil for non-existent accounts. -func (self *StateDB) StorageTrie(a common.Address) Trie { - stateObject := self.getStateObject(a) +func (self *StateDB) StorageTrie(addr common.Address) Trie { + stateObject := self.getStateObject(addr) if stateObject == nil { return nil } @@ -271,7 +271,7 @@ func (self *StateDB) HasSuicided(addr common.Address) bool { * 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) { stateObject := self.GetOrNewStateObject(addr) 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) { stateObject := self.GetOrNewStateObject(addr) 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) if stateObject != nil { 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. @@ -388,7 +388,7 @@ func (self *StateDB) setStateObject(object *stateObject) { 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 { stateObject := self.getStateObject(addr) if stateObject == nil || stateObject.deleted { diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 47d5e7f2fa..7090e0261f 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -42,7 +42,7 @@ type Config struct { } // 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 // configuration. 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. - // 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) if err != nil || !contract.UseGas(cost) { return nil, ErrOutOfGas diff --git a/light/postprocess.go b/light/postprocess.go index d67c5e2c3e..a1b1d9fb04 100644 --- a/light/postprocess.go +++ b/light/postprocess.go @@ -66,10 +66,10 @@ var ( ropstenCheckpoint = trustedCheckpoint{ name: "ropsten", - sectionIdx: 83, - sectionHead: common.HexToHash("3ca623586bc0da35f1fc8d9b6b55950f3b1f69be9c6501846a2df672adb61236"), - chtRoot: common.HexToHash("8f08ec7783969768c6ef06e5fe3398223cbf4ae2907b676da7b6fe6c7f55b059"), - bloomTrieRoot: common.HexToHash("02d86d3c6a87f8f8a92c2a59bbba2132ff6f9f61b0915a5dc28a9d8279219fd0"), + sectionIdx: 87, + sectionHead: common.HexToHash("ebc0adcb30ed21cbe95bd77499cc1af0bada621fee3644cb80dbcf1444c123fe"), + chtRoot: common.HexToHash("d9830f4893c821ddf149b8cb9d3e3bfe3109d2eea8e3c4a4ede7c8b2ee8a7800"), + bloomTrieRoot: common.HexToHash("c76e12d713f65b84c5a36d06bc77d0c8419248ea0b36e0812a78b76aa6da0ddb"), } ) diff --git a/whisper/whisperv6/api.go b/whisper/whisperv6/api.go index 96e2b17e7c..3f3a082afe 100644 --- a/whisper/whisperv6/api.go +++ b/whisper/whisperv6/api.go @@ -558,9 +558,10 @@ func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error) { } if len(req.Topics) > 0 { - topics = make([][]byte, 0, len(req.Topics)) - for _, topic := range req.Topics { - topics = append(topics, topic[:]) + topics = make([][]byte, len(req.Topics)) + for i, topic := range req.Topics { + topics[i] = make([]byte, TopicLength) + copy(topics[i], topic[:]) } } diff --git a/whisper/whisperv6/api_test.go b/whisper/whisperv6/api_test.go new file mode 100644 index 0000000000..004a41c949 --- /dev/null +++ b/whisper/whisperv6/api_test.go @@ -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 . + +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") + } +}