Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
Remove packages, update utils dependency (#522)
Browse files Browse the repository at this point in the history
- Replaces blockstore, core, metrics and router with external packages
- Updates chainbridge-utils to latest release
  • Loading branch information
ansermino authored Sep 17, 2020
1 parent 75b81b0 commit 4b2d5e6
Show file tree
Hide file tree
Showing 30 changed files with 42 additions and 608 deletions.
117 changes: 0 additions & 117 deletions blockstore/blockstore.go

This file was deleted.

73 changes: 0 additions & 73 deletions blockstore/blockstore_test.go

This file was deleted.

9 changes: 4 additions & 5 deletions chains/ethereum/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ import (
erc20Handler "github.com/ChainSafe/ChainBridge/bindings/ERC20Handler"
erc721Handler "github.com/ChainSafe/ChainBridge/bindings/ERC721Handler"
"github.com/ChainSafe/ChainBridge/bindings/GenericHandler"
"github.com/ChainSafe/ChainBridge/blockstore"
connection "github.com/ChainSafe/ChainBridge/connections/ethereum"
"github.com/ChainSafe/ChainBridge/core"
metrics "github.com/ChainSafe/ChainBridge/metrics/types"
"github.com/ChainSafe/ChainBridge/router"
"github.com/ChainSafe/chainbridge-utils/blockstore"
"github.com/ChainSafe/chainbridge-utils/core"
"github.com/ChainSafe/chainbridge-utils/crypto/secp256k1"
"github.com/ChainSafe/chainbridge-utils/keystore"
metrics "github.com/ChainSafe/chainbridge-utils/metrics/types"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -178,7 +177,7 @@ func InitializeChain(chainCfg *core.ChainConfig, logger log15.Logger, sysErr cha
}, nil
}

func (c *Chain) SetRouter(r *router.Router) {
func (c *Chain) SetRouter(r *core.Router) {
r.Listen(c.cfg.Id, c.writer)
c.listener.setRouter(r)
}
Expand Down
5 changes: 2 additions & 3 deletions chains/ethereum/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"testing"
"time"

"github.com/ChainSafe/ChainBridge/core"
"github.com/ChainSafe/ChainBridge/router"
ethtest "github.com/ChainSafe/ChainBridge/shared/ethereum/testing"
"github.com/ChainSafe/chainbridge-utils/core"
"github.com/ChainSafe/chainbridge-utils/keystore"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -103,7 +102,7 @@ func TestChain_WriterShutdownOnFailure(t *testing.T) {
t.Fatal(err)
}

r := router.NewRouter(TestLogger)
r := core.NewRouter(TestLogger)
chain.SetRouter(r)

err = chain.Start()
Expand Down
2 changes: 1 addition & 1 deletion chains/ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"math/big"

"github.com/ChainSafe/ChainBridge/core"
utils "github.com/ChainSafe/ChainBridge/shared/ethereum"
"github.com/ChainSafe/chainbridge-utils/core"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ethereum/go-ethereum/common"
)
Expand Down
2 changes: 1 addition & 1 deletion chains/ethereum/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"reflect"
"testing"

"github.com/ChainSafe/ChainBridge/core"
"github.com/ChainSafe/chainbridge-utils/core"
"github.com/ethereum/go-ethereum/common"
)

Expand Down
4 changes: 2 additions & 2 deletions chains/ethereum/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"github.com/ChainSafe/ChainBridge/bindings/ERC20Handler"
"github.com/ChainSafe/ChainBridge/bindings/ERC721Handler"
"github.com/ChainSafe/ChainBridge/bindings/GenericHandler"
"github.com/ChainSafe/ChainBridge/blockstore"
"github.com/ChainSafe/ChainBridge/chains"
metrics "github.com/ChainSafe/ChainBridge/metrics/types"
utils "github.com/ChainSafe/ChainBridge/shared/ethereum"
"github.com/ChainSafe/chainbridge-utils/blockstore"
metrics "github.com/ChainSafe/chainbridge-utils/metrics/types"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
eth "github.com/ethereum/go-ethereum"
Expand Down
2 changes: 1 addition & 1 deletion chains/ethereum/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"github.com/ChainSafe/ChainBridge/bindings/ERC20Handler"
"github.com/ChainSafe/ChainBridge/bindings/ERC721Handler"
"github.com/ChainSafe/ChainBridge/bindings/GenericHandler"
"github.com/ChainSafe/ChainBridge/blockstore"
utils "github.com/ChainSafe/ChainBridge/shared/ethereum"
ethtest "github.com/ChainSafe/ChainBridge/shared/ethereum/testing"
"github.com/ChainSafe/chainbridge-utils/blockstore"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
"github.com/ethereum/go-ethereum/common"
Expand Down
6 changes: 3 additions & 3 deletions chains/ethereum/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ package ethereum

