Skip to content

Commit

Permalink
Merge pull request #3 from algorand/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
tsachiherman authored Jun 19, 2019
2 parents 3f6de0e + ea85541 commit 4d22065
Show file tree
Hide file tree
Showing 33 changed files with 653 additions and 92 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: '🐜 Bug report'
about: 'Report a reproducible bug.'
title: ''
labels: 'new-bug'
---
<!--
NOTE: If this issue relates to security, please use the vulnerability disclosure form here:
https://www.algorand.com/resources/blog/security
General, developer or support questions concerning Algorand should be directed to the Algorand Forums https://forum.algorand.org/.
-->

### Subject of the issue
Describe your issue here.

### Your environment
* Software version: `algod -v`
* Node status if applicable: `goal node status`
* Operating System details.
* In many cases log files and cadaver files are also useful to include. Since these files may be large, an Algorand developer may request them later. These files may include public addresses that you're participating with. If that is a concern please be sure to scrub that data.

### Steps to reproduce
Tell us how to reproduce this issue.

### Expected behaviour
Tell us what should happen

### Actual behaviour
Tell us what happens instead
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: '🔔 Feature Request'
about: 'Suggestions for how we can improve the algorand platform.'
title: ''
labels: 'new-feature-request'
---
<!--
NOTE: If this issue relates to security, please use the vulnerability disclosure form here:
https://www.algorand.com/resources/blog/security
General, developer or support questions concerning Algorand should be directed to the Algorand Forums https://forum.algorand.org/.
-->

<!--
This project is focused on low level platform concerns. A good feature request would be related
to protocol and network usage, debugging and monitoring tools, and goal commands.
Higher level suggestions relating to layer 2 applications (like wallet apps) are not appropriate here.
-->
**Is your feature request related to a problem? Please describe.**

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**

A clear and concise description of what you want to happen.

**Additional context**

Add any other context or screenshots about the feature request here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: '❓ Question'
about: 'General questions related to the algorand platform.'
title: ''
labels: 'question'
---
<!--
NOTE: If this issue relates to security, please use the vulnerability disclosure form here:
https://www.algorand.com/resources/blog/security
This issue tracker is not appropriate for most questions.
If your question does not involve a compiler it probably shouldn't be asked here.
General, developer or support questions concerning Algorand should be directed to the Algorand Forums https://forum.algorand.org/.
Additional information is available here: https://developer.algorand.org/
-->
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Thanks for submitting a pull request! We appreciate the time and effort you spent to get this far.
If you haven't already, please make sure that you've reviewed the CONTRIBUTING guide:
https://github.com/algorand/go-algorand/blob/master/CONTRIBUTING.md#code-guidelines
In particular ensure that you've run the following:
* make generate
* make sanity (which runs make fmt, make lint, make fix and make vet)
It is also a good idea to run tests:
* make test
* make integration
-->

## Summary

Explain the goal of this change and what problem it is solving.

## Test Plan

How did you test these changes? Please provide the exact scenarios you tested in as much detail as possible including commands, output and rationale.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Again, if you have a patch for a critical security vulnerability, please use our

