Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep feature branch for multiple contracts per account up-to-date #119

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
9f32007
compute polynomials in G2 using small scalar multiplications only
Oct 1, 2020
fa2433a
compute polynomial images in Zr using a single mult per iteration
Oct 1, 2020
4585014
refactor BLS tests
Oct 14, 2020
63fc691
Split Snapshot into Snapshot and SpockSnapshot to ensure spock secret…
m4ksio Oct 14, 2020
7c449d4
Fix missing storage of ExecutionResults
m4ksio Oct 14, 2020
a4a86b7
Linting
m4ksio Oct 14, 2020
c28e513
log receiving collection
zhangchiqing Oct 14, 2020
3529525
reload all finalized and unexecuted blocks
zhangchiqing Oct 15, 2020
6539803
print block height
zhangchiqing Oct 15, 2020
1d6ba0f
update metrics
zhangchiqing Oct 15, 2020
d322a7c
show block height in extend call
zhangchiqing Oct 15, 2020
c18760d
log missing parent
zhangchiqing Oct 15, 2020
f159cd1
linting
zhangchiqing Oct 15, 2020
1b43735
fix logging
zhangchiqing Oct 15, 2020
6f6d976
log last finalized
zhangchiqing Oct 15, 2020
bdd0485
adjust log level
zhangchiqing Oct 15, 2020
d86c30e
force executing on startup
zhangchiqing Oct 15, 2020
e50f7e5
pull until a future height
zhangchiqing Oct 15, 2020
08c5a63
refactor the remaining tests
Oct 15, 2020
e4ed3fb
Merge branch 'master' into tarak/4870-crypto-testing-syntax
Oct 15, 2020
0ce8341
fix linting
zhangchiqing Oct 15, 2020
ebb7688
Merge branch 'master' into m4ksio/4800-dont-transfer-spocks
m4ksio Oct 19, 2020
d3e2781
enforce max seal count per block when gathering seals for unfinalized
jordanschalm Oct 17, 2020
744191b
adding consistency checks: wip
jordanschalm Oct 17, 2020
23b0e58
"fixed" tests
Oct 16, 2020
9409027
enabled tests
Oct 19, 2020
228366b
merged builder matching engine
Oct 16, 2020
3c158a5
cleanup
Oct 19, 2020
0cef85f
Revisions for concurrency safety of stdmap.IncorporatedResults
Oct 20, 2020
3494c41
wip
Oct 20, 2020
87006ec
Rough merge of 'master' into alex/sealing-hotfix-backport
Oct 22, 2020
125db6a
fixed IncorporatedResults mempool
Oct 23, 2020
96598e8
wip
Oct 23, 2020
abc23fa
fixed concurrency safety of stdmap.IApprovals and stdmap.Incorporated…
Oct 23, 2020
050ad33
some more polishing of stdmap.IApprovals and stdmap.IncorporatedResul…
Oct 23, 2020
c0dc548
Use proper context
m4ksio Oct 23, 2020
7fcba70
wip
Oct 24, 2020
9828276
some more refactoring of matching engine
Oct 24, 2020
2b29afc
fixing tests (in progress)
Oct 24, 2020
67ad9fd
Update engine/execution/ingestion/engine.go
zhangchiqing Oct 25, 2020
e8f48a6
add comments
zhangchiqing Oct 25, 2020
cfa26e3
deduplicate queue
zhangchiqing Oct 25, 2020
b50d86d
refactor block reloading
zhangchiqing Oct 26, 2020
5823b50
continue fixing tests
Oct 26, 2020
10e9cde
fixed more tests
Oct 26, 2020
4cb1354
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 26, 2020
c604e5b
fix IsBlockExecuted
zhangchiqing Oct 26, 2020
34c646d
Merge branch 'leo/4920-reload-unexecuted-blocks' of github.com:onflow…
zhangchiqing Oct 26, 2020
aae4d84
... tests
Oct 26, 2020
a6d1350
extended matching engine tests
Oct 26, 2020
48e2d1d
done fixing tests for matching engine.
Oct 26, 2020
09f9d79
wip
Oct 26, 2020
b25a0c8
fixed builder tests
Oct 26, 2020
068bbe8
test fix
Oct 26, 2020
b662b73
added some more sanity checks to avoid sealing empty state commitment
Oct 26, 2020
436c7b8
linted code
Oct 26, 2020
7a523f3
exclude the last executed block from the execution queues
zhangchiqing Oct 26, 2020
b79dc3a
update comment
zhangchiqing Oct 26, 2020
04cebaa
Merge branch 'master' into alex/sealing-hotfix-backport
Oct 27, 2020
8400fc6
Merge branch 'm4ksio/chunk-index' into alex/sealing-hotfix-backport
Oct 27, 2020
d19b61a
Apply suggestions from code review
Oct 27, 2020
66ea1fe
code decluttering; extended goDoc and method comments
Oct 27, 2020
69f4fd8
fixed camel cases in go code files
Oct 27, 2020
5478e5d
Merge branch 'm4ksio/chunk-index' into alex/sealing-hotfix-backport
Oct 27, 2020
9f044b1
log queue head, and refactor with IsBlockExecuted
zhangchiqing Oct 27, 2020
52647d7
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 27, 2020
626e807
use Restart=always in example systemd deploy files
jordanschalm Oct 27, 2020
a495b96
Merge branch 'master' into m4ksio/4800-dont-transfer-spocks
m4ksio Oct 27, 2020
83c490e
Fix merge
m4ksio Oct 27, 2020
0a6a987
Merge branch 'master' into jordan/hf/systemd-restart-default
jordanschalm Oct 27, 2020
e7982f4
add safety check and crash the node if unable to reload blocks
zhangchiqing Oct 27, 2020
77f1eab
Merge branch 'leo/4920-reload-unexecuted-blocks' of github.com:onflow…
zhangchiqing Oct 27, 2020
5b699f8
Merge branch 'master' into 3123/tarak-optimize-joint-feldman
tarakby Oct 28, 2020
6fdda8d
Adding tx byte size limit for access/collection nodes (#90)
ramtinms Oct 28, 2020
445c268
reverted minor change in ExecutionResult: an empty state commitment i…
Oct 28, 2020
1219a5e
add address validity check
jordanschalm Oct 28, 2020
1574b8d
fixed TODO comment
Oct 28, 2020
e8898eb
Apply suggestions from code review
Oct 28, 2020
8e41436
improved logging; renamed matching.Engine.maxUnsealedResults to match…
Oct 28, 2020
92f95c3
Merge branch 'master' into alex/sealing-hotfix-backport
Oct 28, 2020
469c50c
fixed broken test after var renaming :facepalm:
Oct 28, 2020
e3bebd6
Merge pull request #93 from onflow/alex/sealing-hotfix-backport
Oct 28, 2020
76bad9c
Merge branch 'master' into jordan/4910-skip-nonexistent-accounts
jordanschalm Oct 28, 2020
4eb858e
update configs where ingest engine is instantiated
jordanschalm Oct 28, 2020
52ad49d
add tests for objective/subjective validity checks
jordanschalm Oct 28, 2020
acba54a
add flag for max index
jordanschalm Oct 28, 2020
78c62ed
Merge branch 'master' into jordan/4910-skip-nonexistent-accounts
jordanschalm Oct 28, 2020
45905b8
Adding gas and byte size limits to collections (#91)
ramtinms Oct 28, 2020
858a4a4
addng test cases for verify unexecuted blocks
zhangchiqing Oct 29, 2020
2cf5449
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 29, 2020
d24dea1
update comment
zhangchiqing Oct 29, 2020
cd1a3d7
Merge branch 'master' into jordan/4910-skip-nonexistent-accounts
jordanschalm Oct 29, 2020
f47430b
Ramtin/4844 adding more tx types to the load (#68)
ramtinms Oct 29, 2020
992d287
bug fixed: VoteAggregator now handles block equivocation without error
Oct 29, 2020
95dfd7a
Merge branch 'master' into jordan/hf/systemd-restart-default
jordanschalm Oct 29, 2020
6e5a81a
Merge pull request #97 from onflow/jordan/hf/systemd-restart-default
jordanschalm Oct 29, 2020
d1dc1de
executed the last executed on startup
zhangchiqing Oct 29, 2020
4c3b1fe
extending logging
Oct 29, 2020
0653782
skip the root block
zhangchiqing Oct 29, 2020
72ab7fc
fix linting
zhangchiqing Oct 29, 2020
c7ed0cf
disable flakey tests
zhangchiqing Oct 29, 2020
210e56d
fix lint
zhangchiqing Oct 29, 2020
e9eb8b7
fix lint
zhangchiqing Oct 29, 2020
bc9910a
reload the last executed block instead of the last finalized executed…
zhangchiqing Oct 29, 2020
b974edc
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 29, 2020
398c4f8
Merge branch 'master' into 3123/tarak-optimize-joint-feldman
Kay-Zee Oct 29, 2020
70917c7
refactor mocks
zhangchiqing Oct 29, 2020
114a8e8
fix lint
zhangchiqing Oct 29, 2020
905a973
update comment
zhangchiqing Oct 29, 2020
99248a2
Merge branch 'master' into m4ksio/4800-dont-transfer-spocks
Kay-Zee Oct 29, 2020
64f439a
Merge branch 'master' into jordan/4910-skip-nonexistent-accounts
jordanschalm Oct 29, 2020
99e74c7
fix error equality checking in collector test
jordanschalm Oct 30, 2020
a6f1c11
Merge pull request #101 from onflow/jordan/4910-skip-nonexistent-acco…
jordanschalm Oct 30, 2020
ace6e5a
Merge branch 'master' into tarak/4870-crypto-testing-syntax
tarakby Oct 30, 2020
c9e7490
comment fix
Oct 30, 2020
588e416
Merge branch '3123/tarak-optimize-joint-feldman' of github.com:onflow…
Oct 30, 2020
b6a9788
fix logging
zhangchiqing Oct 30, 2020
e391da6
Merge branch 'master' into 3123/tarak-optimize-joint-feldman
tarakby Oct 30, 2020
5d077fb
Merge branch 'master' into alex/4952-hotstuff-error-on-double-proposal
Oct 30, 2020
5b42992
Merge pull request #74 from onflow/tarak/4870-crypto-testing-syntax
Kay-Zee Oct 30, 2020
58d3eea
Merge branch 'master' into alex/4952-hotstuff-error-on-double-proposal
Kay-Zee Oct 30, 2020
bbd6d18
Merge pull request #105 from onflow/alex/4952-hotstuff-error-on-doubl…
Oct 30, 2020
b54a4d7
Merge branch 'master' into 3123/tarak-optimize-joint-feldman
tarakby Oct 30, 2020
12c327a
Apply suggestions from code review
zhangchiqing Oct 30, 2020
a26a683
Update state/protocol/badger/mutator.go
zhangchiqing Oct 30, 2020
6eea192
Update engine/execution/state/state.go
zhangchiqing Oct 30, 2020
70fdcc2
pin the snapshot for reloading blocks
zhangchiqing Oct 30, 2020
cfa0cdc
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 30, 2020
c519b72
Merge branch 'master' into joran/4949-col-integration-test
jordanschalm Oct 30, 2020
266b272
Merge pull request #106 from onflow/joran/4949-col-integration-test
jordanschalm Oct 30, 2020
fa3f1af
Command to create Staking & Networking keys for internal nodes (#96)
danukumanan Oct 30, 2020
7b5bf29
truncate-database command line utility
m4ksio Oct 30, 2020
e1d0ec8
Yahya/5005-fix-flakey-libp2p-test (#99)
yhassanzadeh13 Oct 30, 2020
12426d6
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 30, 2020
c33444a
Linting
m4ksio Oct 30, 2020
be6aecd
Merge branch 'master' into m4ksio/truncate-database
m4ksio Oct 30, 2020
8023422
Add command
m4ksio Oct 30, 2020
fbe9e64
Merge remote-tracking branch 'origin/m4ksio/truncate-database' into m…
m4ksio Oct 30, 2020
f3c6bb2
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Oct 30, 2020
a08e985
fix tests
zhangchiqing Oct 30, 2020
5754117
Merge branch 'leo/4920-reload-unexecuted-blocks' of github.com:onflow…
zhangchiqing Oct 30, 2020
5218344
Merge pull request #107 from onflow/m4ksio/truncate-database
m4ksio Oct 30, 2020
c0f837b
add additional logging
zhangchiqing Oct 30, 2020
c960343
Merge branch 'master' into 3123/tarak-optimize-joint-feldman
Oct 31, 2020
621b87f
Merge pull request #37 from onflow/3123/tarak-optimize-joint-feldman
tarakby Nov 1, 2020
cf7d609
Merge branch 'master' into m4ksio/4800-dont-transfer-spocks
m4ksio Nov 2, 2020
c5fb677
locking the read of statecommitment in execution state mock
zhangchiqing Nov 2, 2020
02ac631
Merge branch 'master' into leo/4920-reload-unexecuted-blocks
zhangchiqing Nov 2, 2020
8ef6e57
Merge pull request #73 from onflow/leo/4920-reload-unexecuted-blocks
zhangchiqing Nov 2, 2020
f8b6442
fix transaction results operation
zhangchiqing Nov 2, 2020
b1edd0c
Merge pull request #114 from onflow/leo/fix-transaction-results-opera…
zhangchiqing Nov 3, 2020
1f3102a
Merge branch 'master' into m4ksio/4800-dont-transfer-spocks
Kay-Zee Nov 3, 2020
a9698a9
resolve merge issue
Kay-Zee Nov 3, 2020
fed56cf
Merge pull request #69 from onflow/m4ksio/4800-dont-transfer-spocks
Kay-Zee Nov 3, 2020
868b894
Decouple address generator state from accounts (#88)
janezpodhostnik Nov 3, 2020
1001b58
Vishal/transit script version (#110)
vishalchangrani Nov 4, 2020
bdf2e71
Merge branch 'master' into bastian/update-multiple-contract-support-2
turbolent Nov 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ docker-build-bootstrap:

.PHONY: docker-build-bootstrap-transit
docker-build-bootstrap-transit:
docker build -f cmd/Dockerfile --ssh default --build-arg TARGET=bootstrap/transit --target production-nocgo \
docker build -f cmd/Dockerfile --ssh default --build-arg TARGET=bootstrap/transit --build-arg COMMIT=$(COMMIT) --build-arg VERSION=$(VERSION) --no-cache \
--target production-transit-nocgo \
-t "$(CONTAINER_REGISTRY)/bootstrap-transit:latest" -t "$(CONTAINER_REGISTRY)/bootstrap-transit:$(SHORT_COMMIT)" -t "$(CONTAINER_REGISTRY)/bootstrap-transit:$(IMAGE_TAG)" .

.PHONY: docker-build-loader
Expand Down
22 changes: 22 additions & 0 deletions access/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package access
import (
"errors"
"fmt"

"github.com/onflow/flow-go/model/flow"
)

// ErrUnknownReferenceBlock indicates that a transaction references an unknown block.
Expand Down Expand Up @@ -48,3 +50,23 @@ type InvalidGasLimitError struct {
func (e InvalidGasLimitError) Error() string {
return fmt.Sprintf("transaction gas limit (%d) exceeds the maximum gas limit (%d)", e.Actual, e.Maximum)
}

// InvalidAddressError indicates that a transaction references an invalid flow Address
// in either the Authorizers or Payer field.
type InvalidAddressError struct {
Address flow.Address
}

func (e InvalidAddressError) Error() string {
return fmt.Sprintf("invalid address: %s", e.Address)
}

// InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.
type InvalidTxByteSizeError struct {
Maximum uint64
Actual uint64
}

func (e InvalidTxByteSizeError) Error() string {
return fmt.Sprintf("transaction byte size (%d) exceeds the maximum byte size allowed for a transaction (%d)", e.Actual, e.Maximum)
}
58 changes: 57 additions & 1 deletion access/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,37 @@ type TransactionValidationOptions struct {
AllowUnknownReferenceBlockID bool
MaxGasLimit uint64
CheckScriptsParse bool
// MaxAddressIndex is a simple spam prevention measure. It rejects any
// transactions referencing an address with index newer than the specified
// maximum. A zero value indicates no address checking.
MaxAddressIndex uint64
MaxTxSizeLimit uint64
}

type TransactionValidator struct {
blocks Blocks
blocks Blocks // for looking up blocks to check transaction expiry
chain flow.Chain // for checking validity of addresses
options TransactionValidationOptions
}

func NewTransactionValidator(
blocks Blocks,
chain flow.Chain,
options TransactionValidationOptions,
) *TransactionValidator {
return &TransactionValidator{
blocks: blocks,
chain: chain,
options: options,
}
}

func (v *TransactionValidator) Validate(tx *flow.TransactionBody) (err error) {
err = v.checkTxSizeLimit(tx)
if err != nil {
return err
}

err = v.checkMissingFields(tx)
if err != nil {
return err
Expand All @@ -88,6 +101,22 @@ func (v *TransactionValidator) Validate(tx *flow.TransactionBody) (err error) {

// TODO check account/payer signatures

err = v.checkAddresses(tx)
if err != nil {
return err
}

return nil
}

func (v *TransactionValidator) checkTxSizeLimit(tx *flow.TransactionBody) error {
txSize := uint64(tx.ByteSize())
if txSize > v.options.MaxTxSizeLimit {
return InvalidTxByteSizeError{
Actual: txSize,
Maximum: v.options.MaxTxSizeLimit,
}
}
return nil
}

Expand Down Expand Up @@ -175,6 +204,33 @@ func (v *TransactionValidator) checkCanBeParsed(tx *flow.TransactionBody) error
return nil
}

func (v *TransactionValidator) checkAddresses(tx *flow.TransactionBody) error {

for _, address := range append(tx.Authorizers, tx.Payer) {
// first we check objective validity, essentially whether or not this
// is a valid output of the address generator
if !v.chain.IsValid(address) {
return InvalidAddressError{Address: address}
}

// skip second check if not configured
if v.options.MaxAddressIndex == 0 {
continue
}

// next we check subjective validity based on the configured maximum index
index, err := v.chain.IndexFromAddress(address)
if err != nil {
return fmt.Errorf("could not get index for address (%s): %w", address, err)
}
if index > v.options.MaxAddressIndex {
return InvalidAddressError{Address: address}
}
}

return nil
}

func remove(s []string, r string) []string {
for i, v := range s {
if v == r {
Expand Down
12 changes: 8 additions & 4 deletions cmd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ RUN mkdir /app
WORKDIR /app

ARG TARGET
ARG COMMIT
ARG VERSION

COPY . .

Expand Down Expand Up @@ -76,19 +78,21 @@ COPY --from=build-debug /app/app /bin/app

ENTRYPOINT ["dlv", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/bin/app"]

FROM build-env as build-production-nocgo
FROM build-env as build-transit-production-nocgo
WORKDIR /app

RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=ssh \
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-extldflags -static" -o ./app ./cmd/${TARGET}
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-extldflags -static \
-X 'github.com/onflow/flow-go/cmd/bootstrap/build.commit=${COMMIT}' -X 'github.com/onflow/flow-go/cmd/bootstrap/build.semver=${VERSION}'" \
-o ./app ./cmd/${TARGET}

RUN chmod a+x /app/app

## (3) Add the statically linked binary to a distroless image
FROM gcr.io/distroless/base as production-nocgo
FROM gcr.io/distroless/base as production-transit-nocgo

COPY --from=build-production-nocgo /app/app /bin/app
COPY --from=build-transit-production-nocgo /app/app /bin/app

ENTRYPOINT ["/bin/app"]
43 changes: 43 additions & 0 deletions cmd/bootstrap/build/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Package build contains information about the build that injected at build-time.
//
// To use this package, simply import it in your program, then add build
// arguments like the following:
//
// go build -ldflags "-X github.com/dapperlabs/flow-go/version.semver=v1.0.0"
package build

// Default value for build-time-injected version strings.
const undefined = "undefined"

// The following variables are injected at build-time using ldflags.
var (
semver string
commit string
)

// Semver returns the semantic version of this build.
func Semver() string {
return semver
}

// Commit returns the commit at which this build was created.
func Commit() string {
return commit
}

// IsDefined determines whether a version string is defined. Inputs should
// have been produced from this package.
func IsDefined(v string) bool {
return v != undefined
}

// If any of the build-time-injected variables are empty at initialization,
// mark them as undefined.
func init() {
if len(semver) == 0 {
semver = undefined
}
if len(commit) == 0 {
commit = undefined
}
}
76 changes: 76 additions & 0 deletions cmd/bootstrap/cmd/keygen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package cmd

import (
"fmt"
"io"
"os"

"github.com/spf13/cobra"

model "github.com/onflow/flow-go/model/bootstrap"
)

// keygenCmd represents the key gen command
var keygenCmd = &cobra.Command{
Use: "keygen",
Short: "Generate Staking and Networking keys for a list of nodes",
Long: `Generate Staking and Networking keys for a list of nodes provided by the flag '--config'`,
Run: func(cmd *cobra.Command, args []string) {
// check if out directory exists
exists, err := pathExists(flagOutdir)
if err != nil {
log.Error().Msg("could not check if directory exists")
return
}

// check if the out directory is empty or has contents
if exists {
empty, err := isEmptyDir(flagOutdir)
if err != nil {
log.Error().Msg("could not check if directory as empty")
return
}

if !empty {
log.Error().Msg("output directory already exists and has content. delete and try again.")
return
}
}

// create keys
log.Info().Msg("generating internal private networking and staking keys")
nodes := genNetworkAndStakingKeys([]model.NodeInfo{})
log.Info().Msg("")

// count roles
roleCounts := nodeCountByRole(nodes)
for role, count := range roleCounts {
log.Info().Msg(fmt.Sprintf("created keys for %d %s nodes", count, role.String()))
}
},
}

func init() {
rootCmd.AddCommand(keygenCmd)

// required parameters
keygenCmd.Flags().
StringVar(&flagConfig, "config", "--node-config.json", "path to a JSON file containing multiple node configurations (Role, Address, Stake)")
_ = keygenCmd.MarkFlagRequired("config")

}

// isEmptyDir returns True if the directory contains children
func isEmptyDir(path string) (bool, error) {
f, err := os.Open(path)
if err != nil {
return false, err
}
defer f.Close()

_, err = f.Readdirnames(1)
if err == io.EOF {
return true, nil
}
return false, err // Either not empty or error, suits both cases
}
29 changes: 29 additions & 0 deletions cmd/bootstrap/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"path/filepath"

"github.com/onflow/flow-go/crypto"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/utils/io"
)

Expand Down Expand Up @@ -78,3 +80,30 @@ func filesInDir(dir string) ([]string, error) {
})
return files, err
}

// pathExists
func pathExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

func nodeCountByRole(nodes []model.NodeInfo) map[flow.Role]uint16 {
roleCounts := map[flow.Role]uint16{
flow.RoleCollection: 0,
flow.RoleConsensus: 0,
flow.RoleExecution: 0,
flow.RoleVerification: 0,
flow.RoleAccess: 0,
}
for _, node := range nodes {
roleCounts[node.Role] = roleCounts[node.Role] + 1
}

return roleCounts
}
27 changes: 26 additions & 1 deletion cmd/bootstrap/transit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"google.golang.org/api/iterator"
"google.golang.org/api/option"

"github.com/onflow/flow-go/cmd/bootstrap/build"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
utilsio "github.com/onflow/flow-go/utils/io"
Expand All @@ -29,6 +30,8 @@ var (
FilenameTransitKeyPriv = "transit-key.priv.%v"
FilenameRandomBeaconCipher = bootstrap.FilenameRandomBeaconPriv + ".%v.enc"
flowBucket string
commit = build.Commit()
semver = build.Semver()
)

const fileMode = os.FileMode(0644)
Expand All @@ -53,8 +56,9 @@ var (
func main() {

var bootDir, keyDir, wrapID, role string
var pull, push, prepare bool
var version, pull, push, prepare bool

flag.BoolVar(&version, "v", false, "View version and commit information")
flag.StringVar(&bootDir, "d", "~/bootstrap", "The bootstrap directory containing your node-info files")
flag.StringVar(&keyDir, "t", "", "Token provided by the Flow team to access the transit server")
flag.BoolVar(&pull, "pull", false, "Fetch keys and metadata from the transit server")
Expand All @@ -65,6 +69,12 @@ func main() {
flag.StringVar(&flowBucket, "flow-bucket", "flow-genesis-bootstrap", "Storage for the transit server")
flag.Parse()

// always print version information
printVersion()
if version {
return
}

if role == "" {
flag.Usage()
log.Fatal("Node role must be specified")
Expand Down Expand Up @@ -132,6 +142,21 @@ func fetchNodeID(bootDir string) (string, error) {
return strings.TrimSpace(string(data)), nil
}

// Print the version and commit id
func printVersion() {
// Print version/commit strings if they are known
if build.IsDefined(semver) {
fmt.Printf("Transit script Version: %s\n", semver)
}
if build.IsDefined(commit) {
fmt.Printf("Transit script Commit: %s\n", commit)
}
// If no version info is known print a message to indicate this.
if !build.IsDefined(semver) && !build.IsDefined(commit) {
fmt.Printf("Transit script version information unknown\n")
}
}

// Run the push process
// - create transit keypair (if the role type is Consensus)
// - upload files to GCS bucket
Expand Down
Loading