Skip to content

Commit

Permalink
Merge branch 'master' into bastian/computation-remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Oct 22, 2024
2 parents e8d75b6 + 6a254ed commit 7415145
Show file tree
Hide file tree
Showing 225 changed files with 4,287 additions and 19,587 deletions.
2 changes: 1 addition & 1 deletion access/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/onflow/cadence"
jsoncdc "github.com/onflow/cadence/encoding/json"
"github.com/onflow/cadence/runtime/parser"
"github.com/onflow/cadence/parser"
"github.com/onflow/crypto"
"github.com/onflow/flow-core-contracts/lib/go/templates"

Expand Down
2 changes: 1 addition & 1 deletion access/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
Expand Down
1 change: 1 addition & 0 deletions cmd/bootstrap/utils/key_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

sdk "github.com/onflow/flow-go-sdk"
sdkcrypto "github.com/onflow/flow-go-sdk/crypto"

"github.com/onflow/flow-go/fvm/systemcontracts"
"github.com/onflow/flow-go/model/bootstrap"
model "github.com/onflow/flow-go/model/bootstrap"
Expand Down
1 change: 1 addition & 0 deletions cmd/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

client "github.com/onflow/flow-go-sdk/access/grpc"
sdkcrypto "github.com/onflow/flow-go-sdk/crypto"

"github.com/onflow/flow-go/admin/commands"
collectionCommands "github.com/onflow/flow-go/admin/commands/collection"
storageCommands "github.com/onflow/flow-go/admin/commands/storage"
Expand Down
1 change: 1 addition & 0 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

client "github.com/onflow/flow-go-sdk/access/grpc"
"github.com/onflow/flow-go-sdk/crypto"

"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/consensus"
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/check-storage/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"

"github.com/onflow/cadence/common"
"github.com/onflow/cadence/runtime"
"github.com/onflow/cadence/runtime/common"

"github.com/onflow/flow-go/cmd/util/ledger/reporters"
"github.com/onflow/flow-go/cmd/util/ledger/util"
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/check-storage/evm_account_storage_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/onflow/atree"

"github.com/onflow/cadence/common"
"github.com/onflow/cadence/runtime"
"github.com/onflow/cadence/runtime/common"

"github.com/onflow/flow-go/cmd/util/ledger/util"
"github.com/onflow/flow-go/cmd/util/ledger/util/registers"
Expand Down
4 changes: 2 additions & 2 deletions cmd/util/cmd/check-storage/evm_account_storage_health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"golang.org/x/exp/maps"

"github.com/onflow/atree"
"github.com/onflow/cadence/common"
"github.com/onflow/cadence/interpreter"
"github.com/onflow/cadence/runtime"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/interpreter"
gethCommon "github.com/onflow/go-ethereum/common"

"github.com/onflow/flow-go/cmd/util/ledger/util"
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/common/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/rs/zerolog"

"github.com/onflow/cadence"
cdcCommon "github.com/onflow/cadence/runtime/common"
cdcCommon "github.com/onflow/cadence/common"

"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/assignment"
Expand Down
3 changes: 2 additions & 1 deletion cmd/util/cmd/common/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/rs/zerolog"
"github.com/sethvargo/go-retry"

"github.com/onflow/flow-go-sdk/access/grpc"

"github.com/onflow/flow-go/utils/logging"

"github.com/onflow/flow-go-sdk/access/grpc"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/state/protocol"
"github.com/onflow/flow-go/state/protocol/inmem"
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/diff-states/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"slices"

"github.com/dustin/go-humanize/english"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
Expand Down
89 changes: 2 additions & 87 deletions cmd/util/cmd/execution-state-extract/cmd.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package extract

import (
"compress/gzip"
"encoding/hex"
"fmt"
"io"
"os"
"path"
"runtime/pprof"
Expand Down Expand Up @@ -326,7 +324,8 @@ func run(*cobra.Command, []string) {
}
}

