Skip to content

Commit

Permalink
Merge branch 'develop' into topics-in-waku-messages-request
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Babik authored Jan 20, 2020
2 parents 7d021f8 + 3b81bd2 commit 1712a9d
Show file tree
Hide file tree
Showing 145 changed files with 7,924 additions and 3,958 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ HELP_FUN = \
print "\n"; \
}

nimbus: ##@build Build Nimbus
./eth-node/bridge/nimbus/build-nimbus.sh

nimbus-statusgo: nimbus ##@build Build status-go (based on Nimbus node) as statusd server
C_INCLUDE_PATH="./eth-node/bridge/nimbus" go build -mod=vendor -i -o $(GOBIN)/statusd -v -tags '$(BUILD_TAGS) nimbus' $(BUILD_FLAGS) ./cmd/statusd && \
cp vendor/github.com/status-im/status-go/eth-node/bridge/nimbus/libnimbus.so $(GOBIN)
@echo "Compilation done."
@echo "Run \"build/bin/statusd -h\" to view available commands."

statusgo: ##@build Build status-go as statusd server
go build -i -o $(GOBIN)/statusd -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/statusd
@echo "Compilation done."
Expand Down Expand Up @@ -93,7 +102,7 @@ statusgo-cross: statusgo-android statusgo-ios
statusgo-android: ##@cross-compile Build status-go for Android
@echo "Building status-go for Android..."
gomobile init
gomobile bind -target=android -ldflags="-s -w" $(BUILD_FLAGS_MOBILE) -o build/bin/statusgo.aar github.com/status-im/status-go/mobile
gomobile bind -v -target=android -ldflags="-s -w" $(BUILD_FLAGS_MOBILE) -o build/bin/statusgo.aar github.com/status-im/status-go/mobile
@echo "Android cross compilation done in build/bin/statusgo.aar"

statusgo-ios: ##@cross-compile Build status-go for iOS
Expand Down Expand Up @@ -244,7 +253,7 @@ test-unit: UNIT_TEST_PACKAGES = $(shell go list ./... | \
grep -v /lib | \
grep -v /transactions/fake )
test-unit: ##@tests Run unit and integration tests
go test -v -failfast $(UNIT_TEST_PACKAGES) $(gotest_extraflags)
go test -v -failfast $(UNIT_TEST_PACKAGES) $(gotest_extraflags) && cd ./protocol && $(MAKE) test

test-unit-race: gotest_extraflags=-race
test-unit-race: test-unit ##@tests Run unit and integration tests with -race flag
Expand Down Expand Up @@ -282,7 +291,8 @@ ci: lint canary-test test-unit test-e2e ##@tests Run all linters and tests at on
ci-race: lint canary-test test-unit test-e2e-race ##@tests Run all linters and tests at once + race

clean: ##@other Cleanup
rm -fr build/bin/* mailserver-config.json
rm -fr build/bin/* mailserver-config.json vendor/github.com/status-im/nimbus
git clean -xf

deep-clean: clean
rm -Rdf .ethereumtest/StatusChain
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.39.5
0.39.9
6 changes: 2 additions & 4 deletions account/accounts_geth.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build !nimbus

package account

import (
Expand All @@ -15,8 +13,8 @@ type GethManager struct {
gethAccManager *accounts.Manager
}

// NewManager returns new node account manager.
func NewManager() *GethManager {
// NewGethManager returns new node account manager.
func NewGethManager() *GethManager {
m := &GethManager{}
m.Manager = &Manager{accountsGenerator: generator.New(m)}
return m
Expand Down
33 changes: 17 additions & 16 deletions account/accounts_nimbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ import (
"github.com/status-im/status-go/account/generator"
)

// NewManager returns new node account manager.
func NewManager() *Manager {
m := &Manager{}
m.accountsGenerator = generator.New(m)
// NimbusManager represents account manager interface.
type NimbusManager struct {
*Manager
}

// NewNimbusManager returns new node account manager.
func NewNimbusManager() *NimbusManager {
m := &NimbusManager{}
m.Manager = &Manager{accountsGenerator: generator.New(m)}
return m
}

// InitKeystore sets key manager and key store.
func (m *Manager) InitKeystore(keydir string) error {
m.mu.Lock()
defer m.mu.Unlock()
// // InitKeystore sets key manager and key store.
// func (m *Manager) InitKeystore(keydir string) error {
// m.mu.Lock()
// defer m.mu.Unlock()

// TODO: Wire with the Nimbus keystore
manager, err := makeAccountManager(keydir)
if err != nil {
return err
}
m.keystore, err = makeKeyStore(manager)
return err
}
// var err error
// m.keystore, err = makeKeyStore(keydir)
// return err
// }
6 changes: 3 additions & 3 deletions account/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

func TestVerifyAccountPassword(t *testing.T) {
accManager := NewManager()
accManager := NewGethManager()
keyStoreDir, err := ioutil.TempDir(os.TempDir(), "accounts")
require.NoError(t, err)
defer os.RemoveAll(keyStoreDir) //nolint: errcheck
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestVerifyAccountPasswordWithAccountBeforeEIP55(t *testing.T) {
err = utils.ImportTestAccount(keyStoreDir, "test-account3-before-eip55.pk")
require.NoError(t, err)

accManager := NewManager()
accManager := NewGethManager()

address := types.HexToAddress(utils.TestConfig.Account3.WalletAddress)
_, err = accManager.VerifyAccountPassword(keyStoreDir, address.Hex(), utils.TestConfig.Account3.Password)
Expand Down Expand Up @@ -136,7 +136,7 @@ type testAccount struct {
// SetupTest is used here for reinitializing the mock before every
// test function to avoid faulty execution.
func (s *ManagerTestSuite) SetupTest() {
s.accManager = NewManager()
s.accManager = NewGethManager()

keyStoreDir, err := ioutil.TempDir(os.TempDir(), "accounts")
s.Require().NoError(err)
Expand Down
2 changes: 2 additions & 0 deletions account/keystore_geth.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !nimbus

// TODO: Make independent version for Nimbus

package account
Expand Down
49 changes: 49 additions & 0 deletions account/keystore_nimbus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// +build nimbus

package account

import (
"io/ioutil"
"os"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"

gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
// nimbusbridge "github.com/status-im/status-go/eth-node/bridge/nimbus"
"github.com/status-im/status-go/eth-node/types"
)

// makeAccountManager creates ethereum accounts.Manager with single disk backend and lightweight kdf.
// If keydir is empty new temporary directory with go-ethereum-keystore will be intialized.
func makeAccountManager(keydir string) (manager *accounts.Manager, err error) {
if keydir == "" {
// There is no datadir.
keydir, err = ioutil.TempDir("", "nimbus-keystore")
}
if err != nil {
return nil, err
}
if err := os.MkdirAll(keydir, 0700); err != nil {
return nil, err
}
config := accounts.Config{InsecureUnlockAllowed: false}
return accounts.NewManager(&config, keystore.NewKeyStore(keydir, keystore.LightScryptN, keystore.LightScryptP)), nil
}

func makeKeyStore(manager *accounts.Manager) (types.KeyStore, error) {
backends := manager.Backends(keystore.KeyStoreType)
if len(backends) == 0 {
return nil, ErrAccountKeyStoreMissing
}
keyStore, ok := backends[0].(*keystore.KeyStore)
if !ok {
return nil, ErrAccountKeyStoreMissing
}

return gethbridge.WrapKeyStore(keyStore), nil
}

// func makeKeyStore(_ string) (types.KeyStore, error) {
// return nimbusbridge.WrapKeyStore(), nil
// }
8 changes: 5 additions & 3 deletions api/geth_backend.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !nimbus

package api

import (
Expand Down Expand Up @@ -82,10 +84,10 @@ type GethStatusBackend struct {

// NewGethStatusBackend create a new GethStatusBackend instance
func NewGethStatusBackend() *GethStatusBackend {
defer log.Info("Status backend initialized", "version", params.Version, "commit", params.GitCommit)
defer log.Info("Status backend initialized", "backend", "geth", "version", params.Version, "commit", params.GitCommit)

statusNode := node.New()
accountManager := account.NewManager()
accountManager := account.NewGethManager()
transactor := transactions.NewTransactor()
personalAPI := personal.NewAPI()
rpcFilters := rpcfilters.New(statusNode)
Expand Down Expand Up @@ -381,7 +383,7 @@ func (b *GethStatusBackend) rpcFiltersService() gethnode.ServiceConstructor {

func (b *GethStatusBackend) subscriptionService() gethnode.ServiceConstructor {
return func(*gethnode.ServiceContext) (gethnode.Service, error) {
return subscriptions.New(b.statusNode), nil
return subscriptions.New(func() *rpc.Client { return b.statusNode.RPCPrivateClient() }), nil
}
}

Expand Down
Loading

0 comments on commit 1712a9d

Please sign in to comment.