Merge pull request #1 from jpmorganchase/master

Merge from upstream
This commit is contained in:
Peter Fox 2018-08-16 15:20:55 +01:00 committed by GitHub
commit 7821208a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# Quorum
<a href="https://quorumslack.azurewebsites.net" target="_blank" rel="noopener"><img title="Quorum Slack" src="https://quorumslack.azurewebsites.net/badge.svg" alt="Quorum Slack" /></a>
<a href="https://clh7rniov2.execute-api.us-east-1.amazonaws.com/Express/" target="_blank" rel="noopener"><img title="Quorum Slack" src="https://clh7rniov2.execute-api.us-east-1.amazonaws.com/Express/badge.svg" alt="Quorum Slack" /></a>
Quorum is an Ethereum-based distributed ledger protocol with transaction/contract privacy and new consensus mechanisms.
@ -128,6 +128,7 @@ Further documentation can be found in the [docs](docs/) folder and on the [wiki]
* [quorum-examples](https://github.com/jpmorganchase/quorum-examples): example quorum clusters
* [quorum-tools](https://github.com/jpmorganchase/quorum-tools): local cluster orchestration, and integration testing tool
* [Quorum Wiki](https://github.com/jpmorganchase/quorum/wiki)
* [Quorum Community Slack Inviter](https://clh7rniov2.execute-api.us-east-1.amazonaws.com/Express/): Quorum Slack community entry point
## Third Party Tools/Libraries

View File

@ -220,7 +220,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block
config: config,
chainconfig: chainconfig,
chain: chain,
signer: types.MakeSigner(chainconfig, new(big.Int)),
signer: types.NewEIP155Signer(chainconfig.ChainId),
pending: make(map[common.Address]*txList),
queue: make(map[common.Address]*txList),
beats: make(map[common.Address]time.Time),

View File

@ -32,6 +32,7 @@ import (
"time"
"io/ioutil"
"os"
"reflect"
)
// testTxPoolConfig is a transaction pool configuration without stateful disk
@ -1522,3 +1523,48 @@ func benchmarkPoolBatchInsert(b *testing.B, size int) {
pool.AddRemotes(batch)
}
}
//Checks that the EIP155 signer is assigned to the TxPool no matter the configuration, even invalid config
func TestEIP155SignerOnTxPool(t *testing.T) {
var flagtests = []struct {
name string
homesteadBlock *big.Int
eip155Block *big.Int
}{
{"hsnileip155nil", nil, nil},
{"hsnileip1550", nil, big.NewInt(0)},
{"hsnileip155100", nil, big.NewInt(100)},
{"hs0eip155nil", big.NewInt(0), nil},
{"hs0eip1550", big.NewInt(0), big.NewInt(0)},
{"hs0eip155100", big.NewInt(0), big.NewInt(100)},
{"hs100eip155nil", big.NewInt(100), nil},
{"hs100eip1550", big.NewInt(100), big.NewInt(0)},
{"hs100eip155100", big.NewInt(100), big.NewInt(100)},
}
for _, tt := range flagtests {
t.Run("", func(t *testing.T) {
db, _ := ethdb.NewMemDatabase()
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db))
blockchain := &testBlockChain{statedb, big.NewInt(1000000), new(event.Feed)}
chainconfig := &params.ChainConfig{
ChainId: big.NewInt(10),
HomesteadBlock: tt.homesteadBlock,
EIP150Block: big.NewInt(0),
EIP155Block: tt.eip155Block,
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
Ethash: new(params.EthashConfig),
}
pool := NewTxPool(testTxPoolConfig, chainconfig, blockchain)
if reflect.TypeOf(types.EIP155Signer{}) != reflect.TypeOf(pool.signer) {
t.Fail()
}
})
}
}

View File

@ -566,7 +566,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
from, _ := types.Sender(env.signer, tx)
// Check whether the tx is replay protected. If we're not in the EIP155 hf
// phase, start ignoring the sender until we do.
if tx.Protected() && !env.config.IsEIP155(env.header.Number) {
if tx.Protected() && !env.config.IsEIP155(env.header.Number) && !tx.IsPrivate() {
log.Trace("Ignoring reply protected transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block)
txs.Pop()

View File

@ -1,19 +1,30 @@
package constellation
import (
"errors"
"fmt"
"github.com/patrickmn/go-cache"
"os"
"path/filepath"
"strings"
"time"
"github.com/patrickmn/go-cache"
)
type Constellation struct {
node *Client
c *cache.Cache
node *Client
c *cache.Cache
isConstellationNotInUse bool
}
var (
ErrConstellationIsntInit = errors.New("Constellation not in use")
)
func (g *Constellation) Send(data []byte, from string, to []string) (out []byte, err error) {
if g.isConstellationNotInUse {
return nil, ErrConstellationIsntInit
}
out, err = g.node.SendPayload(data, from, to)
if err != nil {
return nil, err
@ -23,6 +34,9 @@ func (g *Constellation) Send(data []byte, from string, to []string) (out []byte,
}
func (g *Constellation) Receive(data []byte) ([]byte, error) {
if g.isConstellationNotInUse {
return nil, nil
}
if len(data) == 0 {
return data, nil
}
@ -47,7 +61,7 @@ func New(path string) (*Constellation, error) {
}
// We accept either the socket or a configuration file that points to
// a socket.
isSocket := info.Mode() & os.ModeSocket != 0
isSocket := info.Mode()&os.ModeSocket != 0
if !isSocket {
cfg, err := LoadConfig(path)
if err != nil {
@ -66,10 +80,18 @@ func New(path string) (*Constellation, error) {
return &Constellation{
node: n,
c: cache.New(5*time.Minute, 5*time.Minute),
isConstellationNotInUse: false,
}, nil
}
func MustNew(path string) *Constellation {
if strings.EqualFold(path, "ignore") {
return &Constellation{
node: nil,
c: nil,
isConstellationNotInUse: true,
}
}
g, err := New(path)
if err != nil {
panic(fmt.Sprintf("MustNew: Failed to connect to Constellation (%s): %v", path, err))