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

Sync stable-cadence branch with master #5400

Merged
merged 128 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
2c0621f
Sync with `master` to get CI improvements (#4995)
jordanschalm Nov 10, 2023
b86e354
FLIP 204: Add `TargetEndTime` to Epoch models and API (#4987)
jordanschalm Nov 17, 2023
445e0ab
FLIP 204: Add `TargetDuration` to Epoch models and API #4987 (#5038)
jordanschalm Nov 23, 2023
de721aa
FLIP 204: Update `cruisectl.BlockTimeController` to use `TargetEndTim…
jordanschalm Nov 24, 2023
64356c8
Sync `master` with `feature-flip-204` (#5057)
jordanschalm Nov 27, 2023
3e5b651
FLIP 204: Include epoch timing config in sporking/bootstrapping proce…
jordanschalm Nov 27, 2023
acdd1ec
Sync master / FLIP 204 (#5063)
jordanschalm Nov 27, 2023
0b64668
Sync master / FLIP 204 (#5065)
jordanschalm Nov 28, 2023
2479faa
Merge branch 'master' into feature/flip-204-epoch-target-end-time
jordanschalm Nov 28, 2023
ef2a908
use crypto v0.24.9 in all modules
jordanschalm Nov 28, 2023
afcbff2
Merge branch 'master' into jordan/feat/flip204
jordanschalm Nov 28, 2023
4d9a41f
Merge branch 'master' into jordan/feat/flip204
jordanschalm Dec 5, 2023
714a626
wip: pin branch commit of updated flow-emu
jordanschalm Dec 5, 2023
b1d4e2c
correct flow-emu version and update core-contracts to v0.15.0
jordanschalm Dec 5, 2023
0c32573
Merge branch 'master' into jordan/feat/flip204
jordanschalm Dec 6, 2023
dd78843
update flow-emulator to v0.59.0
jordanschalm Dec 6, 2023
c1dde1b
tidy
jordanschalm Dec 6, 2023
e766833
Merge branch 'master' into jordan/feat/flip204
jordanschalm Dec 6, 2023
00f109d
Apply suggestions from code review
jordanschalm Dec 8, 2023
c3c6fc9
add sanity check for target end time
jordanschalm Dec 8, 2023
3d8753d
remove unused param from initEpochInfo
jordanschalm Dec 8, 2023
2f11b11
Update cmd/bootstrap/cmd/seal.go
jordanschalm Dec 18, 2023
e3e0daf
epoch timing flag requirements
jordanschalm Dec 22, 2023
894151a
Add EVM load
janezpodhostnik Jan 26, 2024
8b162a2
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 1, 2024
b86f936
make tidy
jordanschalm Feb 1, 2024
3aabf33
leftover merge artifact and import ordering
jordanschalm Feb 1, 2024
4b35c39
update state commentments
jordanschalm Feb 1, 2024
d909f97
rename to selector
ramtinms Feb 1, 2024
74f60d1
add abi utility
ramtinms Feb 1, 2024
eaf39d9
add coa ownership proofs
ramtinms Feb 1, 2024
deba603
add coa proof to handler
ramtinms Feb 1, 2024
bb22d11
add coa proof verifier to evm contract
ramtinms Feb 1, 2024
85415c1
fix test utils
ramtinms Feb 1, 2024
1b8f32c
fix the rootAddr mismatch bug
ramtinms Feb 1, 2024
e11dae9
add test for arch flow height lookup
ramtinms Feb 1, 2024
3f3cbc1
add test for COA proofs
ramtinms Feb 1, 2024
de87a5b
test clean up
ramtinms Feb 2, 2024
1ae6759
reorg epoch timing config flags
jordanschalm Feb 2, 2024
8002974
update BN2 Makefile bootstrapping
jordanschalm Feb 2, 2024
5004491
consolidate epoch setup fixtures, fix test
jordanschalm Feb 2, 2024
bbf67a0
fix a bad copy-paste
jordanschalm Feb 2, 2024
603a48f
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 2, 2024
fa4b24e
tps gen changes
janezpodhostnik Feb 5, 2024
6e4820b
temp only bench last commit
janezpodhostnik Feb 5, 2024
13c03a6
fix tps server scripts
janezpodhostnik Feb 5, 2024
49cc60d
fix control script
janezpodhostnik Feb 5, 2024
98ebe77
fix transaction sender
janezpodhostnik Feb 5, 2024
7a01db8
remove compute limit
janezpodhostnik Feb 5, 2024
7979d5b
signers are not concurency safe
janezpodhostnik Feb 5, 2024
f17116e
fix err handling
janezpodhostnik Feb 5, 2024
c26520a
improve subscription validator integration test
kc1116 Feb 6, 2024
c685c39
fix err handling
janezpodhostnik Feb 6, 2024
fbb5fad
Update cmd/bootstrap/cmd/finalize.go
jordanschalm Feb 6, 2024
226727e
add additional flag to bootstrap readme
jordanschalm Feb 6, 2024
096d016
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 6, 2024
209f901
fix commit ordering
janezpodhostnik Feb 6, 2024
173a00f
fix service account handling
janezpodhostnik Feb 6, 2024
d8b0204
fix account creation
janezpodhostnik Feb 6, 2024
10ee110
fix error handling
janezpodhostnik Feb 6, 2024
a698961
fix logging
janezpodhostnik Feb 6, 2024
ae74a84
account creation debugging
janezpodhostnik Feb 6, 2024
6b65067
do not reuse signers accross threads
janezpodhostnik Feb 6, 2024
1cada3d
reduce create account load
janezpodhostnik Feb 6, 2024
0b23892
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 6, 2024
a119066
use load type from parameters
janezpodhostnik Feb 6, 2024
323d090
reduce accounts created at once
janezpodhostnik Feb 6, 2024
2d185b2
fix evm load type name
janezpodhostnik Feb 6, 2024
3b734e1
increase timeout
janezpodhostnik Feb 6, 2024
686a182
Update network/internal/p2pfixtures/fixtures.go
kc1116 Feb 7, 2024
63b7196
Update network/internal/p2pfixtures/fixtures.go
kc1116 Feb 7, 2024
1691bb3
Update fixtures.go
kc1116 Feb 7, 2024
e385b9b
Merge branch 'khalil/6932-fix-subscription-validator-test' of github.…
kc1116 Feb 7, 2024
82baeba
Merge branch 'master' into khalil/6932-fix-subscription-validator-test
kc1116 Feb 7, 2024
541905b
add setup to evm transfer load
janezpodhostnik Feb 7, 2024
7ca7296
fix evm_load
janezpodhostnik Feb 7, 2024
fd10f1d
make setup faster
janezpodhostnik Feb 7, 2024
433ca90
bugfix on account loading
janezpodhostnik Feb 7, 2024
d1454de
fix tests
janezpodhostnik Feb 7, 2024
7f125b6
fix tests
janezpodhostnik Feb 7, 2024
13f1134
reduce batch size for account creation
janezpodhostnik Feb 7, 2024
f427fd2
Merge branch 'master' into janez/tps-benchmark-evm-load
janezpodhostnik Feb 7, 2024
ec07042
fix evm load
janezpodhostnik Feb 8, 2024
30d8805
cleanup
janezpodhostnik Feb 8, 2024
cc7e059
add todo
janezpodhostnik Feb 8, 2024
741008f
Merge branch 'master' into ramtin/5197-part2-precompile
ramtinms Feb 8, 2024
50f2855
apply PR feedback
ramtinms Feb 8, 2024
7e4e216
apply PR feedback
ramtinms Feb 8, 2024
40c9647
rename functions
ramtinms Feb 8, 2024
b89ac22
add test for read uint256
ramtinms Feb 8, 2024
6f3d51c
add test for size needed for bytes
ramtinms Feb 8, 2024
7638b16
Merge branch 'ramtin/5197-part2-precompile' into ramtin/5197-part3-st…
ramtinms Feb 8, 2024
0b2c79f
fix test
ramtinms Feb 8, 2024
8311418
lint fix
ramtinms Feb 8, 2024
38d3730
log progress of loading wal segment file
zhangchiqing Feb 8, 2024
3eb7e8d
log storage init
zhangchiqing Feb 8, 2024
ac7cd2f
fix test
ramtinms Feb 9, 2024
d0577df
?
ramtinms Feb 9, 2024
927251c
upgrade wal
zhangchiqing Feb 9, 2024
eeaa7e9
lint fix
ramtinms Feb 9, 2024
6086e05
Merge branch 'ramtin/5197-part2-precompile' into ramtin/5197-part3-st…
ramtinms Feb 9, 2024
9374e87
clean up
ramtinms Feb 9, 2024
c2bdf70
move test contracts to its own files
ramtinms Feb 9, 2024
79b5462
Merge branch 'master' into ramtin/5197-part2-precompile
ramtinms Feb 10, 2024
99232e1
Update cmd/bootstrap/cmd/finalize.go
jordanschalm Feb 12, 2024
1baa345
Merge pull request #5342 from onflow/ramtin/5197-part2-precompile
ramtinms Feb 12, 2024
5f976ba
Merge branch 'master' into ramtin/5197-part3-stdlib
ramtinms Feb 12, 2024
11973b9
lint fix
ramtinms Feb 12, 2024
8fe3563
Merge branch 'ramtin/5197-part3-stdlib' of github.com:onflow/flow-go …
ramtinms Feb 12, 2024
b144ecf
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 13, 2024
52e7802
correct obo in error documentation
jordanschalm Feb 13, 2024
aefd300
update tests
ramtinms Feb 13, 2024
26ac4b4
Merge pull request #5343 from onflow/ramtin/5197-part3-stdlib
ramtinms Feb 13, 2024
9a016d8
Update module/executiondatasync/tracker/storage.go
zhangchiqing Feb 13, 2024
9a40970
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 13, 2024
d22727b
Merge pull request #5367 from onflow/leo/add-logs-for-en-startup
zhangchiqing Feb 13, 2024
4de14a3
edit control.sh
janezpodhostnik Feb 13, 2024
36d340f
Merge branch 'master' into jordan/feat/flip204
jordanschalm Feb 13, 2024
0421a12
Merge branch 'master' into janez/tps-benchmark-evm-load
janezpodhostnik Feb 14, 2024
e654b2d
Merge pull request #5071 from onflow/jordan/feat/flip204
jordanschalm Feb 14, 2024
ceec128
Merge pull request #5363 from onflow/janez/tps-benchmark-evm-load
janezpodhostnik Feb 14, 2024
ae8ab05
Merge pull request #5355 from onflow/khalil/6932-fix-subscription-val…
kc1116 Feb 14, 2024
cca11b7
Merge branch 'master' of https://github.com/onflow/flow-go into supun…
SupunS Feb 15, 2024
baf9cc3
Update EVM module to match Cadence changes
SupunS Feb 15, 2024
873396d
Fix code
SupunS Feb 15, 2024
21d646a
revert incorrect conflict resolution of wal dependency
turbolent Feb 15, 2024
a6db2d9
remove evm load from test untill its fixed
janezpodhostnik Feb 15, 2024
a60dda9
revert part of 873396d628b0b379ec2bb846f418b68a49f7d94a
turbolent Feb 15, 2024
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
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ generate-fvm-env-wrappers:
generate-mocks: install-mock-generators
mockery --name '(Connector|PingInfoProvider)' --dir=network/p2p --case=underscore --output="./network/mocknetwork" --outpkg="mocknetwork"
CGO_CFLAGS=$(CRYPTO_FLAG) mockgen -destination=storage/mocks/storage.go -package=mocks github.com/onflow/flow-go/storage Blocks,Headers,Payloads,Collections,Commits,Events,ServiceEvents,TransactionResults
# MERGE: Line below commented out on HEAD, uncommented on master
#CGO_CFLAGS=$(CRYPTO_FLAG) mockgen -destination=module/mocks/network.go -package=mocks github.com/onflow/flow-go/module Local,Requester
CGO_CFLAGS=$(CRYPTO_FLAG) mockgen -destination=network/mocknetwork/mock_network.go -package=mocknetwork github.com/onflow/flow-go/network EngineRegistry
mockery --name='.*' --dir=integration/benchmark/mocksiface --case=underscore --output="integration/benchmark/mock" --outpkg="mock"
mockery --name=ExecutionDataStore --dir=module/executiondatasync/execution_data --case=underscore --output="./module/executiondatasync/execution_data/mock" --outpkg="mock"
Expand Down
1 change: 1 addition & 0 deletions cmd/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ go run . rootblock \
--epoch-dkg-phase-length 2000 \
--collection-clusters 1 \
--protocol-version=0 \
--use-default-epoch-timing \
--epoch-commit-safety-threshold=1000 \
--config ./bootstrap-example/node-config.json \
-o ./bootstrap-example \
Expand Down
2 changes: 2 additions & 0 deletions cmd/bootstrap/cmd/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func constructRootEpochEvents(
Participants: participants.Sort(flow.Canonical[flow.Identity]).ToSkeleton(),
Assignments: assignments,
RandomSource: GenerateRandomSeed(flow.EpochSetupRandomSourceLength),
TargetDuration: flagEpochTimingDuration,
TargetEndTime: rootEpochTargetEndTime(),
}

qcsWithSignerIDs := make([]*flow.QuorumCertificateWithSignerIDs, 0, len(clusterQCs))
Expand Down
51 changes: 47 additions & 4 deletions cmd/bootstrap/cmd/finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"path/filepath"
"strings"
"time"

"github.com/onflow/cadence"

Expand Down Expand Up @@ -121,7 +122,7 @@ func finalize(cmd *cobra.Command, args []string) {
internalNodes := readInternalNodeInfos()
log.Info().Msg("")

log.Info().Msg("checking constraints on consensus/cluster nodes")
log.Info().Msg("checking constraints on consensus nodes")
checkConstraints(partnerNodes, internalNodes)
log.Info().Msg("")

Expand Down Expand Up @@ -162,7 +163,7 @@ func finalize(cmd *cobra.Command, args []string) {
// if no root commit is specified, bootstrap an empty execution state
if flagRootCommit == "0000000000000000000000000000000000000000000000000000000000000000" {
commit := generateEmptyExecutionState(
block.Header.ChainID,
block.Header,
intermediaryData.ExecutionStateConfig,
participants,
)
Expand Down Expand Up @@ -557,7 +558,7 @@ func readIntermediaryBootstrappingData() (*IntermediaryBootstrappingData, *flow.
// generateEmptyExecutionState generates a new empty execution state with the
// given configuration. Sets the flagRootCommit variable for future reads.
func generateEmptyExecutionState(
chainID flow.ChainID,
rootBlock *flow.Header,
epochConfig epochs.EpochConfig,
identities flow.IdentityList,
) (commit flow.StateCommitment) {
Expand All @@ -577,7 +578,8 @@ func generateEmptyExecutionState(
commit, err = run.GenerateExecutionState(
filepath.Join(flagOutdir, model.DirnameExecutionState),
serviceAccountPublicKey,
chainID.Chain(),
rootBlock.ChainID.Chain(),
fvm.WithRootBlock(rootBlock),
fvm.WithInitialTokenSupply(cdcInitialTokenSupply),
fvm.WithMinimumStorageReservation(fvm.DefaultMinimumStorageReservation),
fvm.WithAccountCreationFee(fvm.DefaultAccountCreationFee),
Expand All @@ -591,3 +593,44 @@ func generateEmptyExecutionState(
log.Info().Msg("")
return commit
}

// validateOrPopulateEpochTimingConfig validates the epoch timing config flags. In case the
// `flagUseDefaultEpochTargetEndTime` value has been set, the function derives the values for
// `flagEpochTimingRefCounter`, `flagEpochTimingDuration`, and `flagEpochTimingRefTimestamp`
// from the configuration. Otherwise, it enforces that compatible values for the respective parameters have been
// specified (and errors otherwise). Therefore, after `validateOrPopulateEpochTimingConfig` ran,
// the targeted end time for the epoch can be computed via `rootEpochTargetEndTime()`.
// You can either let the tool choose default values, or specify a value for each config.
func validateOrPopulateEpochTimingConfig() error {
// Default timing is intended for Benchnet, Localnet, etc.
// Manually specified timings for Mainnet, Testnet, Canary.
if flagUseDefaultEpochTargetEndTime {
// No other flags may be set
if !(flagEpochTimingRefTimestamp == 0 && flagEpochTimingDuration == 0 && flagEpochTimingRefCounter == 0) {
return fmt.Errorf("invalid epoch timing config: cannot specify ANY of --epoch-timing-ref-counter, --epoch-timing-ref-timestamp, or --epoch-timing-duration if using default timing config")
}
flagEpochTimingRefCounter = flagEpochCounter
flagEpochTimingDuration = flagNumViewsInEpoch
flagEpochTimingRefTimestamp = uint64(time.Now().Unix()) + flagNumViewsInEpoch

// compute target end time for initial (root) epoch from flags: `TargetEndTime = RefTimestamp + (RootEpochCounter - RefEpochCounter) * Duration`
rootEpochTargetEndTimeUNIX := rootEpochTargetEndTime()
rootEpochTargetEndTime := time.Unix(int64(rootEpochTargetEndTimeUNIX), 0)
log.Info().Msgf("using default epoch timing config with root epoch target end time %s, which is in %s", rootEpochTargetEndTime, time.Until(rootEpochTargetEndTime))
} else {
// All other flags must be set
// NOTE: it is valid for flagEpochTimingRefCounter to be set to 0
if flagEpochTimingRefTimestamp == 0 || flagEpochTimingDuration == 0 {
return fmt.Errorf("invalid epoch timing config: must specify ALL of --epoch-timing-ref-counter, --epoch-timing-ref-timestamp, and --epoch-timing-duration")
}
if flagEpochCounter < flagEpochTimingRefCounter {
return fmt.Errorf("invalid epoch timing config: reference epoch counter must be less than or equal to root epoch counter")
}

// compute target end time for initial (root) epoch from flags: `TargetEndTime = RefTimestamp + (RootEpochCounter - RefEpochCounter) * Duration`
rootEpochTargetEndTimeUNIX := rootEpochTargetEndTime()
rootEpochTargetEndTime := time.Unix(int64(rootEpochTargetEndTimeUNIX), 0)
log.Info().Msgf("using user-specified epoch timing config with root epoch target end time %s, which is in %s", rootEpochTargetEndTime, time.Until(rootEpochTargetEndTime))
}
return nil
}
52 changes: 51 additions & 1 deletion cmd/bootstrap/cmd/finalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cmd

import (
"encoding/hex"
"fmt"
"math/rand"
"path/filepath"
"regexp"
"strings"
Expand All @@ -23,7 +25,7 @@ const finalizeHappyPathLogs = "collecting partner network and staking keys" +
`read \d+ internal private node-info files` +
`read internal node configurations` +
`read \d+ weights for internal nodes` +
`checking constraints on consensus/cluster nodes` +
`checking constraints on consensus nodes` +
`assembling network and staking keys` +
`reading root block data` +
`reading root block votes` +
Expand Down Expand Up @@ -72,6 +74,10 @@ func TestFinalize_HappyPath(t *testing.T) {
flagNumViewsInStakingAuction = 50_000
flagNumViewsInDKGPhase = 2_000
flagEpochCommitSafetyThreshold = 1_000
flagUseDefaultEpochTargetEndTime = true
flagEpochTimingRefCounter = 0
flagEpochTimingRefTimestamp = 0
flagEpochTimingDuration = 0

// rootBlock will generate DKG and place it into bootDir/public-root-information
rootBlock(nil, nil)
Expand All @@ -85,6 +91,7 @@ func TestFinalize_HappyPath(t *testing.T) {
log = log.Hook(hook)

finalize(nil, nil)
fmt.Println(hook.logs.String())
assert.Regexp(t, finalizeHappyPathRegex, hook.logs.String())
hook.logs.Reset()

Expand Down Expand Up @@ -117,6 +124,49 @@ func TestClusterAssignment(t *testing.T) {
flagCollectionClusters = tmp
}

func TestEpochTimingConfig(t *testing.T) {
// Reset flags after test is completed
defer func(_flagDefault bool, _flagRefCounter, _flagRefTs, _flagDur uint64) {
flagUseDefaultEpochTargetEndTime = _flagDefault
flagEpochTimingRefCounter = _flagRefCounter
flagEpochTimingRefTimestamp = _flagRefTs
flagEpochTimingDuration = _flagDur
}(flagUseDefaultEpochTargetEndTime, flagEpochTimingRefCounter, flagEpochTimingRefTimestamp, flagEpochTimingDuration)

flags := []*uint64{&flagEpochTimingRefCounter, &flagEpochTimingRefTimestamp, &flagEpochTimingDuration}
t.Run("if default is set, no other flag may be set", func(t *testing.T) {
flagUseDefaultEpochTargetEndTime = true
for _, flag := range flags {
*flag = rand.Uint64()%100 + 1
err := validateOrPopulateEpochTimingConfig()
assert.Error(t, err)
*flag = 0 // set the flag back to 0
}
err := validateOrPopulateEpochTimingConfig()
assert.NoError(t, err)
})

t.Run("if default is not set, all other flags must be set", func(t *testing.T) {
flagUseDefaultEpochTargetEndTime = false
// First set all required flags and ensure validation passes
flagEpochTimingRefCounter = rand.Uint64() % flagEpochCounter
flagEpochTimingDuration = rand.Uint64()%100_000 + 1
flagEpochTimingRefTimestamp = rand.Uint64()

err := validateOrPopulateEpochTimingConfig()
assert.NoError(t, err)

// Next, check that validation fails if any one flag is not set
// NOTE: we do not include refCounter here, because it is allowed to be zero.
for _, flag := range []*uint64{&flagEpochTimingRefTimestamp, &flagEpochTimingDuration} {
*flag = 0
err := validateOrPopulateEpochTimingConfig()
assert.Error(t, err)
*flag = rand.Uint64()%100 + 1 // set the flag back to a non-zero value
}
})
}

// Check about the number of internal/partner nodes in each cluster. The identites
// in each cluster do not matter for this check.
func checkClusterConstraint(clusters flow.ClusterList, partnersInfo []model.NodeInfo, internalsInfo []model.NodeInfo) bool {
Expand Down
28 changes: 28 additions & 0 deletions cmd/bootstrap/cmd/rootblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ var (
flagNumViewsInEpoch uint64
flagNumViewsInStakingAuction uint64
flagNumViewsInDKGPhase uint64
// Epoch target end time config
flagUseDefaultEpochTargetEndTime bool
flagEpochTimingRefCounter uint64
flagEpochTimingRefTimestamp uint64
flagEpochTimingDuration uint64
)

// rootBlockCmd represents the rootBlock command
Expand Down Expand Up @@ -95,6 +100,25 @@ func addRootBlockCmdFlags() {
cmd.MarkFlagRequired(rootBlockCmd, "root-height")
cmd.MarkFlagRequired(rootBlockCmd, "protocol-version")
cmd.MarkFlagRequired(rootBlockCmd, "epoch-commit-safety-threshold")

// Epoch timing config - these values must be set identically to `EpochTimingConfig` in the FlowEpoch smart contract.
// See https://github.com/onflow/flow-core-contracts/blob/240579784e9bb8d97d91d0e3213614e25562c078/contracts/epochs/FlowEpoch.cdc#L259-L266
// Must specify either:
// 1. --use-default-epoch-timing and no other `--epoch-timing*` flags
// 2. All `--epoch-timing*` flags except --use-default-epoch-timing
//
// Use Option 1 for Benchnet, Localnet, etc.
// Use Option 2 for Mainnet, Testnet, Canary.
rootBlockCmd.Flags().BoolVar(&flagUseDefaultEpochTargetEndTime, "use-default-epoch-timing", false, "whether to use the default target end time")
rootBlockCmd.Flags().Uint64Var(&flagEpochTimingRefCounter, "epoch-timing-ref-counter", 0, "the reference epoch for computing the root epoch's target end time")
rootBlockCmd.Flags().Uint64Var(&flagEpochTimingRefTimestamp, "epoch-timing-ref-timestamp", 0, "the end time of the reference epoch, specified in second-precision Unix time, to use to compute the root epoch's target end time")
rootBlockCmd.Flags().Uint64Var(&flagEpochTimingDuration, "epoch-timing-duration", 0, "the duration of each epoch in seconds, used to compute the root epoch's target end time")

rootBlockCmd.MarkFlagsOneRequired("use-default-epoch-timing", "epoch-timing-ref-counter", "epoch-timing-ref-timestamp", "epoch-timing-duration")
rootBlockCmd.MarkFlagsRequiredTogether("epoch-timing-ref-counter", "epoch-timing-ref-timestamp", "epoch-timing-duration")
for _, flag := range []string{"epoch-timing-ref-counter", "epoch-timing-ref-timestamp", "epoch-timing-duration"} {
rootBlockCmd.MarkFlagsMutuallyExclusive("use-default-epoch-timing", flag)
}
}

func rootBlock(cmd *cobra.Command, args []string) {
Expand All @@ -114,6 +138,10 @@ func rootBlock(cmd *cobra.Command, args []string) {
if err != nil {
log.Fatal().Err(err).Msg("invalid or unsafe epoch commit threshold config")
}
err = validateOrPopulateEpochTimingConfig()
if err != nil {
log.Fatal().Err(err).Msg("invalid epoch timing config")
}

log.Info().Msg("collecting partner network and staking keys")
partnerNodes := readPartnerNodeInfos()
Expand Down
4 changes: 4 additions & 0 deletions cmd/bootstrap/cmd/rootblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func TestRootBlock_HappyPath(t *testing.T) {
flagNumViewsInDKGPhase = 2_000
flagEpochCommitSafetyThreshold = 1_000
flagProtocolVersion = 42
flagUseDefaultEpochTargetEndTime = true
flagEpochTimingRefCounter = 0
flagEpochTimingRefTimestamp = 0
flagEpochTimingDuration = 0

hook := zeroLoggerHook{logs: &strings.Builder{}}
log = log.Hook(hook)
Expand Down
20 changes: 20 additions & 0 deletions cmd/bootstrap/cmd/seal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"encoding/hex"
"time"

"github.com/onflow/flow-go/cmd/bootstrap/run"
"github.com/onflow/flow-go/model/flow"
Expand Down Expand Up @@ -38,3 +39,22 @@ func constructRootResultAndSeal(

return result, seal
}

// rootEpochTargetEndTime computes the target end time for the given epoch, using the given config.
// CAUTION: the variables `flagEpochTimingRefCounter`, `flagEpochTimingDuration`, and
// `flagEpochTimingRefTimestamp` must contain proper values. You can either specify a value for
// each config parameter or use the function `validateOrPopulateEpochTimingConfig()` to populate the variables
// from defaults.
func rootEpochTargetEndTime() uint64 {
if flagEpochTimingRefTimestamp == 0 || flagEpochTimingDuration == 0 {
panic("invalid epoch timing config: must specify ALL of --epoch-target-end-time-ref-counter, --epoch-target-end-time-ref-timestamp, and --epoch-target-end-time-duration")
}
if flagEpochCounter < flagEpochTimingRefCounter {
panic("invalid epoch timing config: reference epoch counter must be less than or equal to root epoch counter")
}
targetEndTime := flagEpochTimingRefTimestamp + (flagEpochCounter-flagEpochTimingRefCounter)*flagEpochTimingDuration
if targetEndTime <= uint64(time.Now().Unix()) {
panic("sanity check failed: root epoch target end time is before current time")
}
return targetEndTime
}
10 changes: 0 additions & 10 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func main() {
emergencySealing bool
dkgMessagingEngineConfig = dkgeng.DefaultMessagingEngineConfig()
cruiseCtlConfig = cruisectl.DefaultConfig()
cruiseCtlTargetTransitionTimeFlag = cruiseCtlConfig.TargetTransition.String()
cruiseCtlFallbackProposalDurationFlag time.Duration
cruiseCtlMinViewDurationFlag time.Duration
cruiseCtlMaxViewDurationFlag time.Duration
Expand Down Expand Up @@ -148,7 +147,6 @@ func main() {
flags.DurationVar(&hotstuffMinTimeout, "hotstuff-min-timeout", 2500*time.Millisecond, "the lower timeout bound for the hotstuff pacemaker, this is also used as initial timeout")
flags.Float64Var(&hotstuffTimeoutAdjustmentFactor, "hotstuff-timeout-adjustment-factor", timeout.DefaultConfig.TimeoutAdjustmentFactor, "adjustment of timeout duration in case of time out event")
flags.Uint64Var(&hotstuffHappyPathMaxRoundFailures, "hotstuff-happy-path-max-round-failures", timeout.DefaultConfig.HappyPathMaxRoundFailures, "number of failed rounds before first timeout increase")
flags.StringVar(&cruiseCtlTargetTransitionTimeFlag, "cruise-ctl-target-epoch-transition-time", cruiseCtlTargetTransitionTimeFlag, "the target epoch switchover schedule")
flags.DurationVar(&cruiseCtlFallbackProposalDurationFlag, "cruise-ctl-fallback-proposal-duration", cruiseCtlConfig.FallbackProposalDelay.Load(), "the proposal duration value to use when the controller is disabled, or in epoch fallback mode. In those modes, this value has the same as the old `--block-rate-delay`")
flags.DurationVar(&cruiseCtlMinViewDurationFlag, "cruise-ctl-min-view-duration", cruiseCtlConfig.MinViewDuration.Load(), "the lower bound of authority for the controller, when active. This is the smallest amount of time a view is allowed to take.")
flags.DurationVar(&cruiseCtlMaxViewDurationFlag, "cruise-ctl-max-view-duration", cruiseCtlConfig.MaxViewDuration.Load(), "the upper bound of authority for the controller when active. This is the largest amount of time a view is allowed to take.")
Expand All @@ -174,14 +172,6 @@ func main() {
startupTime = t
nodeBuilder.Logger.Info().Time("startup_time", startupTime).Msg("got startup_time")
}
// parse target transition time string, if set
if cruiseCtlTargetTransitionTimeFlag != cruiseCtlConfig.TargetTransition.String() {
transitionTime, err := cruisectl.ParseTransition(cruiseCtlTargetTransitionTimeFlag)
if err != nil {
return fmt.Errorf("invalid epoch transition time string: %w", err)
}
cruiseCtlConfig.TargetTransition = *transitionTime
}
// convert local flag variables to atomic config variables, for dynamically updatable fields
if cruiseCtlEnabledFlag != cruiseCtlConfig.Enabled.Load() {
cruiseCtlConfig.Enabled.Store(cruiseCtlEnabledFlag)
Expand Down
3 changes: 3 additions & 0 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,7 @@ func (fnb *FlowNodeBuilder) initFvmOptions() {

// handleModules initializes the given module.
func (fnb *FlowNodeBuilder) handleModule(v namedModuleFunc) error {
fnb.Logger.Info().Str("module", v.name).Msg("module initialization started")
err := v.fn(fnb.NodeConfig)
if err != nil {
return fmt.Errorf("module %s initialization failed: %w", v.name, err)
Expand Down Expand Up @@ -1398,6 +1399,7 @@ func (fnb *FlowNodeBuilder) handleComponent(v namedComponentFunc, dependencies <

logger := fnb.Logger.With().Str("component", v.name).Logger()

logger.Info().Msg("component initialization started")
// First, build the component using the factory method.
readyAware, err := v.fn(fnb.NodeConfig)
if err != nil {
Expand Down Expand Up @@ -1469,6 +1471,7 @@ func (fnb *FlowNodeBuilder) handleRestartableComponent(v namedComponentFunc, par

// This may be called multiple times if the component is restarted
componentFactory := func() (component.Component, error) {
log.Info().Msg("component initialization started")
c, err := v.fn(fnb.NodeConfig)
if err != nil {
return nil, err
Expand Down
Loading
Loading