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

Re-enable test TestProtocolVersionUpgrade #6752

Open
wants to merge 7 commits into
base: jord/6622-chunk-service-events
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ require (
github.com/onflow/cadence v1.0.0-preview.52
github.com/onflow/crypto v0.25.2
github.com/onflow/flow v0.3.4
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d
github.com/onflow/flow-go-sdk v1.0.0-preview.55
github.com/onflow/flow/protobuf/go/flow v0.4.7
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,10 @@ github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns=
github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY=
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.3.2-0.20241025200435-872ffe7410e6 h1:G3rQ9gRDxdiW1TUz0RaPPT1R5cSAcd8byhb+UiRn/Xo=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6 h1:gDn+waxuTie03H7RdIkesue1LI+1pg/AxqEK2wlnyJE=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d h1:+Ky17U+AFQxtru/CRGoW+dUtn4+wETh2Yx2xxq/7odU=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d h1:7EAZjUgdL5gc1/mS01vzs4WKUdNl3GzxNOoai0tPdw4=
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
Expand Down
4 changes: 2 additions & 2 deletions insecure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.8.0-rc.6 // indirect
github.com/onflow/cadence v1.0.0-preview.52 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
github.com/onflow/flow-go-sdk v1.0.0-preview.55 // indirect
Expand Down
8 changes: 4 additions & 4 deletions insecure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,10 @@ github.com/onflow/cadence v1.0.0-preview.52 h1:hZ92e6lL2+PQa3C1i5jJh0zZYFdW89+X1
github.com/onflow/cadence v1.0.0-preview.52/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU=
github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns=
github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6 h1:G3rQ9gRDxdiW1TUz0RaPPT1R5cSAcd8byhb+UiRn/Xo=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6 h1:gDn+waxuTie03H7RdIkesue1LI+1pg/AxqEK2wlnyJE=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d h1:+Ky17U+AFQxtru/CRGoW+dUtn4+wETh2Yx2xxq/7odU=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d h1:7EAZjUgdL5gc1/mS01vzs4WKUdNl3GzxNOoai0tPdw4=
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
Expand Down
4 changes: 2 additions & 2 deletions integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ require (
github.com/libp2p/go-libp2p v0.32.2
github.com/onflow/cadence v1.0.0-preview.52
github.com/onflow/crypto v0.25.2
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d
github.com/onflow/flow-emulator v1.0.0-preview.41.0.20240829134601-0be55d6970b5
github.com/onflow/flow-go v0.37.7-0.20240826193109-e211841b59f5
github.com/onflow/flow-go-sdk v1.0.0-preview.55
Expand Down
8 changes: 4 additions & 4 deletions integration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,10 @@ github.com/onflow/cadence v1.0.0-preview.52 h1:hZ92e6lL2+PQa3C1i5jJh0zZYFdW89+X1
github.com/onflow/cadence v1.0.0-preview.52/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU=
github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns=
github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6 h1:G3rQ9gRDxdiW1TUz0RaPPT1R5cSAcd8byhb+UiRn/Xo=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.2-0.20241025200435-872ffe7410e6/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6 h1:gDn+waxuTie03H7RdIkesue1LI+1pg/AxqEK2wlnyJE=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.2-0.20241025200435-872ffe7410e6/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d h1:+Ky17U+AFQxtru/CRGoW+dUtn4+wETh2Yx2xxq/7odU=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.1-0.20241029155424-807cf69d387d/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d h1:7EAZjUgdL5gc1/mS01vzs4WKUdNl3GzxNOoai0tPdw4=
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20241029155424-807cf69d387d/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64=
github.com/onflow/flow-emulator v1.0.0-preview.41.0.20240829134601-0be55d6970b5 h1:Z5PC3Sqvl2UemY27uwUwzkLb8EXUf+m/aEimxFzOXuc=
github.com/onflow/flow-emulator v1.0.0-preview.41.0.20240829134601-0be55d6970b5/go.mod h1:gFafyGD4Qxs+XT2BRSIjQJ86ILSmgm1VYUoCr1nVxVI=
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
Expand Down
16 changes: 4 additions & 12 deletions integration/tests/upgrades/protocol_version_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,23 @@ import (
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/state/protocol/protocol_state"
"github.com/onflow/flow-go/state/protocol/protocol_state/kvstore"
"github.com/onflow/flow-go/utils/unittest"
)

type ProtocolVersionUpgradeSuite struct {
Suite
}

func TestProtocolVersionUpgrade(t *testing.T) {
// See https://github.com/onflow/flow-go/pull/5840/files#r1589483631
// Must merge and pin https://github.com/onflow/flow-core-contracts/pull/419 to re-enable test
unittest.SkipUnless(t, unittest.TEST_TODO, "skipped as it depends on VersionBeacon contract upgrade")
suite.Run(t, new(ProtocolVersionUpgradeSuite))
}

func (suite *ProtocolVersionUpgradeSuite) SetupTest() {
func (s *ProtocolVersionUpgradeSuite) SetupTest() {
// Begin the test with a v0 kvstore, rather than the default v1.
// This lets us test upgrading v0->v1
protocolState, err := suite.net.BootstrapSnapshot.ProtocolState()
require.NoError(suite.T(), err)
finalizationThreshold := protocolState.GetFinalizationSafetyThreshold()
epochExtensionViewCount := protocolState.GetEpochExtensionViewCount()
suite.KVStoreFactory = func(epochStateID flow.Identifier) (protocol_state.KVStoreAPI, error) {
return kvstore.NewKVStoreV0(finalizationThreshold, epochExtensionViewCount, epochStateID)
s.KVStoreFactory = func(epochStateID flow.Identifier) (protocol_state.KVStoreAPI, error) {
return kvstore.NewKVStoreV0(10, 50, epochStateID)
}
suite.Suite.SetupTest()
s.Suite.SetupTest()
}

// TestProtocolStateVersionUpgradeServiceEvent tests the process of upgrading the protocol
Expand Down
4 changes: 2 additions & 2 deletions integration/tests/upgrades/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func (s *Suite) SetupTest() {

consensusConfigs := []func(config *testnet.NodeConfig){
testnet.WithAdditionalFlag("--cruise-ctl-fallback-proposal-duration=500ms"),
testnet.WithAdditionalFlag("--required-verification-seal-approvals=0"),
testnet.WithAdditionalFlag("--required-construction-seal-approvals=0"),
testnet.WithAdditionalFlag("--required-verification-seal-approvals=1"),
testnet.WithAdditionalFlag("--required-construction-seal-approvals=1"),
testnet.WithLogLevel(zerolog.InfoLevel),
}

Expand Down
5 changes: 2 additions & 3 deletions integration/utils/templates/set-protocol-state-version.cdc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NodeVersionBeacon from 0xNODEVERSIONBEACONADDRESS
import NodeVersionBeacon from "NodeVersionBeacon"

/// Transaction that allows NodeVersionAdmin to specify a new protocol state version.
/// The new version will become active at view `activeView` if the service event
Expand All @@ -9,7 +9,6 @@ import NodeVersionBeacon from 0xNODEVERSIONBEACONADDRESS
/// This is a special version of the admin transaction for use in integration tests.
/// We allow the sender to pass in a value to add to the current view, to reduce
/// the liklihood that a test spuriously fails due to timing.

transaction(newProtocolVersion: UInt64, activeViewDiff: UInt64) {

let adminRef: &NodeVersionBeacon.Admin
Expand All @@ -22,7 +21,7 @@ transaction(newProtocolVersion: UInt64, activeViewDiff: UInt64) {

execute {
let block = getCurrentBlock()
self.adminRef.setPendingProtocolStateVersionUpgrade(
self.adminRef.emitProtocolStateVersionUpgrade(
newProtocolVersion: newProtocolVersion,
activeView: block.view + activeViewDiff
)
Expand Down
3 changes: 2 additions & 1 deletion integration/utils/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var createAndSetupNodeTxScript string
//go:embed templates/remove-node.cdc
var removeNodeTxScript string

//go:embed templates/set-protocol-state-version.cdc
//go:embed "templates/set-protocol-state-version.cdc"
var setProtocolStateVersionScript string

func LocalnetEnv() templates.Environment {
Expand Down Expand Up @@ -195,6 +195,7 @@ func MakeSetProtocolStateVersionTx(
activeViewDiff uint64,
) (*sdk.Transaction, error) {
accountKey := adminAccount.Keys[adminAccountKeyID]

tx := sdk.NewTransaction().
SetScript([]byte(templates.ReplaceAddresses(setProtocolStateVersionScript, env))).
SetComputeLimit(9999).
Expand Down
4 changes: 2 additions & 2 deletions state/protocol/protocol_state/kvstore/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func (model *Modelv0) SetEpochStateID(id flow.Identifier) {
// - kvstore.ErrInvalidValue - if the view count is less than FinalizationSafetyThreshold*2.
func (model *Modelv0) SetEpochExtensionViewCount(viewCount uint64) error {
// Strictly speaking it should be perfectly fine to use a value viewCount >= model.FinalizationSafetyThreshold.
// By using a sligtly higher value(factor of 2) we ensure that extension is big enough in practice to give operators a bigger
// window in which a valid epoch recover event could be submitted.
// By using a slightly higher value (factor of 2), we ensure that each extension spans a sufficiently big time
// window for the human governance committee to submit a valid epoch recovery transaction.
if viewCount < model.FinalizationSafetyThreshold*2 {
return fmt.Errorf("invalid view count %d, expect at least %d: %w", viewCount, model.FinalizationSafetyThreshold*2, ErrInvalidValue)
}
Expand Down