Skip to content

Commit

Permalink
Merge pull request #6752 from onflow/jord/re-enable-TestProtocolVersi…
Browse files Browse the repository at this point in the history
…onUpgrade

Re-enable test `TestProtocolVersionUpgrade`
  • Loading branch information
jordanschalm authored Dec 12, 2024
2 parents 6c251a3 + 74c9d8f commit c7c7e5a
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 42 deletions.
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("d06b0cb5947b99081321263eabff599246a610ae8cfd1b18b1c9373271a7c537")
expectedStateCommitmentBytes, _ := hex.DecodeString("98f14d08f41e7ac9773365f5754e406bf5d54ab166a5a667e80c88f8300a379d")
expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes)
require.NoError(t, err)

Expand Down
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
6 changes: 3 additions & 3 deletions utils/unittest/execution_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256
const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256

// Pre-calculated state commitment with root account with the above private key
const GenesisStateCommitmentHex = "bac7d50115c6a470cdef79e503d8e7c826a5feb8c4e10a5126753ace52653958"
const GenesisStateCommitmentHex = "6a3c5e9ad92edb0588c7e1f1dd75c5b449b44276eaa8e849f54a4a9425131527"

var GenesisStateCommitment flow.StateCommitment

Expand Down Expand Up @@ -87,10 +87,10 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string {
return GenesisStateCommitmentHex
}
if chainID == flow.Testnet {
return "14a64f957d65b09ef6cc9401ad2f8a7a27159fa13524996d5d44eb9f105e29fd"
return "1601994aa167f94141df86e90eea79a1eaa831a61f12f28cd4bf07d968ab6ff0"
}
if chainID == flow.Sandboxnet {
return "e1c08b17f9e5896f03fe28dd37ca396c19b26628161506924fbf785834646ea1"
}
return "7584db9154179afd9e9c39d86cb60e1a39677e62f921e1e1661f58b58fed32ec"
return "ded8cdf6371b065da99a00e627dd123ddb2b9e60848047fd4908651426a59618"
}

0 comments on commit c7c7e5a

Please sign in to comment.