Skip to content

Commit

Permalink
Merge branch 'master' into ramtin/evm-offchain-part3
Browse files Browse the repository at this point in the history
  • Loading branch information
ramtinms authored Oct 21, 2024
2 parents 895c04a + a4773d7 commit fa94833
Show file tree
Hide file tree
Showing 188 changed files with 2,280 additions and 19,425 deletions.
1 change: 1 addition & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
docker-push:
name: ${{ matrix.role }} images
runs-on: ubuntu-latest
environment: Production Docker Registry
needs: matrix_builder

# setup jobs for each role
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
name: CD

on:
push:
tags:
- '*'
- "!daily-*"
# Workflow dispatch for now, while we're testing environments
# push:
# tags:
# - '*'
# - "!daily-*"
workflow_dispatch:
inputs:
tag:
description: 'Tag/commit'
required: true
type: string


env:
GO_VERSION: "1.22"
Expand All @@ -13,6 +21,7 @@ jobs:
docker-push:
name: Push to container registry
runs-on: ubuntu-latest
environment: Production Docker Registry
steps:
- name: Setup Go
uses: actions/setup-go@v4
Expand All @@ -21,6 +30,8 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- name: Checkout repo
uses: actions/checkout@v2
with:
ref: ${{ inputs.tag }}
# Provide Google Service Account credentials to Github Action, allowing interaction with the Google Container Registry
# Logging in as [email protected]
- id: auth
Expand Down
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
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
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
Loading

0 comments on commit fa94833

Please sign in to comment.