chain := flow.ChainID(flagChain).Chain()
// Validate chain ID
_ = flow.ChainID(flagChain).Chain()

if flagNoReport {
log.Warn().Msgf("--no-report flag is deprecated")
Expand Down Expand Up @@ -401,43 +400,6 @@ func run(*cobra.Command, []string) {

log.Info().Msgf("state extraction plan: %s, %s", inputMsg, outputMsg)

chainID := chain.ChainID()

burnerContractChange := migrations.BurnerContractChangeNone
evmContractChange := migrations.EVMContractChangeNone
switch chainID {
case flow.Emulator:
burnerContractChange = migrations.BurnerContractChangeDeploy
evmContractChange = migrations.EVMContractChangeDeployMinimalAndUpdateFull
case flow.Testnet, flow.Mainnet:
burnerContractChange = migrations.BurnerContractChangeUpdate
evmContractChange = migrations.EVMContractChangeUpdateFull
}

stagedContracts, err := migrations.StagedContractsFromCSV(flagStagedContractsFile)
if err != nil {
log.Fatal().Err(err).Msgf("error loading staged contracts: %s", err.Error())
}

opts := migrations.Options{
NWorker: flagNWorker,
DiffMigrations: flagDiffMigration,
LogVerboseDiff: flagLogVerboseDiff,
CheckStorageHealthBeforeMigration: flagCheckStorageHealthBeforeMigration,
ChainID: chainID,
EVMContractChange: evmContractChange,
BurnerContractChange: burnerContractChange,
StagedContracts: stagedContracts,
Prune: flagPrune,
MaxAccountSize: flagMaxAccountSize,
VerboseErrorOutput: flagVerboseErrorOutput,
FixSlabsWithBrokenReferences: chainID == flow.Testnet && flagFixSlabsWithBrokenReferences,
FilterUnreferencedSlabs: flagFilterUnreferencedSlabs,
ReportMetrics: flagReportMetrics,
CacheStaticTypeMigrationResults: flagCacheStaticTypeMigrationResults,
CacheEntitlementsMigrationResults: flagCacheEntitlementsMigrationResults,
}

var extractor extractor
if len(flagInputPayloadFileName) > 0 {
extractor = newPayloadFileExtractor(log.Logger, flagInputPayloadFileName)
Expand All @@ -460,21 +422,6 @@ func run(*cobra.Command, []string) {
var migs []migrations.NamedMigration

switch flagMigration {
case "cadence-1.0":
migs = newCadence1Migrations(
log.Logger,
flagOutputDir,
opts,
)

case "fix-authorizations":
migs = newFixAuthorizationsMigrations(
log.Logger,
flagAuthorizationFixes,
flagOutputDir,
opts,
)

default:
log.Fatal().Msgf("unknown migration: %s", flagMigration)
}
Expand Down Expand Up @@ -557,35 +504,3 @@ func ensureCheckpointFileExist(dir string) error {

return fmt.Errorf("no checkpoint file was found, no root checkpoint file was found in %v, check the --execution-state-dir flag", dir)
}

func readAuthorizationFixes(path string) migrations.AuthorizationFixes {

file, err := os.Open(path)
if err != nil {
log.Fatal().Err(err).Msgf("can't open authorization fixes: %s", path)
}
defer file.Close()

var reader io.Reader = file
if isGzip(file) {
reader, err = gzip.NewReader(file)
if err != nil {
log.Fatal().Err(err).Msgf("failed to create gzip reader for %s", path)
}
}

log.Info().Msgf("Reading authorization fixes from %s ...", path)

fixes, err := migrations.ReadAuthorizationFixes(reader, nil)
if err != nil {
log.Fatal().Err(err).Msgf("failed to read authorization fixes %s", path)
}

log.Info().Msgf("Read %d authorization fixes", len(fixes))

return fixes
}

func isGzip(file *os.File) bool {
return strings.HasSuffix(file.Name(), ".gz")
}
78 changes: 0 additions & 78 deletions cmd/util/cmd/execution-state-extract/execution_state_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"golang.org/x/sync/errgroup"

migrators "github.com/onflow/flow-go/cmd/util/ledger/migrations"
"github.com/onflow/flow-go/cmd/util/ledger/reporters"
"github.com/onflow/flow-go/cmd/util/ledger/util"
"github.com/onflow/flow-go/ledger"
"github.com/onflow/flow-go/ledger/common/hash"
Expand Down Expand Up @@ -357,80 +356,3 @@ func createTrieFromPayloads(logger zerolog.Logger, payloads []*ledger.Payload) (

return newTrie, nil
}

func newCadence1Migrations(
log zerolog.Logger,
outputDir string,
opts migrators.Options,
) []migrators.NamedMigration {

log.Info().Msg("initializing Cadence 1.0 migrations ...")

rwf := reporters.NewReportFileWriterFactory(outputDir, log)

namedMigrations := migrators.NewCadence1Migrations(
log,
outputDir,
rwf,
opts,
)

// At the end, fix up storage-used discrepancies
namedMigrations = append(
namedMigrations,
migrators.NamedMigration{
Name: "account-usage-migration",
Migrate: migrators.NewAccountBasedMigration(
log,
opts.NWorker,
[]migrators.AccountBasedMigration{
migrators.NewAccountUsageMigration(rwf),
},
),
},
)

log.Info().Msg("initialized migrations")

return namedMigrations
}

func newFixAuthorizationsMigrations(
log zerolog.Logger,
authorizationFixesPath string,
outputDir string,
opts migrators.Options,
) []migrators.NamedMigration {

log.Info().Msg("initializing authorization fix migrations ...")

rwf := reporters.NewReportFileWriterFactory(outputDir, log)

authorizationFixes := readAuthorizationFixes(authorizationFixesPath)

namedMigrations := migrators.NewFixAuthorizationsMigrations(
log,
rwf,
authorizationFixes,
opts,
)

// At the end, fix up storage-used discrepancies
namedMigrations = append(
namedMigrations,
migrators.NamedMigration{
Name: "account-usage-migration",
Migrate: migrators.NewAccountBasedMigration(
log,
opts.NWorker,
[]migrators.AccountBasedMigration{
migrators.NewAccountUsageMigration(rwf),
},
),
},
)

log.Info().Msg("initialized migrations")

return namedMigrations
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/atomic"

runtimeCommon "github.com/onflow/cadence/runtime/common"
runtimeCommon "github.com/onflow/cadence/common"

"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/cmd/util/ledger/util"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"

"github.com/onflow/flow-go/cmd/util/ledger/util"
"github.com/onflow/flow-go/ledger"
Expand Down
8 changes: 4 additions & 4 deletions cmd/util/cmd/generate-authorization-fixes/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"strings"
"sync"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/interpreter"
"github.com/onflow/cadence/runtime/sema"
"github.com/onflow/cadence/runtime/stdlib"
"github.com/onflow/cadence/common"
"github.com/onflow/cadence/interpreter"
"github.com/onflow/cadence/sema"
"github.com/onflow/cadence/stdlib"
"github.com/rs/zerolog/log"
"github.com/schollz/progressbar/v3"
"github.com/spf13/cobra"
Expand Down
6 changes: 3 additions & 3 deletions cmd/util/cmd/generate-authorization-fixes/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"

"github.com/onflow/cadence"
"github.com/onflow/cadence/common"
jsoncdc "github.com/onflow/cadence/encoding/json"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/interpreter"
"github.com/onflow/cadence/runtime/sema"
"github.com/onflow/cadence/interpreter"
"github.com/onflow/cadence/sema"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"strings"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
)

// AccountCapabilityID is a capability ID in an account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/util/ledger/migrations/account_based_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
syncAtomic "sync/atomic"
"time"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/common"
"github.com/rs/zerolog"
"golang.org/x/sync/errgroup"

Expand Down
Loading

0 comments on commit 7415145

Please sign in to comment.