2015-03-26 21:30:42 -07:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
"context"
|
2015-03-26 21:30:42 -07:00
|
|
|
"fmt"
|
2016-06-27 20:43:09 -04:00
|
|
|
"time"
|
|
|
|
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
2018-06-22 06:59:02 +02:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
2018-08-10 00:25:57 -05:00
|
|
|
cmn "github.com/tendermint/tendermint/libs/common"
|
2017-04-26 19:57:33 -04:00
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
2015-04-01 17:30:16 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2015-03-26 21:30:42 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-06-27 20:43:09 -04:00
|
|
|
// NOTE: tx should be signed, but this is only checked at the app level (not by Tendermint!)
|
2015-03-26 21:30:42 -07:00
|
|
|
|
2016-06-27 20:43:09 -04:00
|
|
|
// Returns right away, with no response
|
2017-06-01 16:09:30 +03:00
|
|
|
//
|
|
|
|
// ```shell
|
2018-06-12 02:25:52 -07:00
|
|
|
// curl 'localhost:26657/broadcast_tx_async?tx="123"'
|
2017-06-01 16:09:30 +03:00
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ```go
|
2018-06-12 02:25:52 -07:00
|
|
|
// client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket")
|
2017-06-01 16:09:30 +03:00
|
|
|
// result, err := client.BroadcastTxAsync("123")
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// > The above command returns JSON structured like this:
|
|
|
|
//
|
|
|
|
// ```json
|
|
|
|
// {
|
|
|
|
// "error": "",
|
|
|
|
// "result": {
|
|
|
|
// "hash": "E39AAB7A537ABAA237831742DCE1117F187C3C52",
|
|
|
|
// "log": "",
|
|
|
|
// "data": "",
|
|
|
|
// "code": 0
|
|
|
|
// },
|
|
|
|
// "id": "",
|
|
|
|
// "jsonrpc": "2.0"
|
|
|
|
// }
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ### Query Parameters
|
|
|
|
//
|
|
|
|
// | Parameter | Type | Default | Required | Description |
|
|
|
|
// |-----------+------+---------+----------+-----------------|
|
|
|
|
// | tx | Tx | nil | true | The transaction |
|
2016-02-08 00:48:58 -08:00
|
|
|
func BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
2016-10-14 21:36:42 -04:00
|
|
|
err := mempool.CheckTx(tx, nil)
|
2015-03-26 21:30:42 -07:00
|
|
|
if err != nil {
|
2015-03-28 23:10:05 -07:00
|
|
|
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
2017-04-21 18:39:02 +03:00
|
|
|
return &ctypes.ResultBroadcastTx{Hash: tx.Hash()}, nil
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
|
|
|
|
2017-06-01 16:09:30 +03:00
|
|
|
// Returns with the response from CheckTx.
|
|
|
|
//
|
|
|
|
// ```shell
|
2018-06-12 02:25:52 -07:00
|
|
|
// curl 'localhost:26657/broadcast_tx_sync?tx="456"'
|
2017-06-01 16:09:30 +03:00
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ```go
|
2018-06-12 02:25:52 -07:00
|
|
|
// client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket")
|
2017-06-01 16:09:30 +03:00
|
|
|
// result, err := client.BroadcastTxSync("456")
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// > The above command returns JSON structured like this:
|
|
|
|
//
|
|
|
|
// ```json
|
|
|
|
// {
|
|
|
|
// "jsonrpc": "2.0",
|
|
|
|
// "id": "",
|
|
|
|
// "result": {
|
|
|
|
// "code": 0,
|
|
|
|
// "data": "",
|
|
|
|
// "log": "",
|
|
|
|
// "hash": "0D33F2F03A5234F38706E43004489E061AC40A2E"
|
|
|
|
// },
|
|
|
|
// "error": ""
|
|
|
|
// }
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ### Query Parameters
|
|
|
|
//
|
|
|
|
// | Parameter | Type | Default | Required | Description |
|
|
|
|
// |-----------+------+---------+----------+-----------------|
|
|
|
|
// | tx | Tx | nil | true | The transaction |
|
2016-02-08 00:48:58 -08:00
|
|
|
func BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
2017-01-12 15:53:32 -05:00
|
|
|
resCh := make(chan *abci.Response, 1)
|
|
|
|
err := mempool.CheckTx(tx, func(res *abci.Response) {
|
2016-02-08 00:48:58 -08:00
|
|
|
resCh <- res
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
|
|
|
|
}
|
|
|
|
res := <-resCh
|
2016-05-14 12:33:27 -04:00
|
|
|
r := res.GetCheckTx()
|
2016-02-08 00:48:58 -08:00
|
|
|
return &ctypes.ResultBroadcastTx{
|
2016-05-14 12:33:27 -04:00
|
|
|
Code: r.Code,
|
|
|
|
Data: r.Data,
|
|
|
|
Log: r.Log,
|
2017-04-21 18:39:02 +03:00
|
|
|
Hash: tx.Hash(),
|
2016-02-08 00:48:58 -08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2016-08-27 16:37:52 -04:00
|
|
|
// CONTRACT: only returns error if mempool.BroadcastTx errs (ie. problem with the app)
|
2016-11-30 17:28:41 -05:00
|
|
|
// or if we timeout waiting for tx to commit.
|
2017-01-12 15:55:03 -05:00
|
|
|
// If CheckTx or DeliverTx fail, no error will be returned, but the returned result
|
2017-01-12 15:53:32 -05:00
|
|
|
// will contain a non-OK ABCI code.
|
2017-06-01 16:09:30 +03:00
|
|
|
//
|
|
|
|
// ```shell
|
2018-06-12 02:25:52 -07:00
|
|
|
// curl 'localhost:26657/broadcast_tx_commit?tx="789"'
|
2017-06-01 16:09:30 +03:00
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ```go
|
2018-06-12 02:25:52 -07:00
|
|
|
// client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket")
|
2017-06-01 16:09:30 +03:00
|
|
|
// result, err := client.BroadcastTxCommit("789")
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// > The above command returns JSON structured like this:
|
|
|
|
//
|
|
|
|
// ```json
|
|
|
|
// {
|
|
|
|
// "error": "",
|
|
|
|
// "result": {
|
|
|
|
// "height": 26682,
|
|
|
|
// "hash": "75CA0F856A4DA078FC4911580360E70CEFB2EBEE",
|
|
|
|
// "deliver_tx": {
|
|
|
|
// "log": "",
|
|
|
|
// "data": "",
|
|
|
|
// "code": 0
|
|
|
|
// },
|
|
|
|
// "check_tx": {
|
|
|
|
// "log": "",
|
|
|
|
// "data": "",
|
|
|
|
// "code": 0
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// "id": "",
|
|
|
|
// "jsonrpc": "2.0"
|
|
|
|
// }
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ### Query Parameters
|
|
|
|
//
|
|
|
|
// | Parameter | Type | Default | Required | Description |
|
|
|
|
// |-----------+------+---------+----------+-----------------|
|
|
|
|
// | tx | Tx | nil | true | The transaction |
|
2016-08-27 16:37:52 -04:00
|
|
|
func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
2016-06-27 20:43:09 -04:00
|
|
|
// subscribe to tx being committed in block
|
2017-11-15 01:42:15 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), subscribeTimeout)
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
defer cancel()
|
|
|
|
deliverTxResCh := make(chan interface{})
|
2017-11-15 15:07:08 -06:00
|
|
|
q := types.EventQueryTxFor(tx)
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
err := eventBus.Subscribe(ctx, "mempool", q, deliverTxResCh)
|
|
|
|
if err != nil {
|
|
|
|
err = errors.Wrap(err, "failed to subscribe to tx")
|
2017-11-02 13:12:40 -05:00
|
|
|
logger.Error("Error on broadcastTxCommit", "err", err)
|
|
|
|
return nil, fmt.Errorf("Error on broadcastTxCommit: %v", err)
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
}
|
|
|
|
defer eventBus.Unsubscribe(context.Background(), "mempool", q)
|
2016-06-27 20:43:09 -04:00
|
|
|
|
|
|
|
// broadcast the tx and register checktx callback
|
2017-01-12 15:53:32 -05:00
|
|
|
checkTxResCh := make(chan *abci.Response, 1)
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
err = mempool.CheckTx(tx, func(res *abci.Response) {
|
2016-06-27 20:43:09 -04:00
|
|
|
checkTxResCh <- res
|
|
|
|
})
|
|
|
|
if err != nil {
|
2017-11-02 13:12:40 -05:00
|
|
|
logger.Error("Error on broadcastTxCommit", "err", err)
|
|
|
|
return nil, fmt.Errorf("Error on broadcastTxCommit: %v", err)
|
2016-06-27 20:43:09 -04:00
|
|
|
}
|
|
|
|
checkTxRes := <-checkTxResCh
|
|
|
|
checkTxR := checkTxRes.GetCheckTx()
|
2017-12-02 01:47:55 -05:00
|
|
|
if checkTxR.Code != abci.CodeTypeOK {
|
2016-06-27 20:43:09 -04:00
|
|
|
// CheckTx failed!
|
2016-08-27 16:37:52 -04:00
|
|
|
return &ctypes.ResultBroadcastTxCommit{
|
2017-11-22 18:55:09 -06:00
|
|
|
CheckTx: *checkTxR,
|
|
|
|
DeliverTx: abci.ResponseDeliverTx{},
|
2017-04-21 18:39:02 +03:00
|
|
|
Hash: tx.Hash(),
|
2016-08-27 16:37:52 -04:00
|
|
|
}, nil
|
2016-06-27 20:43:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for the tx to be included in a block,
|
|
|
|
// timeout after something reasonable.
|
2017-05-20 21:43:00 -07:00
|
|
|
// TODO: configurable?
|
2016-11-30 17:28:41 -05:00
|
|
|
timer := time.NewTimer(60 * 2 * time.Second)
|
2016-06-27 20:43:09 -04:00
|
|
|
select {
|
new pubsub package
comment out failing consensus tests for now
rewrite rpc httpclient to use new pubsub package
import pubsub as tmpubsub, query as tmquery
make event IDs constants
EventKey -> EventTypeKey
rename EventsPubsub to PubSub
mempool does not use pubsub
rename eventsSub to pubsub
new subscribe API
fix channel size issues and consensus tests bugs
refactor rpc client
add missing discardFromChan method
add mutex
rename pubsub to eventBus
remove IsRunning from WSRPCConnection interface (not needed)
add a comment in broadcastNewRoundStepsAndVotes
rename registerEventCallbacks to broadcastNewRoundStepsAndVotes
See https://dave.cheney.net/2014/03/19/channel-axioms
stop eventBuses after reactor tests
remove unnecessary Unsubscribe
return subscribe helper function
move discardFromChan to where it is used
subscribe now returns an err
this gives us ability to refuse to subscribe if pubsub is at its max
capacity.
use context for control overflow
cache queries
handle err when subscribing in replay_test
rename testClientID to testSubscriber
extract var
set channel buffer capacity to 1 in replay_file
fix byzantine_test
unsubscribe from single event, not all events
refactor httpclient to return events to appropriate channels
return failing testReplayCrashBeforeWriteVote test
fix TestValidatorSetChanges
refactor code a bit
fix testReplayCrashBeforeWriteVote
add comment
fix TestValidatorSetChanges
fixes from Bucky's review
update comment [ci skip]
test TxEventBuffer
update changelog
fix TestValidatorSetChanges (2nd attempt)
only do wg.Done when no errors
benchmark event bus
create pubsub server inside NewEventBus
only expose config params (later if needed)
set buffer capacity to 0 so we are not testing cache
new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ}
This should allow to subscribe to all transactions! or a specific one
using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'"
use TimeoutCommit instead of afterPublishEventNewBlockTimeout
TimeoutCommit is the time a node waits after committing a block, before
it goes into the next height. So it will finish everything from the last
block, but then wait a bit. The idea is this gives it time to hear more
votes from other validators, to strengthen the commit it includes in the
next block. But it also gives it time to hear about new transactions.
waitForBlockWithUpdatedVals
rewrite WAL crash tests
Task:
test that we can recover from any WAL crash.
Solution:
the old tests were relying on event hub being run in the same thread (we
were injecting the private validator's last signature).
when considering a rewrite, we considered two possible solutions: write
a "fuzzy" testing system where WAL is crashing upon receiving a new
message, or inject failures and trigger them in tests using something
like https://github.com/coreos/gofail.
remove sleep
no cs.Lock around wal.Save
test different cases (empty block, non-empty block, ...)
comments
add comments
test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks
fixes as per Bucky's last review
reset subscriptions on UnsubscribeAll
use a simple counter to track message for which we panicked
also, set a smaller part size for all test cases
2017-06-26 19:00:30 +04:00
|
|
|
case deliverTxResMsg := <-deliverTxResCh:
|
2018-04-05 08:17:10 -07:00
|
|
|
deliverTxRes := deliverTxResMsg.(types.EventDataTx)
|
2016-06-27 20:43:09 -04:00
|
|
|
// The tx was included in a block.
|
2017-11-29 11:22:52 -06:00
|
|
|
deliverTxR := deliverTxRes.Result
|
2018-02-03 03:42:59 -05:00
|
|
|
logger.Info("DeliverTx passed ", "tx", cmn.HexBytes(tx), "response", deliverTxR)
|
2016-08-27 16:37:52 -04:00
|
|
|
return &ctypes.ResultBroadcastTxCommit{
|
2017-11-22 18:55:09 -06:00
|
|
|
CheckTx: *checkTxR,
|
|
|
|
DeliverTx: deliverTxR,
|
2017-04-21 18:39:02 +03:00
|
|
|
Hash: tx.Hash(),
|
2017-04-12 18:33:48 -04:00
|
|
|
Height: deliverTxRes.Height,
|
2016-06-27 20:43:09 -04:00
|
|
|
}, nil
|
|
|
|
case <-timer.C:
|
2017-05-02 11:53:32 +04:00
|
|
|
logger.Error("failed to include tx")
|
2016-08-27 16:37:52 -04:00
|
|
|
return &ctypes.ResultBroadcastTxCommit{
|
2017-11-22 18:55:09 -06:00
|
|
|
CheckTx: *checkTxR,
|
|
|
|
DeliverTx: abci.ResponseDeliverTx{},
|
2017-04-21 18:39:02 +03:00
|
|
|
Hash: tx.Hash(),
|
2016-06-27 20:43:09 -04:00
|
|
|
}, fmt.Errorf("Timed out waiting for transaction to be included in a block")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 11:31:35 +04:00
|
|
|
// Get unconfirmed transactions (maximum ?limit entries) including their number.
|
2017-06-01 16:09:30 +03:00
|
|
|
//
|
|
|
|
// ```shell
|
2018-06-12 02:25:52 -07:00
|
|
|
// curl 'localhost:26657/unconfirmed_txs'
|
2017-06-01 16:09:30 +03:00
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ```go
|
2018-06-12 02:25:52 -07:00
|
|
|
// client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket")
|
2017-06-01 16:09:30 +03:00
|
|
|
// result, err := client.UnconfirmedTxs()
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// > The above command returns JSON structured like this:
|
|
|
|
//
|
|
|
|
// ```json
|
|
|
|
// {
|
|
|
|
// "error": "",
|
|
|
|
// "result": {
|
|
|
|
// "txs": [],
|
|
|
|
// "n_txs": 0
|
|
|
|
// },
|
|
|
|
// "id": "",
|
|
|
|
// "jsonrpc": "2.0"
|
|
|
|
// }
|
2018-05-15 11:31:35 +04:00
|
|
|
//
|
|
|
|
// ### Query Parameters
|
|
|
|
//
|
|
|
|
// | Parameter | Type | Default | Required | Description |
|
|
|
|
// |-----------+------+---------+----------+--------------------------------------|
|
|
|
|
// | limit | int | 30 | false | Maximum number of entries (max: 100) |
|
2017-06-01 16:09:30 +03:00
|
|
|
// ```
|
2018-05-15 11:31:35 +04:00
|
|
|
func UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error) {
|
|
|
|
// reuse per_page validator
|
|
|
|
limit = validatePerPage(limit)
|
|
|
|
|
2018-08-08 16:03:58 +04:00
|
|
|
txs := mempool.ReapMaxTxs(limit)
|
2016-02-14 17:00:33 -08:00
|
|
|
return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil
|
2015-04-25 13:26:36 -07:00
|
|
|
}
|
2016-03-05 20:59:51 -05:00
|
|
|
|
2017-06-01 16:09:30 +03:00
|
|
|
// Get number of unconfirmed transactions.
|
|
|
|
//
|
|
|
|
// ```shell
|
2018-06-12 02:25:52 -07:00
|
|
|
// curl 'localhost:26657/num_unconfirmed_txs'
|
2017-06-01 16:09:30 +03:00
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// ```go
|
2018-06-12 02:25:52 -07:00
|
|
|
// client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket")
|
2017-06-01 16:09:30 +03:00
|
|
|
// result, err := client.UnconfirmedTxs()
|
|
|
|
// ```
|
|
|
|
//
|
|
|
|
// > The above command returns JSON structured like this:
|
|
|
|
//
|
|
|
|
// ```json
|
|
|
|
// {
|
|
|
|
// "error": "",
|
|
|
|
// "result": {
|
|
|
|
// "txs": null,
|
|
|
|
// "n_txs": 0
|
|
|
|
// },
|
|
|
|
// "id": "",
|
|
|
|
// "jsonrpc": "2.0"
|
|
|
|
// }
|
|
|
|
// ```
|
2016-03-05 20:59:51 -05:00
|
|
|
func NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error) {
|
2016-10-14 21:36:42 -04:00
|
|
|
return &ctypes.ResultUnconfirmedTxs{N: mempool.Size()}, nil
|
2016-03-05 20:59:51 -05:00
|
|
|
}
|