diff --git a/client/ws_client.go b/client/ws_client.go index 2f562927f6a99bb19852570f46b185f0e3da6c7b..f2542c1a477eacb27d12f4e8f0f563c8e530b891 100644 --- a/client/ws_client.go +++ b/client/ws_client.go @@ -3,8 +3,9 @@ package client import ( "fmt" - "github.com/gorilla/websocket" "net/http" + + "github.com/gorilla/websocket" ) // A websocket client subscribes and unsubscribes to events diff --git a/consensus/consensus.go b/consensus/consensus.go index 369210beeb285994dd42fffdd32305e055316713..fb0fdab34cdcdf0677cfe3b05d1c138e93549a5a 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -33,6 +33,7 @@ func LoadConsensusEngineInPipe(moduleConfig *config.ModuleConfig, if err != nil { return fmt.Errorf("Failed to load Tendermint node: %v", err) } + if err := pipe.SetConsensusEngine(tendermintNode); err != nil { return fmt.Errorf("Failed to hand Tendermint node to pipe: %v", err) } diff --git a/definitions/do.go b/definitions/do.go index 25966bdd48a66eb45ba7d6542b9633465b0089e9..f022aabbc2495d91933b0da38cbd39c4f0be4399 100644 --- a/definitions/do.go +++ b/definitions/do.go @@ -48,7 +48,7 @@ type Do struct { // Zip bool // Tarball bool DisableRpc bool - Config *viper.Viper + Config *viper.Viper // Accounts []*Account // Result string } diff --git a/event/event_cache.go b/event/event_cache.go index 2db266101e5b97e86bc0d09b919a6782f1f72ed5..fc73a197d395386292aae0f58315bbdc95ef59f3 100644 --- a/event/event_cache.go +++ b/event/event_cache.go @@ -4,8 +4,7 @@ import ( "fmt" "sync" "time" - - evts "github.com/tendermint/go-events" + "github.com/eris-ltd/eris-db/txs" ) var ( @@ -91,7 +90,7 @@ func (this *EventSubscriptions) Add(eventId string) (string, error) { } cache := newEventCache() errC := this.eventEmitter.Subscribe(subId, eventId, - func(evt evts.EventData) { + func(evt txs.EventData) { cache.mtx.Lock() defer cache.mtx.Unlock() cache.events = append(cache.events, evt) diff --git a/event/event_cache_test.go b/event/event_cache_test.go index 9240457184c53b0d410e6c3f07b3e93d524451e1..021c7e49abde4e2f9da79dbd8e50e7dff76dbd95 100644 --- a/event/event_cache_test.go +++ b/event/event_cache_test.go @@ -9,8 +9,8 @@ import ( "sync" + "github.com/eris-ltd/eris-db/txs" "github.com/stretchr/testify/assert" - evts "github.com/tendermint/go-events" ) var mockInterval = 10 * time.Millisecond @@ -18,7 +18,7 @@ var mockInterval = 10 * time.Millisecond type mockSub struct { subId string eventId string - f func(evts.EventData) + f func(txs.EventData) shutdown bool sdChan chan struct{} } @@ -29,7 +29,7 @@ type mockEventData struct { } // A mock event -func newMockSub(subId, eventId string, f func(evts.EventData)) mockSub { +func newMockSub(subId, eventId string, f func(txs.EventData)) mockSub { return mockSub{subId, eventId, f, false, make(chan struct{})} } @@ -42,7 +42,7 @@ func newMockEventEmitter() *mockEventEmitter { return &mockEventEmitter{make(map[string]mockSub), &sync.Mutex{}} } -func (this *mockEventEmitter) Subscribe(subId, eventId string, callback func(evts.EventData)) error { +func (this *mockEventEmitter) Subscribe(subId, eventId string, callback func(txs.EventData)) error { if _, ok := this.subs[subId]; ok { return nil } diff --git a/event/events.go b/event/events.go index b776c0debb87d11f54e3a39724d2ba09bdf0586c..fab369680988f7040b0b854407762299e63eb295 100644 --- a/event/events.go +++ b/event/events.go @@ -21,20 +21,29 @@ import ( "encoding/hex" "strings" - evts "github.com/tendermint/go-events" + "fmt" + + "github.com/eris-ltd/eris-db/txs" + log "github.com/eris-ltd/eris-logger" + go_events "github.com/tendermint/go-events" + tm_types "github.com/tendermint/tendermint/types" ) -// TODO improve -// TODO: [ben] yes please ^^^ -// [ben] To improve this we will switch out go-events with eris-db/event so -// that there is no need anymore for this poor wrapper. +// TODO: [Silas] this is a compatibility layer between our event types and +// TODO: go-events. Our ultimate plan is to replace go-events with our own pub-sub +// TODO: code that will better allow us to manage and multiplex events from different +// TODO: subsystems + +// Oh for a sum type +// We are using this as a marker interface for the +type anyEventData interface{} type EventEmitter interface { - Subscribe(subId, event string, callback func(evts.EventData)) error + Subscribe(subId, event string, callback func(txs.EventData)) error Unsubscribe(subId string) error } -func NewEvents(eventSwitch *evts.EventSwitch) *events { +func NewEvents(eventSwitch *go_events.EventSwitch) *events { return &events{eventSwitch} } @@ -47,12 +56,22 @@ func Multiplex(events ...EventEmitter) *multiplexedEvents { // The events struct has methods for working with events. type events struct { - eventSwitch *evts.EventSwitch + eventSwitch *go_events.EventSwitch } // Subscribe to an event. -func (this *events) Subscribe(subId, event string, callback func(evts.EventData)) error { - this.eventSwitch.AddListenerForEvent(subId, event, callback) +func (this *events) Subscribe(subId, event string, + callback func(txs.EventData)) error { + cb := func(evt go_events.EventData) { + eventData, err := mapToOurEventData(evt) + if err != nil { + log.WithError(err). + WithFields(log.Fields{"event": event}). + Error("Failed to map go-events EventData to our EventData") + } + callback(eventData) + } + this.eventSwitch.AddListenerForEvent(subId, event, cb) return nil } @@ -67,7 +86,8 @@ type multiplexedEvents struct { } // Subscribe to an event. -func (multiEvents *multiplexedEvents) Subscribe(subId, event string, callback func(evts.EventData)) error { +func (multiEvents *multiplexedEvents) Subscribe(subId, event string, + callback func(txs.EventData)) error { for _, eventEmitter := range multiEvents.eventEmitters { err := eventEmitter.Subscribe(subId, event, callback) if err != nil { @@ -118,5 +138,24 @@ func GenerateSubId() (string, error) { } rStr := hex.EncodeToString(b) return strings.ToUpper(rStr), nil +} +func mapToOurEventData(eventData anyEventData) (txs.EventData, error) { + // TODO: [Silas] avoid this with a better event pub-sub system of our own + // TODO: that maybe involves a registry of events + switch eventData := eventData.(type) { + case txs.EventData: + return eventData, nil + case tm_types.EventDataNewBlock: + return txs.EventDataNewBlock{ + Block: eventData.Block, + }, nil + case tm_types.EventDataNewBlockHeader: + return txs.EventDataNewBlockHeader{ + Header: eventData.Header, + }, nil + default: + return nil, fmt.Errorf("EventData not recognised as known EventData: %v", + eventData) + } } diff --git a/event/events_test.go b/event/events_test.go index 7fdf3e7bd245ed34c8fb96a11a7e3a33c612cde0..2927589e24f17c397326b97b62c27f2bbf49dd38 100644 --- a/event/events_test.go +++ b/event/events_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" evts "github.com/tendermint/go-events" + "github.com/eris-ltd/eris-db/txs" ) func TestMultiplexedEvents(t *testing.T) { @@ -15,25 +16,25 @@ func TestMultiplexedEvents(t *testing.T) { emitter2 := newMockEventEmitter() emitter12 := Multiplex(emitter1, emitter2) - eventData1 := make(map[evts.EventData]int) - eventData2 := make(map[evts.EventData]int) - eventData12 := make(map[evts.EventData]int) + eventData1 := make(map[txs.EventData]int) + eventData2 := make(map[txs.EventData]int) + eventData12 := make(map[txs.EventData]int) mutex1 := &sync.Mutex{} mutex2 := &sync.Mutex{} mutex12 := &sync.Mutex{} - emitter12.Subscribe("Sub12", "Event12", func(eventData evts.EventData) { + emitter12.Subscribe("Sub12", "Event12", func(eventData txs.EventData) { mutex12.Lock() eventData12[eventData] = 1 mutex12.Unlock() }) - emitter1.Subscribe("Sub1", "Event1", func(eventData evts.EventData) { + emitter1.Subscribe("Sub1", "Event1", func(eventData txs.EventData) { mutex1.Lock() eventData1[eventData] = 1 mutex1.Unlock() }) - emitter2.Subscribe("Sub2", "Event2", func(eventData evts.EventData) { + emitter2.Subscribe("Sub2", "Event2", func(eventData txs.EventData) { mutex2.Lock() eventData2[eventData] = 1 mutex2.Unlock() @@ -41,7 +42,7 @@ func TestMultiplexedEvents(t *testing.T) { time.Sleep(mockInterval) - allEventData := make(map[evts.EventData]int) + allEventData := make(map[txs.EventData]int) for k, v := range eventData1 { allEventData[k] = v } @@ -49,11 +50,11 @@ func TestMultiplexedEvents(t *testing.T) { allEventData[k] = v } - assert.Equal(t, map[evts.EventData]int{mockEventData{"Sub1", "Event1"}: 1}, + assert.Equal(t, map[txs.EventData]int{mockEventData{"Sub1", "Event1"}: 1}, eventData1) - assert.Equal(t, map[evts.EventData]int{mockEventData{"Sub2", "Event2"}: 1}, + assert.Equal(t, map[txs.EventData]int{mockEventData{"Sub2", "Event2"}: 1}, eventData2) - assert.Equal(t, map[evts.EventData]int{mockEventData{"Sub12", "Event12"}: 1}, + assert.Equal(t, map[txs.EventData]int{mockEventData{"Sub12", "Event12"}: 1}, eventData12) assert.NotEmpty(t, allEventData, "Some events should have been published") diff --git a/files/files_test.go b/files/files_test.go index 2d9cdc23ed1646f3acb242904015df3ba1418945..16943df7f53d6f5e899e89b26c224d68aa71705c 100644 --- a/files/files_test.go +++ b/files/files_test.go @@ -2,10 +2,11 @@ package files import ( "bytes" - "github.com/stretchr/testify/assert" "os" "path" "testing" + + "github.com/stretchr/testify/assert" ) var tempFolder = os.TempDir() diff --git a/manager/eris-mint/eris-mint.go b/manager/eris-mint/eris-mint.go index fb86908318454066ad3ba61f10d7e2cd2b49ed50..d15f75cdd766bfc1fb000de6b1f8e246b84922e3 100644 --- a/manager/eris-mint/eris-mint.go +++ b/manager/eris-mint/eris-mint.go @@ -138,8 +138,6 @@ func (app *ErisMint) AppendTx(txBytes []byte) (res tmsp.Result) { return tmsp.NewError(tmsp.CodeType_EncodingError, fmt.Sprintf("Encoding error: %v", err)) } - log.Info("AppendTx", "tx", *tx) - err = sm.ExecTx(app.cache, *tx, true, app.evc) if err != nil { return tmsp.NewError(tmsp.CodeType_InternalError, fmt.Sprintf("Internal error: %v", err)) @@ -161,8 +159,6 @@ func (app *ErisMint) CheckTx(txBytes []byte) (res tmsp.Result) { return tmsp.NewError(tmsp.CodeType_EncodingError, fmt.Sprintf("Encoding error: %v", err)) } - log.Info("CheckTx", "tx", *tx) - // TODO: make errors tmsp aware err = sm.ExecTx(app.checkCache, *tx, false, nil) if err != nil { diff --git a/manager/eris-mint/evm/native.go b/manager/eris-mint/evm/native.go index 55b18a167bdcf68e7642679437f06703ca72b6b8..860f99bd252a9037168765f2d6aa207cb1df806e 100644 --- a/manager/eris-mint/evm/native.go +++ b/manager/eris-mint/evm/native.go @@ -2,6 +2,7 @@ package vm import ( "crypto/sha256" + "golang.org/x/crypto/ripemd160" . "github.com/tendermint/go-common" diff --git a/manager/eris-mint/evm/opcodes.go b/manager/eris-mint/evm/opcodes.go index 87e09bfdd75bc0c78f86010928f497da0abede1a..63e6b297958f105ca45ae85e7dee3055fa52868d 100644 --- a/manager/eris-mint/evm/opcodes.go +++ b/manager/eris-mint/evm/opcodes.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "gopkg.in/fatih/set.v0" ) diff --git a/manager/eris-mint/evm/stack.go b/manager/eris-mint/evm/stack.go index 979aba2e3ceb1a8d3f61bf4d7935094619579ed8..3f3d727f1fb8e78eb63226ecd952e2f9981ff3f9 100644 --- a/manager/eris-mint/evm/stack.go +++ b/manager/eris-mint/evm/stack.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + . "github.com/tendermint/go-common" ) diff --git a/manager/eris-mint/pipe.go b/manager/eris-mint/pipe.go index 06dde2de3fa058778bf70e134eaa7f590e2d5ae5..00d955de8a48779f5a584b0acbfab78254344c3a 100644 --- a/manager/eris-mint/pipe.go +++ b/manager/eris-mint/pipe.go @@ -236,10 +236,11 @@ func (pipe *erisMintPipe) Subscribe(listenerId, event string, rpcResponseWriter func(result rpc_tm_types.ErisDBResult)) (*rpc_tm_types.ResultSubscribe, error) { log.WithFields(log.Fields{"listenerId": listenerId, "event": event}). Info("Subscribing to event") + pipe.consensusAndManagerEvents().Subscribe(subscriptionId(listenerId, event), event, - func(eventData go_events.EventData) { + func(eventData txs.EventData) { result := rpc_tm_types.ErisDBResult(&rpc_tm_types.ResultEvent{event, - tm_types.TMEventData(eventData)}) + txs.EventData(eventData)}) // NOTE: EventSwitch callbacks must be nonblocking rpcResponseWriter(result) }) diff --git a/manager/eris-mint/state/execution.go b/manager/eris-mint/state/execution.go index 54799c38b06213baeb36dad89750fb11f83d1769..34d8afd049e7ae8b3d0879aca10f445965807d52 100644 --- a/manager/eris-mint/state/execution.go +++ b/manager/eris-mint/state/execution.go @@ -279,6 +279,7 @@ func adjustByInputs(accounts map[string]*acm.Account, ins []*txs.TxInput) { PanicSanity("adjustByInputs() expects sufficient funds") } acc.Balance -= in.Amount + acc.Sequence += 1 } } @@ -413,6 +414,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable // Good! value := tx.Input.Amount - tx.Fee + inAcc.Sequence += 1 inAcc.Balance -= tx.Fee blockCache.UpdateAccount(inAcc) diff --git a/manager/eris-mint/transactor.go b/manager/eris-mint/transactor.go index e9882f77cbab3a9f10211a09d575ad78e7f14317..fd9201454549ffba46b7d77f1ddb393182ad8c68 100644 --- a/manager/eris-mint/transactor.go +++ b/manager/eris-mint/transactor.go @@ -207,12 +207,13 @@ func (this *transactor) TransactAndHold(privKey, address, data []byte, gasLimit, } wc := make(chan *txs.EventDataCall) subId := fmt.Sprintf("%X", rec.TxHash) - this.eventEmitter.Subscribe(subId, txs.EventStringAccCall(addr), func(evt tEvents.EventData) { - event := evt.(txs.EventDataCall) - if bytes.Equal(event.TxID, rec.TxHash) { - wc <- &event - } - }) + this.eventEmitter.Subscribe(subId, txs.EventStringAccCall(addr), + func(evt txs.EventData) { + event := evt.(txs.EventDataCall) + if bytes.Equal(event.TxID, rec.TxHash) { + wc <- &event + } + }) timer := time.NewTimer(300 * time.Second) toChan := timer.C diff --git a/permission/types/permissions.go b/permission/types/permissions.go index cca221f86a3feb63610e4a02f468bce616439eec..5cdcdaf8ca1e8ba4f5a2e605ed90f3521c757740 100644 --- a/permission/types/permissions.go +++ b/permission/types/permissions.go @@ -2,6 +2,7 @@ package types import ( "fmt" + . "github.com/tendermint/go-common" ) diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index bfafa4c2f9861f01192de0ad9b9aba05897d304d..f728d822bd1251f9147aaeac9e199672b7092d25 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -1,8 +1,9 @@ package rpc import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) // ... diff --git a/rpc/tendermint/core/routes.go b/rpc/tendermint/core/routes.go index c00d3f5579cb4d11a87935c65daafe3cb208c20c..02ffadfbf3a2bc07d1d5ce6ee5d565d2b677cd95 100644 --- a/rpc/tendermint/core/routes.go +++ b/rpc/tendermint/core/routes.go @@ -55,6 +55,12 @@ func (tmRoutes *TendermintRoutes) GetRoutes() map[string]*rpc.RPCFunc { func (tmRoutes *TendermintRoutes) Subscribe(wsCtx rpctypes.WSRPCContext, event string) (ctypes.ErisDBResult, error) { // NOTE: RPCResponses of subscribed events have id suffix "#event" + // TODO: we really ought to allow multiple subscriptions from the same client address + // to the same event. The code as it stands reflects the somewhat broken tendermint + // implementation. We can use GenerateSubId to randomize the subscriptions id + // and return it in the result. This would require clients to hang on to a + // subscription id if they wish to unsubscribe, but then again they can just + // drop their connection result, err := tmRoutes.tendermintPipe.Subscribe(wsCtx.GetRemoteAddr(), event, func(result ctypes.ErisDBResult) { // NOTE: EventSwitch callbacks must be nonblocking diff --git a/rpc/tendermint/core/types/responses.go b/rpc/tendermint/core/types/responses.go index 77ab79af0b4a7063c7fb3c108b03cfde3de6d164..179e26dab7afac286f0aa9b890276f29cb5f8813 100644 --- a/rpc/tendermint/core/types/responses.go +++ b/rpc/tendermint/core/types/responses.go @@ -124,8 +124,8 @@ type ResultSignTx struct { } type ResultEvent struct { - Event string `json:"event"` - Data types.TMEventData `json:"data"` + Event string `json:"event"` + Data txs.EventData `json:"data"` } //---------------------------------------- diff --git a/rpc/tendermint/test/client_ws_test.go b/rpc/tendermint/test/client_ws_test.go index f31d400bf88e9aa7831b45a068e1209c057b94a6..69153da425e711d7ef9ab9ab67b1af01b9db777c 100644 --- a/rpc/tendermint/test/client_ws_test.go +++ b/rpc/tendermint/test/client_ws_test.go @@ -28,10 +28,11 @@ func TestWSNewBlock(t *testing.T) { unsubscribe(t, wsc, eid) wsc.Stop() }() - waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b interface{}) error { - fmt.Println("Check:", string(b.([]byte))) - return nil - }) + waitForEvent(t, wsc, eid, true, func() {}, + func(eid string, eventData txs.EventData) error { + fmt.Println("Check: ", eventData.(txs.EventDataNewBlock).Block) + return nil + }) } // receive a few new block messages in a row, with increasing height @@ -47,7 +48,26 @@ func TestWSBlockchainGrowth(t *testing.T) { wsc.Stop() }() // listen for NewBlock, ensure height increases by 1 - unmarshalValidateBlockchain(t, wsc, eid) + var initBlockN int + for i := 0; i < 2; i++ { + waitForEvent(t, wsc, eid, true, func() {}, + func(eid string, eventData txs.EventData) error { + eventDataNewBlock, ok := eventData.(txs.EventDataNewBlock) + if !ok { + t.Fatalf("Was expecting EventDataNewBlock but got %v", eventData) + } + block := eventDataNewBlock.Block + if i == 0 { + initBlockN = block.Height + } else { + if block.Header.Height != initBlockN+i { + return fmt.Errorf("Expected block %d, got block %d", i, block.Header.Height) + } + } + + return nil + }) + } } // send a transaction and validate the events from listening for both sender and receiver @@ -90,12 +110,12 @@ func TestWSDoubleFire(t *testing.T) { waitForEvent(t, wsc, eid, true, func() { tx := makeDefaultSendTxSigned(t, wsTyp, toAddr, amt) broadcastTx(t, wsTyp, tx) - }, func(eid string, b interface{}) error { + }, func(eid string, b txs.EventData) error { return nil }) // but make sure we don't hear about it twice waitForEvent(t, wsc, eid, false, func() { - }, func(eid string, b interface{}) error { + }, func(eid string, b txs.EventData) error { return nil }) } @@ -200,7 +220,7 @@ func TestWSCallCall(t *testing.T) { // let the contract get created first waitForEvent(t, wsc, eid1, true, func() { - }, func(eid string, b interface{}) error { + }, func(eid string, b txs.EventData) error { return nil }) // call it diff --git a/rpc/tendermint/test/common.go b/rpc/tendermint/test/common.go index d9ef3230b0310592654f06e9030056f04e2ee2a3..b0d2f07eb76a8a0ff5123306b2d6b5746005489d 100644 --- a/rpc/tendermint/test/common.go +++ b/rpc/tendermint/test/common.go @@ -8,6 +8,7 @@ import ( // Needs to be in a _test.go file to be picked up func TestWrapper(runner func() int) int { ffs := fixtures.NewFileFixtures("Eris-DB") + defer ffs.RemoveAll() err := initGlobalVariables(ffs) @@ -28,10 +29,15 @@ func TestWrapper(runner func() int) int { return runner() } +// This main function exists as a little convenience mechanism for running the +// delve debugger which doesn't work well from go test yet. In due course it can +// be removed, but it's flux between pull requests should be considered +// inconsequential, so feel free to insert your own code if you want to use it +// as an application entry point for delve debugging. func DebugMain() { t := &testing.T{} TestWrapper(func() int { - testBroadcastTx(t, "HTTP") + testNameReg(t, "JSONRPC") return 0 }) } diff --git a/rpc/tendermint/test/genesis.go b/rpc/tendermint/test/genesis.go index 61cf2e6b1d9d588b3ffe428cdaaa6b10c8518fb9..3136a9339323cbfd1f5508daae335de335c9ef10 100644 --- a/rpc/tendermint/test/genesis.go +++ b/rpc/tendermint/test/genesis.go @@ -38,12 +38,3 @@ var defaultGenesis = `{ } ] }` - -var defaultPrivValidator = `{ - "address": "1D7A91CB32F758A02EBB9BE1FB6F8DEE56F90D42", - "pub_key": [1,"06FBAC4E285285D1D91FCBC7E91C780ADA11516F67462340B3980CE2B94940E8"], - "priv_key": [1,"C453604BD6480D5538B4C6FD2E3E314B5BCE518D75ADE4DA3DA85AB8ADFD819606FBAC4E285285D1D91FCBC7E91C780ADA11516F67462340B3980CE2B94940E8"], - "last_height":0, - "last_round":0, - "last_step":0 -}` diff --git a/rpc/tendermint/test/shared.go b/rpc/tendermint/test/shared.go index 13ab2570589fec8a1aee96b39e8c0b6c009fdfd7..2bcffc1f28d1cdf1024700be3216a020c8720437 100644 --- a/rpc/tendermint/test/shared.go +++ b/rpc/tendermint/test/shared.go @@ -17,10 +17,11 @@ import ( "github.com/tendermint/go-crypto" rpcclient "github.com/tendermint/go-rpc/client" + "path" + "github.com/spf13/viper" tm_common "github.com/tendermint/go-common" "github.com/tendermint/tendermint/types" - "path" ) // global variables for use across all tests @@ -101,23 +102,10 @@ func makeUsers(n int) []*acm.PrivAccount { return accounts } -// create a new node and sleep forever func newNode(ready chan error) { - // TODO: we don't need to start a V0 gateway this was added for debugging, remove - serverProcess, err := testCore.NewGatewayV0(config) - if err != nil { - ready <- err - } - - err = serverProcess.Start() - if err != nil { - ready <- err - } - - // Run the RPC servers - _, err = testCore.NewGatewayTendermint(config) + // Run the 'tendermint' rpc server + _, err := testCore.NewGatewayTendermint(config) ready <- err - <-serverProcess.StopEventChannel() } func saveNewPriv() { diff --git a/rpc/tendermint/test/tests.go b/rpc/tendermint/test/tests.go index 3f2646ea1f169ec622a22140963d35ef795c51ff..832534e9b0ec12f97f26470fa85f7900fadf5f78 100644 --- a/rpc/tendermint/test/tests.go +++ b/rpc/tendermint/test/tests.go @@ -12,7 +12,9 @@ import ( "golang.org/x/crypto/ripemd160" ) -var doNothing = func(eid string, b interface{}) error { return nil } +func doNothing(eventId string, eventData txs.EventData) error { + return nil +} func testStatus(t *testing.T, typ string) { client := clients[typ] @@ -30,7 +32,7 @@ func testStatus(t *testing.T, typ string) { func testGetAccount(t *testing.T, typ string) { acc := getAccount(t, typ, user[0].Address) if acc == nil { - t.Fatalf("Account was nil") + t.Fatal("Account was nil") } if bytes.Compare(acc.Address, user[0].Address) != 0 { t.Fatalf("Failed to get correct account. Got %x, expected %x", acc.Address, user[0].Address) @@ -192,9 +194,7 @@ func testNameReg(t *testing.T, typ string) { tx := makeDefaultNameTx(t, typ, name, data, amt, fee) broadcastTx(t, typ, tx) // verify the name by both using the event and by checking get_name - waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b interface{}) error { - // TODO: unmarshal the response - _ = b // TODO + waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b txs.EventData) error { // TODO: unmarshal thtxs.EventData _ = b // TODO tx, err := unmarshalResponseNameReg([]byte{}) if err != nil { return err diff --git a/rpc/tendermint/test/ws_helpers.go b/rpc/tendermint/test/ws_helpers.go index 9e6bc5ae41fc44896f76fbde97ac1e12f4359d33..76c624109634c60669930b0d450829131e5bbfff 100644 --- a/rpc/tendermint/test/ws_helpers.go +++ b/rpc/tendermint/test/ws_helpers.go @@ -8,7 +8,7 @@ import ( "time" ctypes "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" - txtypes "github.com/eris-ltd/eris-db/txs" + "github.com/eris-ltd/eris-db/txs" "github.com/tendermint/tendermint/types" "github.com/tendermint/go-events" @@ -18,7 +18,7 @@ import ( ) const ( - timeoutSeconds = 5 + timeoutSeconds = 2 ) //-------------------------------------------------------------------------------- @@ -49,9 +49,10 @@ func unsubscribe(t *testing.T, wsc *client.WSClient, eventid string) { // wait for an event; do things that might trigger events, and check them when they are received // the check function takes an event id and the byte slice read off the ws -func waitForEvent(t *testing.T, wsc *client.WSClient, eventid string, dieOnTimeout bool, f func(), check func(string, interface{}) error) { +func waitForEvent(t *testing.T, wsc *client.WSClient, eventid string, + dieOnTimeout bool, f func(), check func(string, txs.EventData) error) { // go routine to wait for webscoket msg - goodCh := make(chan interface{}) + goodCh := make(chan txs.EventData) errCh := make(chan error) // Read message @@ -131,7 +132,7 @@ func unmarshalResponseNewBlock(b []byte) (*types.Block, error) { return nil, nil } -func unmarshalResponseNameReg(b []byte) (*txtypes.NameTx, error) { +func unmarshalResponseNameReg(b []byte) (*txs.NameTx, error) { // unmarshall and assert somethings var response rpctypes.RPCResponse var err error @@ -143,48 +144,17 @@ func unmarshalResponseNameReg(b []byte) (*txtypes.NameTx, error) { return nil, fmt.Errorf(response.Error) } _, val := UnmarshalEvent(*response.Result) - tx := txtypes.DecodeTx(val.(types.EventDataTx).Tx).(*txtypes.NameTx) + tx := txs.DecodeTx(val.(types.EventDataTx).Tx).(*txs.NameTx) return tx, nil } -func unmarshalValidateBlockchain(t *testing.T, wsc *client.WSClient, eid string) { - var initBlockN int - for i := 0; i < 2; i++ { - waitForEvent(t, wsc, eid, true, func() {}, func(eid string, b interface{}) error { - block, err := unmarshalResponseNewBlock(b.([]byte)) - if err != nil { - return err - } - if i == 0 { - initBlockN = block.Header.Height - } else { - if block.Header.Height != initBlockN+i { - return fmt.Errorf("Expected block %d, got block %d", i, block.Header.Height) - } - } - - return nil - }) - } -} - -func unmarshalValidateSend(amt int64, toAddr []byte) func(string, interface{}) error { - return func(eid string, b interface{}) error { - // unmarshal and assert correctness - var response rpctypes.RPCResponse - var err error - wire.ReadJSON(&response, b.([]byte), &err) - if err != nil { - return err - } - if response.Error != "" { - return fmt.Errorf(response.Error) - } - event, val := UnmarshalEvent(*response.Result) - if eid != event { - return fmt.Errorf("Eventid is not correct. Got %s, expected %s", event, eid) +func unmarshalValidateSend(amt int64, toAddr []byte) func(string, txs.EventData) error { + return func(eid string, eventData txs.EventData) error { + var data = eventData.(txs.EventDataTx) + if data.Exception != "" { + return fmt.Errorf(data.Exception) } - tx := txtypes.DecodeTx(val.(types.EventDataTx).Tx).(*txtypes.SendTx) + tx := data.Tx.(*txs.SendTx) if !bytes.Equal(tx.Inputs[0].Address, user[0].Address) { return fmt.Errorf("Senders do not match up! Got %x, expected %x", tx.Inputs[0].Address, user[0].Address) } @@ -198,24 +168,13 @@ func unmarshalValidateSend(amt int64, toAddr []byte) func(string, interface{}) e } } -func unmarshalValidateTx(amt int64, returnCode []byte) func(string, interface{}) error { - return func(eid string, b interface{}) error { - // unmarshall and assert somethings - var response rpctypes.RPCResponse - var err error - wire.ReadJSON(&response, b.([]byte), &err) - if err != nil { - return err - } - if response.Error != "" { - return fmt.Errorf(response.Error) - } - _, val := UnmarshalEvent(*response.Result) - var data = val.(txtypes.EventDataTx) +func unmarshalValidateTx(amt int64, returnCode []byte) func(string, txs.EventData) error { + return func(eid string, eventData txs.EventData) error { + var data = eventData.(txs.EventDataTx) if data.Exception != "" { return fmt.Errorf(data.Exception) } - tx := data.Tx.(*txtypes.CallTx) + tx := data.Tx.(*txs.CallTx) if !bytes.Equal(tx.Input.Address, user[0].Address) { return fmt.Errorf("Senders do not match up! Got %x, expected %x", tx.Input.Address, user[0].Address) @@ -232,20 +191,9 @@ func unmarshalValidateTx(amt int64, returnCode []byte) func(string, interface{}) } } -func unmarshalValidateCall(origin, returnCode []byte, txid *[]byte) func(string, interface{}) error { - return func(eid string, b interface{}) error { - // unmarshall and assert somethings - var response rpctypes.RPCResponse - var err error - wire.ReadJSON(&response, b.([]byte), &err) - if err != nil { - return err - } - if response.Error != "" { - return fmt.Errorf(response.Error) - } - _, val := UnmarshalEvent(*response.Result) - var data = val.(txtypes.EventDataCall) +func unmarshalValidateCall(origin, returnCode []byte, txid *[]byte) func(string, txs.EventData) error { + return func(eid string, eventData txs.EventData) error { + var data = eventData.(txs.EventDataCall) if data.Exception != "" { return fmt.Errorf(data.Exception) } diff --git a/rpc/v0/wsService.go b/rpc/v0/wsService.go index 93e691dc20496e67ea0993a1d4513bbbbd0d0900..fdd48de0ed8f6a588fc3dd6e64f315328456cc8f 100644 --- a/rpc/v0/wsService.go +++ b/rpc/v0/wsService.go @@ -4,14 +4,13 @@ import ( "encoding/json" "fmt" - "github.com/tendermint/go-events" - log "github.com/eris-ltd/eris-logger" definitions "github.com/eris-ltd/eris-db/definitions" - event "github.com/eris-ltd/eris-db/event" + "github.com/eris-ltd/eris-db/event" rpc "github.com/eris-ltd/eris-db/rpc" server "github.com/eris-ltd/eris-db/server" + "github.com/eris-ltd/eris-db/txs" ) // Used for ErisDb. Implements WebSocketService. @@ -69,7 +68,8 @@ func (this *ErisDbWsService) Process(msg []byte, session *server.WSSession) { } // Convenience method for writing error responses. -func (this *ErisDbWsService) writeError(msg, id string, code int, session *server.WSSession) { +func (this *ErisDbWsService) writeError(msg, id string, code int, + session *server.WSSession) { response := rpc.NewRPCErrorResponse(id, code, msg) bts, err := this.codec.EncodeBytes(response) // If there's an error here all bets are off. @@ -80,7 +80,8 @@ func (this *ErisDbWsService) writeError(msg, id string, code int, session *serve } // Convenience method for writing responses. -func (this *ErisDbWsService) writeResponse(id string, result interface{}, session *server.WSSession) error { +func (this *ErisDbWsService) writeResponse(id string, result interface{}, + session *server.WSSession) error { response := rpc.NewRPCResponse(id, result) bts, err := this.codec.EncodeBytes(response) log.Debug("RESPONSE: %v\n", response) @@ -93,10 +94,12 @@ func (this *ErisDbWsService) writeResponse(id string, result interface{}, sessio // *************************************** Events ************************************ -func (this *ErisDbWsService) EventSubscribe(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbWsService) EventSubscribe(request *rpc.RPCRequest, + requester interface{}) (interface{}, int, error) { session, ok := requester.(*server.WSSession) if !ok { - return 0, rpc.INTERNAL_ERROR, fmt.Errorf("Passing wrong object to websocket events") + return 0, rpc.INTERNAL_ERROR, + fmt.Errorf("Passing wrong object to websocket events") } param := &EventIdParam{} err := this.codec.DecodeBytes(param, request.Params) @@ -109,7 +112,7 @@ func (this *ErisDbWsService) EventSubscribe(request *rpc.RPCRequest, requester i return nil, rpc.INTERNAL_ERROR, errSID } - callback := func(ret events.EventData) { + callback := func(ret txs.EventData) { this.writeResponse(subId, ret, session) } errC := this.pipe.Events().Subscribe(subId, eventId, callback) diff --git a/server/server_test.go b/server/server_test.go index 05d954b705fe5daf9980c7bd84d9b98dbb5c20b6..61569515529d3d9d650f018f2757cc0fc371cbe4 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -2,8 +2,9 @@ package server import ( //"fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) // Unit tests for server components goes here. Full-on client-server tests diff --git a/test/fixtures/file_fixtures.go b/test/fixtures/file_fixtures.go index 5935e54c20d7b9c4203f4a22680ff23ce6ee3a62..0e188762085e0bb14d3d011fcb0fb5ad442773ed 100644 --- a/test/fixtures/file_fixtures.go +++ b/test/fixtures/file_fixtures.go @@ -1,9 +1,10 @@ package fixtures import ( - "github.com/docker/docker/pkg/ioutils" "os" "path" + + "github.com/docker/docker/pkg/ioutils" ) // FileFixtures writes files to a temporary location for use in testing. @@ -25,6 +26,12 @@ func NewFileFixtures(identifyingPrefix string) *FileFixtures { } } +// Returns the root temporary directory that this FileFixtures will populate and +// clear on RemoveAll() +func (ffs *FileFixtures) TempDir() string { + return ffs.tempDir +} + // Add a file relative to the FileFixtures tempDir using name for the relative // part of the path. func (ffs *FileFixtures) AddFile(name, content string) string { diff --git a/test/mock/pipe.go b/test/mock/pipe.go index 413e6e1a37f51b9b54b929cb950cfd339f240bcf..9410d073d6b5259a7e0c3ab43a91c696d4abed0b 100644 --- a/test/mock/pipe.go +++ b/test/mock/pipe.go @@ -2,17 +2,16 @@ package mock import ( "fmt" - - account "github.com/eris-ltd/eris-db/account" - core_types "github.com/eris-ltd/eris-db/core/types" - definitions "github.com/eris-ltd/eris-db/definitions" - event "github.com/eris-ltd/eris-db/event" + + account "github.com/eris-ltd/eris-db/account" + core_types "github.com/eris-ltd/eris-db/core/types" + definitions "github.com/eris-ltd/eris-db/definitions" + event "github.com/eris-ltd/eris-db/event" manager_types "github.com/eris-ltd/eris-db/manager/types" td "github.com/eris-ltd/eris-db/test/testdata/testdata" - types "github.com/eris-ltd/eris-db/txs" + "github.com/eris-ltd/eris-db/txs" - evts "github.com/tendermint/go-events" mintTypes "github.com/tendermint/tendermint/types" ) @@ -182,7 +181,7 @@ type eventer struct { testData *td.TestData } -func (this *eventer) Subscribe(subId, event string, callback func(evts.EventData)) error { +func (this *eventer) Subscribe(subId, event string, callback func(txs.EventData)) error { return nil } @@ -250,37 +249,37 @@ func (this *transactor) CallCode(from, code, data []byte) (*core_types.Call, err return this.testData.CallCode.Output, nil } -func (this *transactor) BroadcastTx(tx types.Tx) (*types.Receipt, error) { +func (this *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { return nil, nil } -func (this *transactor) UnconfirmedTxs() (*types.UnconfirmedTxs, error) { +func (this *transactor) UnconfirmedTxs() (*txs.UnconfirmedTxs, error) { return this.testData.GetUnconfirmedTxs.Output, nil } -func (this *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*types.Receipt, error) { +func (this *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) { if address == nil || len(address) == 0 { return this.testData.TransactCreate.Output, nil } return this.testData.Transact.Output, nil } -func (this *transactor) TransactAndHold(privKey, address, data []byte, gasLimit, fee int64) (*types.EventDataCall, error) { +func (this *transactor) TransactAndHold(privKey, address, data []byte, gasLimit, fee int64) (*txs.EventDataCall, error) { return nil, nil } -func (this *transactor) Send(privKey, toAddress []byte, amount int64) (*types.Receipt, error) { +func (this *transactor) Send(privKey, toAddress []byte, amount int64) (*txs.Receipt, error) { return nil, nil } -func (this *transactor) SendAndHold(privKey, toAddress []byte, amount int64) (*types.Receipt, error) { +func (this *transactor) SendAndHold(privKey, toAddress []byte, amount int64) (*txs.Receipt, error) { return nil, nil } -func (this *transactor) TransactNameReg(privKey []byte, name, data string, amount, fee int64) (*types.Receipt, error) { +func (this *transactor) TransactNameReg(privKey []byte, name, data string, amount, fee int64) (*txs.Receipt, error) { return this.testData.TransactNameReg.Output, nil } -func (this *transactor) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) { +func (this *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (txs.Tx, error) { return nil, nil } diff --git a/test/server/http_burst_test.go b/test/server/http_burst_test.go index c2a1e89d501c6c0f5bfeb7fc3f03597d2f07330d..bb49275b7d82c5ee10a35fb162a79852e95833eb 100644 --- a/test/server/http_burst_test.go +++ b/test/server/http_burst_test.go @@ -2,10 +2,11 @@ package server import ( // "fmt" - "github.com/stretchr/testify/assert" "net/http" "testing" "time" + + "github.com/stretchr/testify/assert" ) const ( diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go index aef23a19a0a5e521212e8dc9aab01dc5afa16ddb..cb9e7af4f2037fdc52f4893f464c3436b406cff9 100644 --- a/test/server/ws_burst_test.go +++ b/test/server/ws_burst_test.go @@ -1,11 +1,12 @@ package server import ( + "testing" + "time" + "github.com/eris-ltd/eris-db/client" "github.com/eris-ltd/eris-db/server" "github.com/stretchr/testify/assert" - "testing" - "time" ) const CONNS uint16 = 100 diff --git a/test/testdata/helpers.go b/test/testdata/helpers.go index 2b2b2edbbe2bd7b4dd9d36c34d2e37bf5c228e55..127440f7eb185dcd360d13b9dc183c8983dc72ad 100644 --- a/test/testdata/helpers.go +++ b/test/testdata/helpers.go @@ -2,14 +2,16 @@ package testdata import ( "fmt" - "github.com/eris-ltd/eris-db/files" - "github.com/eris-ltd/eris-db/server" "os" "path" - . "github.com/tendermint/go-common" + "github.com/eris-ltd/eris-db/files" + "github.com/eris-ltd/eris-db/server" + stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" + . "github.com/tendermint/go-common" "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/types" ) const TendermintConfigDefault = `# This is a TOML config file. diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index 34c7c895bf9e32d94d066fdedbca54c2b21c6ddb..56894ecb5a55601ba90f8d542e458dfce66f7442 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -1,11 +1,11 @@ package testdata import ( - account "github.com/eris-ltd/eris-db/account" - core_types "github.com/eris-ltd/eris-db/core/types" - event "github.com/eris-ltd/eris-db/event" - rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0" - stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" + account "github.com/eris-ltd/eris-db/account" + core_types "github.com/eris-ltd/eris-db/core/types" + event "github.com/eris-ltd/eris-db/event" + stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" + rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0" transaction "github.com/eris-ltd/eris-db/txs" mintTypes "github.com/tendermint/tendermint/types" @@ -512,22 +512,22 @@ type ( GetAccountData struct { Input *rpc_v0.AddressParam `json:"input"` - Output *account.Account `json:"output"` + Output *account.Account `json:"output"` } GetAccountsData struct { - Input *rpc_v0.AccountsParam `json:"input"` - Output *core_types.AccountList `json:"output"` + Input *rpc_v0.AccountsParam `json:"input"` + Output *core_types.AccountList `json:"output"` } GetStorageData struct { Input *rpc_v0.AddressParam `json:"input"` - Output *core_types.Storage `json:"output"` + Output *core_types.Storage `json:"output"` } GetStorageAtData struct { - Input *rpc_v0.StorageAtParam `json:"input"` - Output *core_types.StorageItem `json:"output"` + Input *rpc_v0.StorageAtParam `json:"input"` + Output *core_types.StorageItem `json:"output"` } GenPrivAccountData struct { @@ -556,12 +556,12 @@ type ( GetBlockData struct { Input *rpc_v0.HeightParam `json:"input"` - Output *mintTypes.Block `json:"output"` + Output *mintTypes.Block `json:"output"` } GetBlocksData struct { - Input *rpc_v0.BlocksParam `json:"input"` - Output *core_types.Blocks `json:"output"` + Input *rpc_v0.BlocksParam `json:"input"` + Output *core_types.Blocks `json:"output"` } GetConsensusStateData struct { @@ -597,18 +597,18 @@ type ( } GetPeerData struct { - Input *rpc_v0.PeerParam `json:"input"` - Output *core_types.Peer `json:"output"` + Input *rpc_v0.PeerParam `json:"input"` + Output *core_types.Peer `json:"output"` } TransactData struct { Input *rpc_v0.TransactParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } TransactCreateData struct { Input *rpc_v0.TransactParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } GetUnconfirmedTxsData struct { @@ -617,36 +617,36 @@ type ( CallCodeData struct { Input *rpc_v0.CallCodeParam `json:"input"` - Output *core_types.Call `json:"output"` + Output *core_types.Call `json:"output"` } CallData struct { - Input *rpc_v0.CallParam `json:"input"` - Output *core_types.Call `json:"output"` + Input *rpc_v0.CallParam `json:"input"` + Output *core_types.Call `json:"output"` } EventSubscribeData struct { - Input *rpc_v0.EventIdParam `json:"input"` - Output *event.EventSub `json:"output"` + Input *rpc_v0.EventIdParam `json:"input"` + Output *event.EventSub `json:"output"` } EventUnsubscribeData struct { - Input *rpc_v0.SubIdParam `json:"input"` - Output *event.EventUnsub `json:"output"` + Input *rpc_v0.SubIdParam `json:"input"` + Output *event.EventUnsub `json:"output"` } TransactNameRegData struct { Input *rpc_v0.TransactNameRegParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } GetNameRegEntryData struct { Input *rpc_v0.NameRegEntryParam `json:"input"` - Output *core_types.NameRegEntry `json:"output"` + Output *core_types.NameRegEntry `json:"output"` } GetNameRegEntriesData struct { - Input *rpc_v0.FilterListParam `json:"input"` + Input *rpc_v0.FilterListParam `json:"input"` Output *core_types.ResultListNames `json:"output"` } diff --git a/txs/events.go b/txs/events.go index 14185c3a0cb7591a100feae2023df146aea8921c..f9c7e0ecd8c0fa41ccf005d3371d146bbc1a47d1 100644 --- a/txs/events.go +++ b/txs/events.go @@ -7,7 +7,7 @@ import ( . "github.com/tendermint/go-common" "github.com/tendermint/go-wire" - "github.com/tendermint/tendermint/types" // Block + tm_types "github.com/tendermint/tendermint/types" // Block ) // Functions to generate eventId strings @@ -43,9 +43,11 @@ const ( EventDataTypeTx = byte(0x03) EventDataTypeCall = byte(0x04) EventDataTypeLog = byte(0x05) + EventDataTypeNewBlockHeader = byte(0x06) EventDataTypeRoundState = byte(0x11) EventDataTypeVote = byte(0x12) + ) type EventData interface { @@ -54,6 +56,7 @@ type EventData interface { var _ = wire.RegisterInterface( struct{ EventData }{}, + wire.ConcreteType{EventDataNewBlockHeader{}, EventDataTypeNewBlockHeader}, wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock}, // wire.ConcreteType{EventDataFork{}, EventDataTypeFork }, wire.ConcreteType{EventDataTx{}, EventDataTypeTx}, @@ -67,7 +70,11 @@ var _ = wire.RegisterInterface( // but some (an input to a call tx or a receive) are more exotic type EventDataNewBlock struct { - Block *types.Block `json:"block"` + Block *tm_types.Block `json:"block"` +} + +type EventDataNewBlockHeader struct { + Header *tm_types.Header `json:"header"` } // All txs fire EventDataTx, but only CallTx might have Return or Exception @@ -107,27 +114,28 @@ type EventDataLog struct { type EventDataRoundState struct { CurrentTime time.Time `json:"current_time"` - Height int `json:"height"` - Round int `json:"round"` - Step string `json:"step"` - StartTime time.Time `json:"start_time"` - CommitTime time.Time `json:"commit_time"` - Proposal *types.Proposal `json:"proposal"` - ProposalBlock *types.Block `json:"proposal_block"` - LockedRound int `json:"locked_round"` - LockedBlock *types.Block `json:"locked_block"` - POLRound int `json:"pol_round"` + Height int `json:"height"` + Round int `json:"round"` + Step string `json:"step"` + StartTime time.Time `json:"start_time"` + CommitTime time.Time `json:"commit_time"` + Proposal *tm_types.Proposal `json:"proposal"` + ProposalBlock *tm_types.Block `json:"proposal_block"` + LockedRound int `json:"locked_round"` + LockedBlock *tm_types.Block `json:"locked_block"` + POLRound int `json:"pol_round"` } type EventDataVote struct { Index int Address []byte - Vote *types.Vote + Vote *tm_types.Vote } -func (_ EventDataNewBlock) AssertIsEventData() {} -func (_ EventDataTx) AssertIsEventData() {} -func (_ EventDataCall) AssertIsEventData() {} -func (_ EventDataLog) AssertIsEventData() {} -func (_ EventDataRoundState) AssertIsEventData() {} -func (_ EventDataVote) AssertIsEventData() {} +func (_ EventDataNewBlock) AssertIsEventData() {} +func (_ EventDataNewBlockHeader) AssertIsEventData() {} +func (_ EventDataTx) AssertIsEventData() {} +func (_ EventDataCall) AssertIsEventData() {} +func (_ EventDataLog) AssertIsEventData() {} +func (_ EventDataRoundState) AssertIsEventData() {} +func (_ EventDataVote) AssertIsEventData() {} diff --git a/txs/names.go b/txs/names.go index 657cdc15744781e86cb7d3844049a1f79c8141e1..1cc00e168c4b3dfce9cb1685969e645caf412d41 100644 --- a/txs/names.go +++ b/txs/names.go @@ -1,8 +1,9 @@ package txs import ( - core_types "github.com/eris-ltd/eris-db/core/types" "regexp" + + core_types "github.com/eris-ltd/eris-db/core/types" ) var ( diff --git a/txs/tx_utils.go b/txs/tx_utils.go index e697951091cfd0b0ce58c748b7e6bdb5c4aef5b9..cdc4be247762db25b3abccda6919b7f72f594751 100644 --- a/txs/tx_utils.go +++ b/txs/tx_utils.go @@ -2,6 +2,7 @@ package txs import ( "fmt" + acm "github.com/eris-ltd/eris-db/account" ptypes "github.com/eris-ltd/eris-db/permission/types"