For Go code we use the [Golang guidelines defined here](https://golang.org/doc/effective_go.html).
* Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
* We use **gofmt** and **golint**. Also make sure to run `make fix` and `make generate` before opening a pull request.
* We use **gofmt** and **golint**. Also make sure to run `make sanity` and `make generate` before opening a pull request.
* Code must be documented adhering to the official Go commentary guidelines.

For JavaScript code we use the [MDN formatting rules](https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Code_guidelines/JavaScript).
Expand Down
41 changes: 39 additions & 2 deletions cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func init() {
accountCmd.AddCommand(addParticipationKeyCmd)
accountCmd.AddCommand(listParticipationKeysCmd)
accountCmd.AddCommand(importCmd)
accountCmd.AddCommand(exportCmd)
accountCmd.AddCommand(importRootKeysCmd)
accountCmd.AddCommand(accountMultisigCmd)

Expand Down Expand Up @@ -140,7 +141,9 @@ func init() {
// import flags
importCmd.Flags().BoolVarP(&importDefault, "default", "f", false, "Set this account as the default one")
importCmd.Flags().StringVarP(&mnemonic, "mnemonic", "m", "", "Mnemonic to import (will prompt otherwise)")

// export flags
exportCmd.Flags().StringVarP(&accountAddress, "address", "a", "", "Address of account to export")
exportCmd.MarkFlagRequired("address")
// importRootKeys flags
importRootKeysCmd.Flags().BoolVarP(&unencryptedWallet, "unencrypted-wallet", "u", false, "Import into the default unencrypted wallet, potentially creating it")

Expand Down Expand Up @@ -756,6 +759,7 @@ var listParticipationKeysCmd = &cobra.Command{
var importCmd = &cobra.Command{
Use: "import",
Short: "Import an account key from mnemonic",
Long: "Import an account key from a mnemonic generated by the export command or by algokey (NOT a mnemonic from the goal wallet command). The imported account will be listed alongside your wallet-generated accounts, but will not be tied to your wallet.",
Run: func(cmd *cobra.Command, args []string) {
dataDir := ensureSingleDataDir()
accountList := makeAccountsList(dataDir)
Expand Down Expand Up @@ -810,10 +814,43 @@ var importCmd = &cobra.Command{
},
}

var exportCmd = &cobra.Command{
Use: "export",
Short: "Export an account key for use with account import",
Long: "Export an account mnemonic seed, for use with account import. This exports the seed for a single account and should not be confused with the wallet mnemonic.",
Run: func(cmd *cobra.Command, args []string) {
dataDir := ensureSingleDataDir()
client := ensureKmdClient(dataDir)

wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)
passwordString := string(pw)

response, err := client.ExportKey(wh, passwordString, accountAddress)

if err != nil {
reportErrorf(errorRequestFail, err)
}

seed, err := crypto.SecretKeyToSeed(response.PrivateKey)

if err != nil {
reportErrorf(errorSeedConversion, accountAddress, err)
}

privKeyAsMnemonic, err := passphrase.KeyToMnemonic(seed[:])

if err != nil {
reportErrorf(errorMnemonicConversion, accountAddress, err)
}

reportInfof(infoExportedKey, accountAddress, privKeyAsMnemonic)
},
}

var importRootKeysCmd = &cobra.Command{
Use: "importrootkey",
Short: "Import .rootkey files from the data directory into a kmd wallet",
Long: "Import .rootkey files from the data directory into a kmd wallet",
Long: "Import .rootkey files from the data directory into a kmd wallet. This is analogous to using the import command with an account seed mnemonic: the imported account will be displayed alongside your wallet-derived accounts, but will not be tied to your wallet mnemonic.",
Args: validateNoPosArgsFn,
Run: func(cmd *cobra.Command, args []string) {
dataDir := ensureSingleDataDir()
Expand Down
3 changes: 3 additions & 0 deletions cmd/goal/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
infoNoAccounts = "Did not find any account. Please import or create a new one."
infoRenamedAccount = "Renamed account '%s' to '%s'"
infoImportedKey = "Imported %s"
infoExportedKey = "Exported key for account %s: \"%s\""
infoImportedNKeys = "Imported %d key%s"
infoCreatedNewAccount = "Created new account with address %s"
errorNameAlreadyTaken = "The account name '%s' is already taken, please choose another."
Expand All @@ -40,6 +41,8 @@ const (
warnMultisigDuplicatesDetected = "Warning: one or more duplicate addresses detected in multisig account creation. This will effectively give the duplicated address(es) extra signature weight. Continuing multisig account creation."
errLastRoundInvalid = "roundLastValid needs to be well after the current round (%d)"
errExistingPartKey = "Account already has a participation key valid at least until roundLastValid (%d) - current is %d"
errorSeedConversion = "Got private key for account %s, but was unable to convert to seed: %s"
errorMnemonicConversion = "Got seed for account %s, but was unable to convert to mnemonic: %s"

// KMD
infoKMDStopped = "Stopped kmd"
Expand Down
2 changes: 1 addition & 1 deletion cmd/goal/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func init() {
walletCmd.Flags().StringVarP(&defaultWalletName, "default", "f", "", "Set the wallet with this name to be the default wallet")

// Should we recover the wallet?
newWalletCmd.Flags().BoolVarP(&recoverWallet, "recover", "r", false, "Recover the wallet from a backup mnemonic. Regenerate accounts in the wallet with `goal account new`")
newWalletCmd.Flags().BoolVarP(&recoverWallet, "recover", "r", false, "Recover the wallet from the backup mnemonic provided at wallet creation (NOT the mnemonic provided by goal account export or by algokey). Regenerate accounts in the wallet with `goal account new`")
}

var walletCmd = &cobra.Command{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
Unattended-Upgrade::Allowed-Origins {
"Algorand:stable";
};

Dpkg::Options {
"--force-confdef";
"--force-confold";
};
2 changes: 1 addition & 1 deletion installer/debian/conffiles
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/etc/apt/apt.conf.d/50algorand-upgrades
/etc/apt/apt.conf.d/51algorand-upgrades
/var/lib/algorand/genesis.json
2 changes: 1 addition & 1 deletion ledger/archival_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestArchival(t *testing.T) {
wl.l.AddBlock(blk, agreement.Certificate{})

// Don't bother checking the trackers every round -- it's too slow..
if crypto.RandUint64()%10 > 0 {
if crypto.RandUint64()%23 > 0 {
continue
}

Expand Down
2 changes: 2 additions & 0 deletions logging/telemetryCommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type TelemetryConfig struct {
FilePath string // Path to file on disk, if any
ChainID string `json:"-"`
SessionGUID string `json:"-"`
UserName string
Password string
}

type asyncTelemetryHook struct {
Expand Down
6 changes: 2 additions & 4 deletions logging/telemetryConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ import (

var loggingFilename = "logging.config"

// these credentials have the minimum privilege set required to write to elasticsearch
var userName = "telemetry-v9"
var password = "oq%$FA1TOJ!yYeMEcJ7D688eEOE#MGCu"

func elasticsearchEndpoint() string {
return "https://1ae9f9654b25441090fe5c48c833b95a.us-east-1.aws.found.io:9243"
}
Expand Down Expand Up @@ -70,6 +66,8 @@ func createTelemetryConfig() TelemetryConfig {
MinLogLevel: logrus.WarnLevel,
ReportHistoryLevel: logrus.WarnLevel,
LogHistoryDepth: 100,
UserName: "telemetry-v9",
Password: "oq%$FA1TOJ!yYeMEcJ7D688eEOE#MGCu",
}
}

Expand Down
92 changes: 92 additions & 0 deletions logging/telemetryConfig_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (C) 2019 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package logging

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
)

func Test_loadTelemetryConfig(t *testing.T) {

sample := TelemetryConfig{
Enable: true,
GUID: "guid",
URI: "elastic.algorand.com",
MinLogLevel: 4,
ReportHistoryLevel: 4,
LogHistoryDepth: 100,
UserName: "telemetry-v9",
Password: "oq%$FA1TOJ!yYeMEcJ7D688eEOE#MGCu",
}

a := require.New(t)
ourPath, err := os.Getwd()
a.NoError(err)
configsPath := filepath.Join(ourPath, "../test/testdata/configs/logging/logging.config.example")

config, err := loadTelemetryConfig(configsPath)
a.NoError(err)

a.Equal(sample.Enable, config.Enable)
a.Equal(sample.GUID, config.GUID)
a.Equal(sample.URI, config.URI)
a.Equal(sample.MinLogLevel, config.MinLogLevel)
a.Equal(sample.ReportHistoryLevel, config.ReportHistoryLevel)
a.Equal(sample.UserName, config.UserName)
a.Equal(sample.Password, config.Password)

}

func Test_CreateSaveLoadTelemetryConfig(t *testing.T) {

testDir := os.Getenv("TESTDIR")

if testDir == "" {
testDir, _ = ioutil.TempDir("", "tmp")
}

a := require.New(t)

configsPath := filepath.Join(testDir, "logging.config")
config1 := createTelemetryConfig()

err := config1.Save(configsPath)
a.NoError(err)

config2, err := loadTelemetryConfig(configsPath)
a.NoError(err)

a.Equal(config1.Enable, config2.Enable)
a.Equal(config1.URI, config2.URI)
a.Equal(config1.Name, config2.Name)
a.Equal(config1.GUID, config2.GUID)
a.Equal(config1.MinLogLevel, config2.MinLogLevel)
a.Equal(config1.ReportHistoryLevel, config2.ReportHistoryLevel)
a.Equal(config1.LogHistoryDepth, config2.LogHistoryDepth)
a.Equal(config1.FilePath, "")
a.Equal(configsPath, config2.FilePath)
a.Equal(config1.ChainID, config2.ChainID)
a.Equal(config1.SessionGUID, config2.SessionGUID)
a.Equal(config1.UserName, config2.UserName)
a.Equal(config1.Password, config2.Password)

}
2 changes: 1 addition & 1 deletion logging/telemetryhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (hook *asyncTelemetryHook) Flush() {

func createElasticHook(cfg TelemetryConfig) (hook logrus.Hook, err error) {
client, err := elastic.NewClient(elastic.SetURL(cfg.URI),
elastic.SetBasicAuth(userName, password),
elastic.SetBasicAuth(cfg.UserName, cfg.Password),
elastic.SetSniff(false),
elastic.SetGzip(true))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion network/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func pingHandler(message IncomingMessage) OutgoingMessage {
copy(mbytes, tbytes)
copy(mbytes[len(tbytes):], message.Data)
var digest crypto.Digest // leave blank, ping message too short
peer.writeNonBlock(mbytes, false, digest)
peer.writeNonBlock(mbytes, false, digest, time.Now())
return OutgoingMessage{}
}

Expand Down
Loading

0 comments on commit 4d22065

Please sign in to comment.