import (
"github.com/ChainSafe/ChainBridge/bindings/Bridge"
"github.com/ChainSafe/ChainBridge/chains"
metrics "github.com/ChainSafe/ChainBridge/metrics/types"
"github.com/ChainSafe/chainbridge-utils/core"
metrics "github.com/ChainSafe/chainbridge-utils/metrics/types"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
)

var _ chains.Writer = &writer{}
var _ core.Writer = &writer{}

// https://github.com/ChainSafe/chainbridge-solidity/blob/b5ed13d9798feb7c340e737a726dd415b8815366/contracts/Bridge.sol#L20
var PassedStatus uint8 = 2
Expand Down
6 changes: 3 additions & 3 deletions chains/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ type Router interface {
Send(message msg.Message) error
}

type Writer interface {
ResolveMessage(message msg.Message) bool
}
//type Writer interface {
// ResolveMessage(message msg.Message) bool
//}
9 changes: 4 additions & 5 deletions chains/substrate/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ As the writer receives messages from the router, it constructs proposals. If a p
package substrate

import (
"github.com/ChainSafe/ChainBridge/blockstore"
"github.com/ChainSafe/ChainBridge/core"
metrics "github.com/ChainSafe/ChainBridge/metrics/types"
"github.com/ChainSafe/ChainBridge/router"
"github.com/ChainSafe/chainbridge-utils/blockstore"
"github.com/ChainSafe/chainbridge-utils/core"
"github.com/ChainSafe/chainbridge-utils/crypto/sr25519"
"github.com/ChainSafe/chainbridge-utils/keystore"
metrics "github.com/ChainSafe/chainbridge-utils/metrics/types"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
)
Expand Down Expand Up @@ -128,7 +127,7 @@ func (c *Chain) Start() error {
return nil
}

func (c *Chain) SetRouter(r *router.Router) {
func (c *Chain) SetRouter(r *core.Router) {
r.Listen(c.cfg.Id, c.writer)
c.listener.setRouter(r)
}
Expand Down
2 changes: 1 addition & 1 deletion chains/substrate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package substrate
import (
"strconv"

"github.com/ChainSafe/ChainBridge/core"
"github.com/ChainSafe/chainbridge-utils/core"
)

func parseStartBlock(cfg *core.ChainConfig) uint64 {
Expand Down
2 changes: 1 addition & 1 deletion chains/substrate/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package substrate
import (
"testing"

"github.com/ChainSafe/ChainBridge/core"
"github.com/ChainSafe/chainbridge-utils/core"
)

func TestParseStartBlock(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions chains/substrate/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"math/big"
"time"

"github.com/ChainSafe/ChainBridge/blockstore"
"github.com/ChainSafe/ChainBridge/chains"
metrics "github.com/ChainSafe/ChainBridge/metrics/types"
utils "github.com/ChainSafe/ChainBridge/shared/substrate"
"github.com/ChainSafe/chainbridge-utils/blockstore"
metrics "github.com/ChainSafe/chainbridge-utils/metrics/types"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
"github.com/centrifuge/go-substrate-rpc-client/types"
Expand Down
2 changes: 1 addition & 1 deletion chains/substrate/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"testing"
"time"

"github.com/ChainSafe/ChainBridge/blockstore"
utils "github.com/ChainSafe/ChainBridge/shared/substrate"
subtest "github.com/ChainSafe/ChainBridge/shared/substrate/testing"
"github.com/ChainSafe/chainbridge-utils/blockstore"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/centrifuge/go-substrate-rpc-client/types"
)
Expand Down
7 changes: 4 additions & 3 deletions chains/substrate/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import (
"fmt"
"time"

"github.com/ChainSafe/ChainBridge/chains"
metrics "github.com/ChainSafe/ChainBridge/metrics/types"
"github.com/ChainSafe/chainbridge-utils/core"

utils "github.com/ChainSafe/ChainBridge/shared/substrate"
metrics "github.com/ChainSafe/chainbridge-utils/metrics/types"
"github.com/ChainSafe/chainbridge-utils/msg"
"github.com/ChainSafe/log15"
"github.com/centrifuge/go-substrate-rpc-client/types"
)

var _ chains.Writer = &writer{}
var _ core.Writer = &writer{}

var AcknowledgeProposal utils.Method = utils.BridgePalletName + ".acknowledge_proposal"
var TerminatedError = errors.New("terminated")
Expand Down
Loading

0 comments on commit 4b2d5e6

Please sign in to comment.