-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4393 from filecoin-project/vectors/support-multip…
…le-versions conformance: support multiple protocol versions.
- Loading branch information
Showing
10 changed files
with
130 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/filecoin-project/go-state-types/abi" | ||
|
||
"github.com/filecoin-project/lotus/build" | ||
) | ||
|
||
// ProtocolCodenames is a table that summarises the protocol codenames that | ||
// will be set on extracted vectors, depending on the original execution height. | ||
// | ||
// Implementers rely on these names to filter the vectors they can run through | ||
// their implementations, based on their support level | ||
var ProtocolCodenames = []struct { | ||
firstEpoch abi.ChainEpoch | ||
name string | ||
}{ | ||
{0, "genesis"}, | ||
{build.UpgradeBreezeHeight + 1, "breeze"}, | ||
{build.UpgradeSmokeHeight + 1, "smoke"}, | ||
{build.UpgradeIgnitionHeight + 1, "ignition"}, | ||
{build.UpgradeRefuelHeight + 1, "refuel"}, | ||
{build.UpgradeActorsV2Height + 1, "actorsv2"}, | ||
{build.UpgradeTapeHeight + 1, "tape"}, | ||
{build.UpgradeLiftoffHeight + 1, "liftoff"}, | ||
} | ||
|
||
// GetProtocolCodename gets the protocol codename associated with a height. | ||
func GetProtocolCodename(height abi.ChainEpoch) string { | ||
for i, v := range ProtocolCodenames { | ||
if height < v.firstEpoch { | ||
// found the cutoff, return previous. | ||
return ProtocolCodenames[i-1].name | ||
} | ||
} | ||
return ProtocolCodenames[len(ProtocolCodenames)-1].name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
|
||
"github.com/filecoin-project/go-state-types/abi" | ||
|
||
"github.com/filecoin-project/lotus/build" | ||
) | ||
|
||
func TestProtocolCodenames(t *testing.T) { | ||
if height := abi.ChainEpoch(100); GetProtocolCodename(height) != "genesis" { | ||
t.Fatal("expected genesis codename") | ||
} | ||
|
||
if height := abi.ChainEpoch(build.UpgradeBreezeHeight + 1); GetProtocolCodename(height) != "breeze" { | ||
t.Fatal("expected breeze codename") | ||
} | ||
|
||
if height := build.UpgradeActorsV2Height + 1; GetProtocolCodename(height) != "actorsv2" { | ||
t.Fatal("expected actorsv2 codename") | ||
} | ||
|
||
if height := abi.ChainEpoch(math.MaxInt64); GetProtocolCodename(height) != ProtocolCodenames[len(ProtocolCodenames)-1].name { | ||
t.Fatal("expected last codename") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule test-vectors
updated
1328 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters