Skip to content

Commit

Permalink
Remove protocol and eth-node submodules (#1835)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Babik authored Feb 10, 2020
1 parent dc80cb0 commit 8b61d92
Show file tree
Hide file tree
Showing 238 changed files with 2,299 additions and 29,634 deletions.
18 changes: 15 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ run:
- bindata.go
- .*_mock.go
- contracts/
- eth-node/crypto/ecies/ # copied
- eth-node/keystore/ # copied

output:
format: colored-line-number
Expand All @@ -29,8 +31,6 @@ linters-settings:
simplify: true
goimports:
local-prefixes: github.com/ethereum/go-ethereum,github.com/status-im/status-go
gocyclo:
min-complexity: 16
maligned:
suggest-new: true
dupl:
Expand All @@ -46,7 +46,6 @@ linters:
- errcheck
- gosec
- goconst
- gocyclo
- goimports
- golint
- govet
Expand All @@ -65,3 +64,16 @@ issues:
- "G304: Potential file inclusion via variable" # gosec
- "G104: Errors unhandled." #gosec
- "lib._Ctype_char, which can be annoying to use" # golint
exclude-rules:
- path: eth-node/keystore/passphrase\.go
text: "make it a constant"
linters:
- goconst
- path: protocol/message_handler\.go
text: "make it a constant"
linters:
- goconst
- path: protocol/.*_test\.go
text: "make it a constant"
linters:
- goconst
2 changes: 1 addition & 1 deletion account/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (m *Manager) SetChatAccount(privKey *ecdsa.PrivateKey) {
address := crypto.PubkeyToAddress(privKey.PublicKey)
id := uuid.NewRandom()
key := &types.Key{
Id: id,
ID: id,
Address: address,
PrivateKey: privKey,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (f *bootnodes) Set(value string) error {
return nil
}

func main() { // nolint: gocyclo
func main() {
flag.Var(&nursery, "n", "These nodes are used to connect to the network if the table is empty and there are no known nodes in the database.")
flag.Parse()

Expand Down
2 changes: 1 addition & 1 deletion cmd/statusd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func printVersion(config *params.NodeConfig, buildStamp string) {
fmt.Println("Build Stamp:", buildStamp)
}

fmt.Println("Network Id:", config.NetworkID)
fmt.Println("Network ID:", config.NetworkID)
fmt.Println("Go Version:", runtime.Version())
fmt.Println("OS:", runtime.GOOS)
fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
Expand Down
12 changes: 6 additions & 6 deletions eth-node/bridge/geth/ens/ens.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ const (
contractQueryTimeout = 5000 * time.Millisecond
)

type ENSVerifier struct {
type Verifier struct {
logger *zap.Logger
}

// NewVerifier returns a ENSVerifier attached to the specified logger
func NewVerifier(logger *zap.Logger) *ENSVerifier {
return &ENSVerifier{logger: logger}
// NewVerifier returns a Verifier attached to the specified logger
func NewVerifier(logger *zap.Logger) *Verifier {
return &Verifier{logger: logger}
}

func (m *ENSVerifier) verifyENSName(ensInfo enstypes.ENSDetails, ethclient *ethclient.Client) enstypes.ENSResponse {
func (m *Verifier) verifyENSName(ensInfo enstypes.ENSDetails, ethclient *ethclient.Client) enstypes.ENSResponse {
publicKeyStr := ensInfo.PublicKeyString
ensName := ensInfo.Name
m.logger.Info("Resolving ENS name", zap.String("name", ensName), zap.String("publicKey", publicKeyStr))
Expand Down Expand Up @@ -75,7 +75,7 @@ func (m *ENSVerifier) verifyENSName(ensInfo enstypes.ENSDetails, ethclient *ethc
}

// CheckBatch verifies that a registered ENS name matches the expected public key
func (m *ENSVerifier) CheckBatch(ensDetails []enstypes.ENSDetails, rpcEndpoint, contractAddress string) (map[string]enstypes.ENSResponse, error) {
func (m *Verifier) CheckBatch(ensDetails []enstypes.ENSDetails, rpcEndpoint, contractAddress string) (map[string]enstypes.ENSResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), contractQueryTimeout)
defer cancel()

Expand Down
2 changes: 1 addition & 1 deletion eth-node/bridge/geth/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func keyFrom(k *keystore.Key) *types.Key {
}

return &types.Key{
Id: k.Id,
ID: k.Id,
Address: types.Address(k.Address),
PrivateKey: k.PrivateKey,
ExtendedKey: k.ExtendedKey,
Expand Down
2 changes: 1 addition & 1 deletion eth-node/bridge/nimbus/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func keyFrom(k *C.key) (*types.Key, error) {

var err error
key := types.Key{
Id: uuid.Parse(C.GoString(&k.id[0])),
ID: uuid.Parse(C.GoString(&k.id[0])),
}
key.Address = types.BytesToAddress(C.GoBytes(unsafe.Pointer(&k.address[0]), C.ADDRESS_LEN))
key.PrivateKey, err = crypto.ToECDSA(C.GoBytes(unsafe.Pointer(&k.privateKeyID[0]), C.PRIVKEY_LEN))
Expand Down
2 changes: 1 addition & 1 deletion eth-node/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TextHash(data []byte) []byte {
func TextAndHash(data []byte) ([]byte, string) {
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), string(data))
hasher := sha3.NewLegacyKeccak256()
hasher.Write([]byte(msg))
_, _ = hasher.Write([]byte(msg))
return hasher.Sum(nil), msg
}

Expand Down
15 changes: 4 additions & 11 deletions eth-node/crypto/gethcrypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ const RecoveryIDOffset = 64
const DigestLength = 32

var (
secp256k1N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
secp256k1halfN = new(big.Int).Div(secp256k1N, big.NewInt(2))
secp256k1N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
)

var errInvalidPubkey = errors.New("invalid secp256k1 public key")
Expand All @@ -57,7 +56,7 @@ var errInvalidPubkey = errors.New("invalid secp256k1 public key")
func Keccak256(data ...[]byte) []byte {
d := sha3.NewLegacyKeccak256()
for _, b := range data {
d.Write(b)
_, _ = d.Write(b)
}
return d.Sum(nil)
}
Expand All @@ -67,7 +66,7 @@ func Keccak256(data ...[]byte) []byte {
func Keccak256Hash(data ...[]byte) (h types.Hash) {
d := sha3.NewLegacyKeccak256()
for _, b := range data {
d.Write(b)
_, _ = d.Write(b)
}
d.Sum(h[:0])
return h
Expand All @@ -77,7 +76,7 @@ func Keccak256Hash(data ...[]byte) (h types.Hash) {
func Keccak512(data ...[]byte) []byte {
d := sha3.NewLegacyKeccak512()
for _, b := range data {
d.Write(b)
_, _ = d.Write(b)
}
return d.Sum(nil)
}
Expand Down Expand Up @@ -202,12 +201,6 @@ func PubkeyToAddress(p ecdsa.PublicKey) types.Address {
return types.BytesToAddress(Keccak256(pubBytes[1:])[12:])
}

func zeroBytes(bytes []byte) {
for i := range bytes {
bytes[i] = 0
}
}

// Ecrecover returns the uncompressed public key that created the given signature.
func Ecrecover(hash, sig []byte) ([]byte, error) {
return secp256k1.RecoverPubkey(hash, sig)
Expand Down
26 changes: 0 additions & 26 deletions eth-node/go.mod

This file was deleted.

Loading

0 comments on commit 8b61d92

Please sign in to comment.