Skip to content

Commit

Permalink
Merge branch 'dns-support' of https://github.com/prd-fox/quorum into …
Browse files Browse the repository at this point in the history
…dns-support
  • Loading branch information
prd-fox committed Nov 20, 2019
2 parents 5004609 + cd5dbc9 commit 1209968
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 22 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,17 @@ matrix:
sudo chown root:$USER /etc/fuse.conf
go run build/ci.go install
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
QUORUM_IGNORE_TEST_PACKAGES=github.com/ethereum/go-ethereum/swarm go run build/ci.go test -coverage $TEST_PACKAGES
QUORUM_IGNORE_TEST_PACKAGES=github.com/ethereum/go-ethereum/swarm,github.com/ethereum/go-ethereum/cmd/swarm go run build/ci.go test -coverage $TEST_PACKAGES
else
go run build/ci.go test -coverage $TEST_PACKAGES
fi
- if: tag IS blank
os: osx
osx_image: xcode9.2 # so we don't have to deal with Kernel Extension Consent UI which is never possible in CI
script:
- |
brew update
brew install caskroom/cask/brew-cask
brew cask install osxfuse
go run build/ci.go install
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
QUORUM_IGNORE_TEST_PACKAGES=github.com/ethereum/go-ethereum/swarm go run build/ci.go test -coverage $TEST_PACKAGES
QUORUM_IGNORE_TEST_PACKAGES=github.com/ethereum/go-ethereum/swarm,github.com/ethereum/go-ethereum/cmd/swarm go run build/ci.go test -coverage $TEST_PACKAGES
else
go run build/ci.go test -coverage $TEST_PACKAGES
fi
Expand All @@ -111,7 +107,6 @@ matrix:

- if: tag IS present
os: osx
osx_image: xcode9.2
env: OUTPUT_FILE=geth_${TRAVIS_TAG}_darwin_amd64.tar.gz
script:
- build/env.sh go run build/ci.go install ./cmd/geth
Expand Down
19 changes: 19 additions & 0 deletions cmd/geth/accountcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,24 @@ Passphrase: {{.InputLine "foobar"}}
}
}

