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

FLIP 204: Add TargetDuration to Epoch models and API #4987 #5038

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
bc5e7ef
unit tests, integration tests using buildjet-4vcpu runner
gomisha Oct 30, 2023
fb69048
listTargetPackages() returns map of CI runners
gomisha Nov 1, 2023
291e71d
test for custom runners
gomisha Nov 1, 2023
e7a7f7e
generateTestMatrix() stores CI runner
gomisha Nov 1, 2023
371e4b3
more testing with custom CI runners
gomisha Nov 1, 2023
00117a4
CI test - 2 unit tests running buildjet runners
gomisha Nov 1, 2023
6a25c05
increase engine unit tests to 8 vCPUs
gomisha Nov 1, 2023
0a3854b
resource manager full load test (8 vCPUs)
gomisha Nov 2, 2023
983e488
network/test tests unquarantined, increased runners
gomisha Nov 2, 2023
0b422d5
Merge branch 'master' into misha/6894-buildjet-ci-test
gomisha Nov 2, 2023
6048198
increased to 16 vCPUs
gomisha Nov 2, 2023
eb81e79
increased engine tests to 16 vCPUs
gomisha Nov 3, 2023
d496e7f
insecure module uses buildjet 4 vcpu runner
gomisha Nov 3, 2023
d320b6b
bft framework integration test using buildjet
gomisha Nov 3, 2023
620d6a1
engine tests split up to 6 jobs with default runners
gomisha Nov 3, 2023
daeac5f
added back all integration tests
gomisha Nov 3, 2023
98c5197
upgraded runners for some integration tests, engine/execution
gomisha Nov 3, 2023
1259067
dummy commit to kick off CI
gomisha Nov 3, 2023
959bf17
split up TestScriptExecutionAndGetAccounts into 3 tests
gomisha Nov 3, 2023
027513c
updated runners for Epoch Cohort2, Access Integration Tests
gomisha Nov 6, 2023
e6a5ef3
AN integration tests split up into 3 cohorts (skip unit, other integr…
gomisha Nov 6, 2023
10c9edd
docker build using GitHub cache
gomisha Nov 6, 2023
c589487
remove saving Docker image locally
gomisha Nov 6, 2023
5998a0d
cache v3, saving local tar before caching, 8vcpu
gomisha Nov 6, 2023
9f86a31
add 11 docker images to docker-images.tar, 16 vcpu
gomisha Nov 6, 2023
ba1b00f
docker save multiline fix; skip localnet-test
gomisha Nov 6, 2023
544b877
docker build increase to 32 vcpu
gomisha Nov 6, 2023
99a9b9e
buildjet cache instead of GitHub cache
gomisha Nov 6, 2023
0e4d303
lint fix
gomisha Nov 6, 2023
94192f6
activate more integration tests with default runners, using cached Do…
gomisha Nov 6, 2023
c1f10f1
docker-build downsized to 16 vcpu
gomisha Nov 6, 2023
5ebfaa0
integration test without relic build
gomisha Nov 6, 2023
6ca0231
put back relic build for integration tests
gomisha Nov 6, 2023
8766f2a
put back all remaining integration tests using BuildJet runners
gomisha Nov 6, 2023
d637a60
Merge branch 'master' into misha/6894-buildjet-ci-test
gomisha Nov 6, 2023
deab1b1
Merge branch 'misha/6894-buildjet-ci-test' of https://github.com/onfl…
gomisha Nov 6, 2023
a9b3441
integration tests reverted to ubuntu-latest runners
gomisha Nov 7, 2023
034942d
re-activated unit-test, unit-test-modules jobs
gomisha Nov 7, 2023
3037af2
added (failing) test for sub-sub packages
gomisha Nov 7, 2023
35f4706
sub-sub packages support
gomisha Nov 7, 2023
1520df6
sub-sub package test enhanced
gomisha Nov 7, 2023
357d9c5
updated other tests to support new sub-sub packages
gomisha Nov 7, 2023
1591a60
split up engine/execution unit tests into 3 jobs
gomisha Nov 7, 2023
645fc0b
engine/execution/ingestion upgraded to 4 vcpu
gomisha Nov 7, 2023
37ecc81
engine/execution/ingestion:buildjet-8vcpu
gomisha Nov 8, 2023
f52d044
network/test, network/p2p increased to 8 vcpu; added remaining networ…
gomisha Nov 8, 2023
a4bfe9c
BFT Framework, Epoch Cohort 2 - increased to 4 vcpu
gomisha Nov 8, 2023
abc6048
upgraded runners for Access Cohort 1, Epoch Cohort 1, 2
gomisha Nov 8, 2023
91a5adf
epoch cohort2 upgraded to 16 vcpu
gomisha Nov 8, 2023
d0b29ce
BFT Framework upgrade to 8 vcpu, epoch cohort2 removed flaky test, do…
gomisha Nov 8, 2023
655cf1c
quarantined flaky test - TestEpochJoinAndLeaveVN
gomisha Nov 8, 2023
14e0019
quarantined flaky test - TestSealingAndVerificationPassThrough
gomisha Nov 8, 2023
b98a39d
Merge branch 'master' into misha/6894-buildjet-ci-test
gomisha Nov 8, 2023
e2b0cdc
lint fix
gomisha Nov 8, 2023
457ae50
network/test split up into network/test/cohort1, network/test/cohort2
gomisha Nov 8, 2023
1554902
network/p2p split up into 4 subpackages
gomisha Nov 8, 2023
7944c28
extracted network/alsp into separate job
gomisha Nov 8, 2023
6e03881
extracted module/dkg into separate job
gomisha Nov 8, 2023
52bd044
engine/execution/ingestion dowgraded to stock runner
gomisha Nov 8, 2023
32afbca
added engine parent package as separate job
gomisha Nov 8, 2023
d8df732
added storage parent package as separate job
gomisha Nov 8, 2023
ec2d6c5
added state package as separate job
gomisha Nov 8, 2023
43c862e
removed localnet-test job
gomisha Nov 8, 2023
d7c598d
engine/execution/ingestion upgraded to 2 vcpu
gomisha Nov 8, 2023
56a4a17
network/p2p/p2pnode upgraded to 2 vcpu
gomisha Nov 8, 2023
60c281e
module, engine upgraded to 2 vcpu
gomisha Nov 8, 2023
1423ee2
network/p2p/p2pnode upgraded to 4 vcpu
gomisha Nov 8, 2023
de74efb
network/test/cohort2 upgraded to 4 vcpu
gomisha Nov 8, 2023
4884166
engine upgraded to 4 vcpu
gomisha Nov 8, 2023
4ad3fa4
engine/execution/ingestion upgraded to 4 vcpu, network/test/cohort1 u…
gomisha Nov 8, 2023
acdb459
network/test/cohort1 upgraded to 4 vcpu
gomisha Nov 8, 2023
3ed7c01
engine/execution/ingestion upgraded to 8 vcpu
gomisha Nov 8, 2023
b540d8f
network/test/cohort1 upgraded to 8 vcpu
gomisha Nov 8, 2023
14b8c6c
BFT (Protocol) upgraded to 4 vcpu
gomisha Nov 8, 2023
ab7cd72
network/test/cohort1 upgraded to 16 vcpu
gomisha Nov 8, 2023
aa60cab
BFT (Protocol), Epoch Cohort1 upgraded to 8 vcpu
gomisha Nov 8, 2023
c1826f9
noop push to kick off CI
gomisha Nov 9, 2023
7c96928
Module (integration) upgraded to 4 vcpu
gomisha Nov 9, 2023
ac432e2
TestUnicastRateLimit_Messages flaky test quarantined
gomisha Nov 9, 2023
7c922cb
noop push to kick off CI
gomisha Nov 9, 2023
ced2ce9
buildjet/cache@v3 => actions/cache@v3
gomisha Nov 9, 2023
76e2f53
test retries increased to 5, timeout increased to 35 mins
gomisha Nov 9, 2023
47e71f9
module job increased to 4 vcpu
gomisha Nov 9, 2023
9f889cc
Merge branch 'master' into misha/6894-buildjet-ci-test
gomisha Nov 9, 2023
b60901b
unquarantined epoch flaky test after it was fixed
gomisha Nov 9, 2023
6761410
unlink flaky test monitor workflow from running when ci changes
gomisha Nov 9, 2023
131490c
Merge branch 'misha/6894-buildjet-ci-test' of https://github.com/onfl…
gomisha Nov 9, 2023
8d6dfe4
clean up
gomisha Nov 9, 2023
d9d1b42
lint fix
gomisha Nov 9, 2023
72e9efd
Merge pull request #4906 from onflow/misha/6894-buildjet-ci-test
gomisha Nov 10, 2023
867579e
Merge branch 'feature/flip-204-epoch-target-end-time' of github.com:o…
jordanschalm Nov 20, 2023
3df3443
add TargetDuration to models, conversion
jordanschalm Nov 20, 2023
813eaa5
bump core-contracts version
jordanschalm Nov 20, 2023
e9e235c
update state commitment constants in tests
jordanschalm Nov 20, 2023
e1a7050
tidy
jordanschalm Nov 20, 2023
7899406
update mocks
jordanschalm Nov 20, 2023
f2834e5
Update state/protocol/inmem/convert.go
jordanschalm Nov 23, 2023
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: 1 addition & 1 deletion engine/execution/computation/computer/computer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ func Test_ExecutingSystemCollection(t *testing.T) {
noopCollector := metrics.NewNoopCollector()

expectedNumberOfEvents := 3
expectedEventSize := 1457
expectedEventSize := 1478
// bootstrapping does not cache programs
expectedCachedPrograms := 0

Expand Down
2 changes: 1 addition & 1 deletion engine/execution/state/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestBootstrapLedger(t *testing.T) {
}

func TestBootstrapLedger_ZeroTokenSupply(t *testing.T) {
expectedStateCommitmentBytes, _ := hex.DecodeString("356275de4a0abb9674872397fe7d91aa1430ea0dcd9c5cc18bffc5e61a54cbc0")
expectedStateCommitmentBytes, _ := hex.DecodeString("03077009b61e3c7d185df77d21bf752cf4b48c69045f98e7e8f964cef135546b")
expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ require (
github.com/onflow/atree v0.6.0
github.com/onflow/cadence v0.42.4
github.com/onflow/flow v0.3.4
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b
github.com/onflow/flow-go-sdk v0.41.14
github.com/onflow/flow-go/crypto v0.24.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,8 @@ github.com/onflow/cadence v0.42.4 h1:KoXnwPCMcjixZv+gHZwWkDiAyVExJhJJe6SebdnHNv8
github.com/onflow/cadence v0.42.4/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE=
github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE=
github.com/onflow/flow v0.3.4/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b h1:TTN9nlagR6z0dlUGDGF6WK7jhIe5vB0Xayj3pyBk7mA=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122 h1:yUzR59WUue8BN/bfwy0eN4YOLYXeQ3G9I53H0amxbDU=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b h1:Q9iCekuCTeZU3CkVRTj5BhMBY/vR/uA2K63JTl5vCD8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 h1:B4ll7e3j+MqTJv2122Enq3RtDNzmIGRu9xjV7fo7un0=
Expand Down
2 changes: 1 addition & 1 deletion insecure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onflow/atree v0.6.0 // indirect
github.com/onflow/cadence v0.42.4 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b // indirect
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect
github.com/onflow/flow-go-sdk v0.41.14 // indirect
Expand Down
4 changes: 2 additions & 2 deletions insecure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,8 @@ github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVF
github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA=
github.com/onflow/cadence v0.42.4 h1:KoXnwPCMcjixZv+gHZwWkDiAyVExJhJJe6SebdnHNv8=
github.com/onflow/cadence v0.42.4/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b h1:TTN9nlagR6z0dlUGDGF6WK7jhIe5vB0Xayj3pyBk7mA=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122 h1:yUzR59WUue8BN/bfwy0eN4YOLYXeQ3G9I53H0amxbDU=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b h1:Q9iCekuCTeZU3CkVRTj5BhMBY/vR/uA2K63JTl5vCD8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 h1:B4ll7e3j+MqTJv2122Enq3RtDNzmIGRu9xjV7fo7un0=
Expand Down
2 changes: 1 addition & 1 deletion integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/ipfs/go-ds-badger2 v0.1.3
github.com/ipfs/go-ipfs-blockstore v1.3.0
github.com/onflow/cadence v0.42.4
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b
github.com/onflow/flow-emulator v0.54.1-0.20231024204057-0273f8fe3807
github.com/onflow/flow-go v0.32.3
Expand Down
4 changes: 2 additions & 2 deletions integration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1376,8 +1376,8 @@ github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVF
github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA=
github.com/onflow/cadence v0.42.4 h1:KoXnwPCMcjixZv+gHZwWkDiAyVExJhJJe6SebdnHNv8=
github.com/onflow/cadence v0.42.4/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b h1:TTN9nlagR6z0dlUGDGF6WK7jhIe5vB0Xayj3pyBk7mA=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231111185227-240579784e9b/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122 h1:yUzR59WUue8BN/bfwy0eN4YOLYXeQ3G9I53H0amxbDU=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231120143830-9e8417b56122/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b h1:Q9iCekuCTeZU3CkVRTj5BhMBY/vR/uA2K63JTl5vCD8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231111185227-240579784e9b/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4=
github.com/onflow/flow-emulator v0.54.1-0.20231024204057-0273f8fe3807 h1:/4jZ2oELdhKubgL97NGqhiuO80oMH/M+fIQoNPfGg+g=
Expand Down
15 changes: 14 additions & 1 deletion model/convert/service_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func convertServiceEventEpochSetup(event flow.Event) (*flow.ServiceEvent, error)
return nil, invalidCadenceTypeError("payload", payload, cadence.Event{})
}

const expectedFieldCount = 10
const expectedFieldCount = 11
if len(cdcEvent.Fields) < expectedFieldCount {
return nil, fmt.Errorf(
"insufficient fields in EpochSetup event (%d < %d)",
Expand All @@ -78,6 +78,7 @@ func convertServiceEventEpochSetup(event flow.Event) (*flow.ServiceEvent, error)
var dkgPhase3FinalView cadence.UInt64
var cdcClusters cadence.Array
var cdcParticipants cadence.Array
var targetDuration cadence.UInt64 // Epoch duration [seconds]
var targetEndTimeUnix cadence.UInt64 // Unix time [seconds]

var foundFieldCount int
Expand Down Expand Up @@ -152,6 +153,17 @@ func convertServiceEventEpochSetup(event flow.Event) (*flow.ServiceEvent, error)
)
}

case "targetDuration":
foundFieldCount++
targetDuration, ok = cdcEvent.Fields[i].(cadence.UInt64)
if !ok {
return nil, invalidCadenceTypeError(
"targetDuration",
cdcEvent.Fields[i],
cadence.UInt64(0),
)
}

case "targetEndTime":
foundFieldCount++
targetEndTimeUnix, ok = cdcEvent.Fields[i].(cadence.UInt64)
Expand Down Expand Up @@ -213,6 +225,7 @@ func convertServiceEventEpochSetup(event flow.Event) (*flow.ServiceEvent, error)
DKGPhase1FinalView: uint64(dkgPhase1FinalView),
DKGPhase2FinalView: uint64(dkgPhase2FinalView),
DKGPhase3FinalView: uint64(dkgPhase3FinalView),
TargetDuration: uint64(targetDuration),
TargetEndTime: uint64(targetEndTimeUnix),
}

Expand Down
1 change: 1 addition & 0 deletions model/flow/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type EpochSetup struct {
Participants IdentityList // all participants of the epoch
Assignments AssignmentList // cluster assignment for the epoch
RandomSource []byte // source of randomness for epoch-specific setup tasks
TargetDuration uint64 // desired real-world duration for the epoch [seconds]
TargetEndTime uint64 // desired real-world end time for the epoch in UNIX time [seconds]
}

Expand Down
9 changes: 9 additions & 0 deletions state/protocol/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ type Epoch interface {
// * state.ErrUnknownSnapshotReference - if the epoch is queried from an unresolvable snapshot.
FinalView() (uint64, error)

// TargetDuration returns the desired real-world duration for this epoch, in seconds.
// This target is specified by the FlowEpoch smart contract along the TargetEndTime in
// the EpochSetup event and used by the Cruise Control system to moderate the block rate.
// Error returns:
// * protocol.ErrNoPreviousEpoch - if the epoch represents a previous epoch which does not exist.
// * protocol.ErrNextEpochNotSetup - if the epoch represents a next epoch which has not been set up.
// * state.ErrUnknownSnapshotReference - if the epoch is queried from an unresolvable snapshot.
TargetDuration() (uint64, error)

// TargetEndTime returns the desired real-world end time for this epoch, represented as
// Unix Time (in units of seconds). This target is specified by the FlowEpoch smart contract in
// the EpochSetup event and used by the Cruise Control system to moderate the block rate.
Expand Down
4 changes: 4 additions & 0 deletions state/protocol/inmem/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ func FromEpoch(from protocol.Epoch) (*Epoch, error) {
if err != nil {
return nil, fmt.Errorf("could not get random source: %w", err)
}
epoch.TargetDuration, err = from.TargetDuration()
if err != nil {
return nil, fmt.Errorf("could not get target epoch duration: %w", err)
}
epoch.TargetEndTime, err = from.TargetEndTime()
if err != nil {
return nil, fmt.Errorf("could not get target end time: %w", err)
Expand Down
1 change: 1 addition & 0 deletions state/protocol/inmem/encodable.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type EncodableEpoch struct {
DKGPhase3FinalView uint64
FinalView uint64
RandomSource []byte
TargetDuration uint64 // desired real-world end time for the epoch in seconds
TargetEndTime uint64 // desired real-world end time for the epoch in unix time [seconds]
InitialIdentities flow.IdentityList
Clustering flow.ClusterList
Expand Down
14 changes: 14 additions & 0 deletions state/protocol/inmem/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ func (e Epoch) RandomSource() ([]byte, error) {
return e.enc.RandomSource, nil
}

// TargetDuration returns the desired real-world duration for this epoch, in seconds.
// This target is specified by the FlowEpoch smart contract in the EpochSetup event
// and used by the Cruise Control system to moderate the block rate.
func (e Epoch) TargetDuration() (uint64, error) {
return e.enc.TargetDuration, nil
}

// TargetEndTime returns the desired real-world end time for this epoch, represented as
// Unix Time (in units of seconds). This target is specified by the FlowEpoch smart contract in
// the EpochSetup event and used by the Cruise Control system to moderate the block rate.
Expand Down Expand Up @@ -150,6 +157,13 @@ func (es *setupEpoch) FinalView() (uint64, error) {
return es.setupEvent.FinalView, nil
}

// TargetDuration returns the desired real-world duration for this epoch, in seconds.
// This target is specified by the FlowEpoch smart contract in the EpochSetup event
// and used by the Cruise Control system to moderate the block rate.
func (es *setupEpoch) TargetDuration() (uint64, error) {
return es.setupEvent.TargetDuration, nil
}

// TargetEndTime returns the desired real-world end time for this epoch, represented as
// Unix Time (in units of seconds). This target is specified by the FlowEpoch smart contract in
// the EpochSetup event and used by the Cruise Control system to moderate the block rate.
Expand Down
4 changes: 4 additions & 0 deletions state/protocol/invalid/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (u *Epoch) RandomSource() ([]byte, error) {
return nil, u.err
}

func (u *Epoch) TargetDuration() (uint64, error) {
return 0, u.err
}

func (u *Epoch) TargetEndTime() (uint64, error) {
return 0, u.err
}
Expand Down
24 changes: 24 additions & 0 deletions state/protocol/mock/epoch.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions utils/unittest/execution_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256
const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256

// Pre-calculated state commitment with root account with the above private key
const GenesisStateCommitmentHex = "b9a64ba52bcbc795c162d69655d645fac70dda9395587590e06bab98669dc9df"
const GenesisStateCommitmentHex = "3b3197e640e7bc171e73cfeb0c26b779fda0c28af383fefff60b3d47e8a4d38e"

var GenesisStateCommitment flow.StateCommitment

Expand Down Expand Up @@ -88,10 +88,10 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string {
return GenesisStateCommitmentHex
}
if chainID == flow.Testnet {
return "498844490ee8718b5c0362f4405c61356c771845718efc2841530772f8f425be"
return "7192a942310f70b21579f3e3bbf6f381a2c350e23130b465aa6a25f4c7612d87"
}
if chainID == flow.Sandboxnet {
return "e1c08b17f9e5896f03fe28dd37ca396c19b26628161506924fbf785834646ea1"
}
return "80d6a73ca02abd8900fa325edbb5014d91475409ae39fe0eb7925ef85d1647e3"
return "93fc7a1d086c25794822a034288f33580bd1eca485ffab1a36691590518606fa"
}
8 changes: 8 additions & 0 deletions utils/unittest/service_events_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func EpochSetupFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.EpochSetu
DKGPhase2FinalView: 160,
DKGPhase3FinalView: 170,
RandomSource: randomSource,
TargetDuration: 200,
TargetEndTime: 2000000000,
Assignments: flow.AssignmentList{
{
Expand Down Expand Up @@ -205,6 +206,9 @@ func createEpochSetupEvent() cadence.Event {
// DKGPhase3FinalView
cadence.UInt64(170),

// targetDuration
cadence.UInt64(200),

// targetEndTime
cadence.UInt64(2000000000),
}).WithType(newFlowEpochEpochSetupEventType())
Expand Down Expand Up @@ -885,6 +889,10 @@ func newFlowEpochEpochSetupEventType() *cadence.EventType {
Identifier: "DKGPhase3FinalView",
Type: cadence.UInt64Type{},
},
{
Identifier: "targetDuration",
Type: cadence.UInt64Type{},
},
{
Identifier: "targetEndTime",
Type: cadence.UInt64Type{},
Expand Down
Loading