Skip to content

Commit

Permalink
Merge pull request #1197 from onetechnical/onetechnical/beta2.0.15
Browse files Browse the repository at this point in the history
Algorand BetaNet 2.0.15
  • Loading branch information
algojohnlee authored Jun 24, 2020
2 parents a6fdbad + 6595b84 commit ea9f684
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 30 deletions.
2 changes: 1 addition & 1 deletion buildnumber.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
15
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ type Local struct {
// EnableBlockService enables the block serving service. The functionality of this depends on NetAddress, which must also be provided.
// This functionality is required for the catchup.
EnableBlockService bool

// EnableGossipBlockService enables the block serving service over the gossip network. The functionality of this depends on NetAddress, which must also be provided.
// This functionality is required for the relays to perform catchup from nodes.
EnableGossipBlockService bool
}

// Filenames of config files within the configdir (e.g. ~/.algorand)
Expand Down
7 changes: 6 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func TestConfigMigrateFromDisk(t *testing.T) {
func TestConfigInvariant(t *testing.T) {
a := require.New(t)

a.Equal(uint32(7), configVersion, "If you bump Config Version, please update this test (and consider if you should be adding more)")
a.Equal(uint32(8), configVersion, "If you bump Config Version, please update this test (and consider if you should be adding more)")

ourPath, err := os.Getwd()
a.NoError(err)
Expand Down Expand Up @@ -359,6 +359,11 @@ func TestConfigInvariant(t *testing.T) {
err = codecs.LoadObjectFromFile(filepath.Join(configsPath, "config-v7.json"), &c7)
a.NoError(err)
a.Equal(defaultLocalV7, c7)

c8 := Local{}
err = codecs.LoadObjectFromFile(filepath.Join(configsPath, "config-v8.json"), &c8)
a.NoError(err)
a.Equal(defaultLocalV8, c8)
}

func TestConfigLatestVersion(t *testing.T) {
Expand Down
73 changes: 71 additions & 2 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"time"
)

var defaultLocal = defaultLocalV7
var defaultLocal = defaultLocalV8

const configVersion = uint32(7)
const configVersion = uint32(8)

// !!! WARNING !!!
//
Expand All @@ -39,6 +39,66 @@ const configVersion = uint32(7)
//
// !!! WARNING !!!

var defaultLocalV8 = Local{
// DO NOT MODIFY VALUES - New values may be added carefully - See WARNING at top of file
Version: 8,
Archival: false,
BaseLoggerDebugLevel: 4,
BroadcastConnectionsLimit: -1,
AnnounceParticipationKey: true,
PriorityPeers: map[string]bool{},
CadaverSizeTarget: 1073741824,
CatchupFailurePeerRefreshRate: 10,
CatchupParallelBlocks: 16,
ConnectionsRateLimitingCount: 60,
ConnectionsRateLimitingWindowSeconds: 1,
DeadlockDetection: 0,
DNSBootstrapID: "<network>.algorand.network",
EnableAgreementReporting: false,
EnableAgreementTimeMetrics: false,
EnableIncomingMessageFilter: false,
EnableMetricReporting: false,
EnableOutgoingNetworkMessageFiltering: true,
EnableRequestLogger: false,
EnableTopAccountsReporting: false,
EndpointAddress: "127.0.0.1:0",
GossipFanout: 4,
IncomingConnectionsLimit: 10000,
IncomingMessageFilterBucketCount: 5,
IncomingMessageFilterBucketSize: 512,
LogArchiveName: "node.archive.log",
LogArchiveMaxAge: "",
LogSizeLimit: 1073741824,
MaxConnectionsPerIP: 30,
NetAddress: "",
NodeExporterListenAddress: ":9100",
NodeExporterPath: "./node_exporter",
OutgoingMessageFilterBucketCount: 3,
OutgoingMessageFilterBucketSize: 128,
ReconnectTime: 1 * time.Minute,
ReservedFDs: 256,
RestReadTimeoutSeconds: 15,
RestWriteTimeoutSeconds: 120,
RunHosted: false,
SuggestedFeeBlockHistory: 3,
SuggestedFeeSlidingWindowSize: 50,
TelemetryToLog: true,
TxPoolExponentialIncreaseFactor: 2,
TxPoolSize: 15000,
TxSyncIntervalSeconds: 60,
TxSyncTimeoutSeconds: 30,
TxSyncServeResponseSize: 1000000,
PeerConnectionsUpdateInterval: 3600,
DNSSecurityFlags: 0x01,
EnablePingHandler: true,
CatchpointInterval: 10000,
CatchpointFileHistoryLength: 365,
EnableLedgerService: false,
EnableBlockService: false,
EnableGossipBlockService: true, // added in V8
// DO NOT MODIFY VALUES - New values may be added carefully - See WARNING at top of file
}

var defaultLocalV7 = Local{
// DO NOT MODIFY VALUES - New values may be added carefully - See WARNING at top of file
Version: 7,
Expand Down Expand Up @@ -497,6 +557,15 @@ func migrate(cfg Local) (newCfg Local, err error) {
newCfg.Version = 7
}

// Migrate 7 -> 8
if newCfg.Version == 7 {
if newCfg.EnableGossipBlockService == defaultLocalV7.EnableGossipBlockService {
newCfg.EnableGossipBlockService = defaultLocalV8.EnableGossipBlockService
}

newCfg.Version = 8
}

if newCfg.Version != configVersion {
err = fmt.Errorf("failed to migrate config version %d (stuck at %d) to latest %d", cfg.Version, newCfg.Version, configVersion)
}
Expand Down
182 changes: 182 additions & 0 deletions daemon/algod/api/server/router_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// Copyright (C) 2019-2020 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 server

import (
"net/http"
"testing"

"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/algorand/go-algorand/daemon/algod/api/server/lib"
"github.com/algorand/go-algorand/daemon/algod/api/server/v1/routes"
)

type TestSuite struct {
suite.Suite
calls int
e *echo.Echo
}

func (s *TestSuite) SetupSuite() {
s.e = echo.New()
handler := func(context lib.ReqContext, context2 echo.Context) {
s.calls++
}
// Make a deep copy of the routes array with dummy handlers that log a call.
v1RoutesCopy := make([]lib.Route, len(routes.V1Routes))
for _, route := range routes.V1Routes {
v1RoutesCopy = append(v1RoutesCopy, lib.Route{
Name: route.Name,
Method: route.Method,
Path: route.Path,
HandlerFunc: handler,
})
}
// Registering v1 routes
registerHandlers(s.e, apiV1Tag, v1RoutesCopy, lib.ReqContext{})
}
func (s *TestSuite) SetupTest() {
s.calls = 0
}
func (s *TestSuite) TestBaselineRoute() {
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v0/this/is/no/endpoint", ctx)
assert.Equal(s.T(), echo.ErrNotFound, ctx.Handler()(ctx))
assert.Equal(s.T(), 0, s.calls)
}
func (s *TestSuite) TestAccountPendingTransaction() {
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/account/address-param/transactions/pending", ctx)
assert.Equal(s.T(), "/v1/account/:addr/transactions/pending", ctx.Path())
assert.Equal(s.T(), "address-param", ctx.Param("addr"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestWaitAfterBlock() {
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/status/wait-for-block-after/123456", ctx)
assert.Equal(s.T(), "/v1/status/wait-for-block-after/:round", ctx.Path())
assert.Equal(s.T(), "123456", ctx.Param("round"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestAccountInformation() {
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/account/ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA", ctx)
assert.Equal(s.T(), "/v1/account/:addr", ctx.Path())
assert.Equal(s.T(), "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA", ctx.Param("addr"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestTransactionInformation() {
ctx := s.e.NewContext(nil, nil)
addr := "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA"
txid := "ASPB5E72OT2UWSOCQGD5OPT3W4KV4LZZDL7L5MBCC3EBAIJCDHAA"
s.e.Router().Find(http.MethodGet, "/v1/account/"+addr+"/transaction/"+txid, ctx)
assert.Equal(s.T(), "/v1/account/:addr/transaction/:txid", ctx.Path())
assert.Equal(s.T(), addr, ctx.Param("addr"))
assert.Equal(s.T(), txid, ctx.Param("txid"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestAccountTransaction() {
ctx := s.e.NewContext(nil, nil)
addr := "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA"
s.e.Router().Find(http.MethodGet, "/v1/account/"+addr+"/transactions", ctx)
assert.Equal(s.T(), "/v1/account/:addr/transactions", ctx.Path())
assert.Equal(s.T(), addr, ctx.Param("addr"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestBlock() {
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/block/123456", ctx)
assert.Equal(s.T(), "/v1/block/:round", ctx.Path())
assert.Equal(s.T(), "123456", ctx.Param("round"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestPendingTransactionID() {
ctx := s.e.NewContext(nil, nil)
txid := "ASPB5E72OT2UWSOCQGD5OPT3W4KV4LZZDL7L5MBCC3EBAIJCDHAA"
s.e.Router().Find(http.MethodGet, "/v1/transactions/pending/"+txid, ctx)
assert.Equal(s.T(), "/v1/transactions/pending/:txid", ctx.Path())
assert.Equal(s.T(), txid, ctx.Param("txid"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestPendingTransactionInformationByAddress() {
ctx := s.e.NewContext(nil, nil)
addr := "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA"
s.e.Router().Find(http.MethodGet, "/v1/account/"+addr+"/transactions/pending", ctx)
assert.Equal(s.T(), "/v1/account/:addr/transactions/pending", ctx.Path())
assert.Equal(s.T(), addr, ctx.Param("addr"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestGetAsset() {
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/asset/123456", ctx)
assert.Equal(s.T(), "/v1/asset/:index", ctx.Path())
assert.Equal(s.T(), "123456", ctx.Param("index"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestGetTransactionByID() {
ctx := s.e.NewContext(nil, nil)
txid := "ASPB5E72OT2UWSOCQGD5OPT3W4KV4LZZDL7L5MBCC3EBAIJCDHAA"
s.e.Router().Find(http.MethodGet, "/v1/transaction/"+txid, ctx)
assert.Equal(s.T(), "/v1/transaction/:txid", ctx.Path())
assert.Equal(s.T(), txid, ctx.Param("txid"))

// Ensure that a handler in the route array was called by checking that the 'calls' variable is incremented.
callsBefore := s.calls
assert.Equal(s.T(), nil, ctx.Handler()(ctx))
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func TestTestSuite(t *testing.T) {
suite.Run(t, new(TestSuite))
}
2 changes: 1 addition & 1 deletion daemon/algod/api/server/v1/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var V1Routes = lib.Routes{
lib.Route{
Name: "pending-transaction-information-by-address",
Method: "GET",
Path: "/account/{addr}/transactions/pending",
Path: "/account/:addr/transactions/pending",
HandlerFunc: handlers.GetPendingTransactionsByAddress,
},

Expand Down
3 changes: 2 additions & 1 deletion installer/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": 7,
"Version": 8,
"AnnounceParticipationKey": true,
"Archival": false,
"BaseLoggerDebugLevel": 4,
Expand All @@ -14,6 +14,7 @@
"DisableOutgoingConnectionThrottling": false,
"DeadlockDetection": 0,
"DNSBootstrapID": "<network>.algorand.network",
"EnableGossipBlockService": true,
"EnableIncomingMessageFilter": false,
"EnableMetricReporting": false,
"EnableOutgoingNetworkMessageFiltering": true,
Expand Down
9 changes: 6 additions & 3 deletions netdeploy/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,13 @@ func (n Network) GetPeerAddresses(binDir string) []string {
for _, relayDir := range n.cfg.RelayDirs {
nc := nodecontrol.MakeNodeController(binDir, n.getNodeFullPath(relayDir))
relayAddress, err := nc.GetListeningAddress()
if err == nil {
peerAddresses = append(peerAddresses, relayAddress)
if err != nil {
continue
}
if strings.HasPrefix(relayAddress, "http://") {
relayAddress = relayAddress[7:]
}
peerAddresses = append(peerAddresses, relayAddress)
}
return peerAddresses
}
Expand All @@ -336,7 +340,6 @@ func (n Network) StartNode(binDir, nodeDir string, redirectOutput bool) (err err
controller := nodecontrol.MakeNodeController(binDir, nodeDir)
peers := n.GetPeerAddresses(binDir)
peerAddresses := strings.Join(peers, ";")

_, err = controller.StartAlgod(nodecontrol.AlgodStartArgs{
PeerAddress: peerAddresses,
RedirectOutput: redirectOutput,
Expand Down
Loading

0 comments on commit ea9f684

Please sign in to comment.