func TestGethDoesntStartWithoutPrivateTransactionManagerVariableSet(t *testing.T) {
defer SetResetPrivateConfig("")()

datadir := tmpDatadirWithKeystore(t)
geth := runGeth(t,
"--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
geth.ExpectExit()

expectedText := "the PRIVATE_CONFIG environment variable must be specified for Quorum"
result := strings.TrimSpace(geth.StderrText())
if result != expectedText {
geth.Fatalf("bad stderr text. want '%s', got '%s'", expectedText, result)
}
}

func TestUnlockFlagWrongPassword(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
datadir := tmpDatadirWithKeystore(t)
geth := runGeth(t,
"--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
Expand Down Expand Up @@ -222,6 +239,7 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
}

func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
datadir := tmpDatadirWithKeystore(t)
geth := runGeth(t,
"--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
Expand Down Expand Up @@ -271,6 +289,7 @@ In order to avoid this warning, you need to remove the following duplicate key f
}

func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
geth := runGeth(t,
"--keystore", store, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
Expand Down
6 changes: 6 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,9 @@ func quorumValidateConsensus(stack *node.Node, isRaft bool) {
utils.Fatalf("Consensus not specified. Exiting!!")
}
}

// quorumValidatePrivateTransactionManager returns whether the "PRIVATE_CONFIG"
// environment variable is set
func quorumValidatePrivateTransactionManager() bool {
return os.Getenv("PRIVATE_CONFIG") != ""
}
12 changes: 12 additions & 0 deletions cmd/geth/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var genesis = `{
// Tests that a node embedded within a console can be started up properly and
// then terminated by closing the input stream.
func TestConsoleWelcome(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"

datadir := setupIstanbul(t)
Expand Down Expand Up @@ -107,6 +108,7 @@ at block: 0 ({{niltime}})

// Tests that a console can be attached to a running node via various means.
func TestIPCAttachWelcome(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
// Configure the instance for IPC attachement
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
var ipc string
Expand Down Expand Up @@ -134,6 +136,7 @@ func TestIPCAttachWelcome(t *testing.T) {
}

func TestHTTPAttachWelcome(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P

Expand All @@ -152,6 +155,7 @@ func TestHTTPAttachWelcome(t *testing.T) {
}

func TestWSAttachWelcome(t *testing.T) {
defer SetResetPrivateConfig("ignore")()
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P

Expand Down Expand Up @@ -231,3 +235,11 @@ func setupIstanbul(t *testing.T) string {

return datadir
}

func SetResetPrivateConfig(value string) func() {
existingValue := os.Getenv("PRIVATE_CONFIG")
os.Setenv("PRIVATE_CONFIG", value)
return func() {
os.Setenv("PRIVATE_CONFIG", existingValue)
}
}
6 changes: 6 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package main

import (
"errors"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -275,6 +276,11 @@ func geth(ctx *cli.Context) error {
if args := ctx.Args(); len(args) > 0 {
return fmt.Errorf("invalid command: %q", args[0])
}

if !quorumValidatePrivateTransactionManager() {
return errors.New("the PRIVATE_CONFIG environment variable must be specified for Quorum")
}

node := makeFullNode(ctx)
startNode(ctx, node)

Expand Down
6 changes: 6 additions & 0 deletions eth/api_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,12 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
default:
tracer = vm.NewStructLogger(config.LogConfig)
}

// Set the private state to public state if it is not a private message
if msg, ok := message.(core.PrivateMessage); !ok || !api.config.IsQuorum || !msg.IsPrivate() {
privateStateDb = statedb
}

// Run the transaction with tracing enabled.
vmenv := vm.NewEVM(vmctx, statedb, privateStateDb, api.config, vm.Config{Debug: true, Tracer: tracer})

Expand Down
2 changes: 1 addition & 1 deletion eth/fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func verifyImportEvent(t *testing.T, imported chan *types.Block, arrive bool) {
select {
case <-imported:
t.Fatalf("import invoked")
case <-time.After(10 * time.Millisecond):
case <-time.After(20 * time.Millisecond):
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion miner/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens
for i := 0; i < 2; i += 1 {
select {
case <-taskCh:
case <-time.NewTimer(time.Second).C:
case <-time.NewTimer(2 * time.Second).C:
t.Error("new task timeout")
}
}
Expand Down
7 changes: 5 additions & 2 deletions p2p/protocols/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,11 @@ func TestProtocolHook(t *testing.T) {
if !testHook.send {
t.Fatal("Expected a send message, but it is not")
}
if testHook.peer == nil || testHook.peer.ID() != tester.Nodes[0].ID() {
t.Fatal("Expected peer ID to be set correctly, but it is not")
if testHook.peer == nil {
t.Fatal("Expected peer to be set, is nil")
}
if peerId := testHook.peer.ID(); peerId != tester.Nodes[0].ID() && peerId != tester.Nodes[1].ID() {
t.Fatalf("Expected peer ID to be set correctly, but it is not (got %v, exp %v or %v", peerId, tester.Nodes[0].ID(), tester.Nodes[1].ID())
}
if testHook.size != 11 { //11 is the length of the encoded message
t.Fatalf("Expected size to be %d, but it is %d ", 1, testHook.size)
Expand Down
13 changes: 3 additions & 10 deletions private/constellation/constellation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ type Constellation struct {
}

var (
ErrConstellationIsntInit = errors.New("Constellation not in use")
errPrivateTransactionManagerNotUsed = errors.New("private transaction manager not in use")
)

func (g *Constellation) Send(data []byte, from string, to []string) (out []byte, err error) {
if g.isConstellationNotInUse {
return nil, ErrConstellationIsntInit
return nil, errPrivateTransactionManagerNotUsed
}
out, err = g.node.SendPayload(data, from, to)
if err != nil {
Expand All @@ -35,7 +35,7 @@ func (g *Constellation) Send(data []byte, from string, to []string) (out []byte,

func (g *Constellation) SendSignedTx(data []byte, to []string) (out []byte, err error) {
if g.isConstellationNotInUse {
return nil, ErrConstellationIsntInit
return nil, errPrivateTransactionManagerNotUsed
}
out, err = g.node.SendSignedPayload(data, to)
if err != nil {
Expand Down Expand Up @@ -109,10 +109,3 @@ func MustNew(path string) *Constellation {
}
return g
}

func MaybeNew(path string) *Constellation {
if path == "" {
return nil
}
return MustNew(path)
}
2 changes: 1 addition & 1 deletion trie/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ type cachedNode struct {
node node // Cached collapsed trie node, or raw rlp data
size uint16 // Byte size of the useful cached data

parents uint16 // Number of live nodes referencing this one
parents uint32 // Number of live nodes referencing this one
children map[common.Hash]uint16 // External children referenced by this node

flushPrev common.Hash // Previous node in the flush-list
Expand Down

0 comments on commit 1209968

Please sign in to comment.