mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
Merge branch 'master' of https://github.com/ethereum/go-ethereum
This commit is contained in:
commit
ba2a75c930
6 changed files with 158 additions and 75 deletions
14
.travis.yml
14
.travis.yml
|
|
@ -3,10 +3,11 @@ go_import_path: github.com/ethereum/go-ethereum
|
||||||
sudo: false
|
sudo: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
# These are the latest Go versions.
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: required
|
sudo: required
|
||||||
go: '1.10'
|
go: "1.10"
|
||||||
script:
|
script:
|
||||||
- sudo modprobe fuse
|
- sudo modprobe fuse
|
||||||
- sudo chmod 666 /dev/fuse
|
- sudo chmod 666 /dev/fuse
|
||||||
|
|
@ -27,10 +28,11 @@ matrix:
|
||||||
tags: true
|
tags: true
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
tag_name: "$TRAVIS_TAG"
|
tag_name: "$TRAVIS_TAG"
|
||||||
|
|
||||||
- os: osx
|
- os: osx
|
||||||
go: '1.10'
|
go: "1.10"
|
||||||
script:
|
script:
|
||||||
- unset -f cd
|
- unset -f cd # workaround for https://github.com/travis-ci/travis-ci/issues/8703
|
||||||
- brew update
|
- brew update
|
||||||
- brew install caskroom/cask/brew-cask
|
- brew install caskroom/cask/brew-cask
|
||||||
- brew cask install osxfuse
|
- brew cask install osxfuse
|
||||||
|
|
@ -50,12 +52,14 @@ matrix:
|
||||||
tags: true
|
tags: true
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
tag_name: "$TRAVIS_TAG"
|
tag_name: "$TRAVIS_TAG"
|
||||||
|
|
||||||
|
# This builder only tests code linters on latest version of Go
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
go: '1.10'
|
go: "1.10"
|
||||||
env:
|
env:
|
||||||
- lint
|
- lint
|
||||||
git:
|
git:
|
||||||
submodules: false
|
submodules: false # avoid cloning ethereum/tests
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go lint
|
- go run build/ci.go lint
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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[:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
78
whisper/whisperv6/api_test.go
Normal file
78
whisper/whisperv6/api_test.go
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue