Skip to content

Commit

Permalink
Merge branch 'master' into janez/migration-mainnet-add-keys-to-core-c…
Browse files Browse the repository at this point in the history
…ontracts-2
  • Loading branch information
j1010001 authored Aug 16, 2024
2 parents d37df7c + d9f7522 commit aa52dd2
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 127 deletions.
14 changes: 7 additions & 7 deletions cmd/execution_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,13 @@ func (exeNode *ExecutionNode) LoadProviderEngine(
)

if exeNode.exeConf.evmTracingEnabled {
if exeNode.exeConf.evmTracesGCPBucket == "" {
return nil, fmt.Errorf("must provide GCP bucket name when EVM tracing is enabled")
}

evmTraceUploader, err := debug.NewGCPUploader(exeNode.exeConf.evmTracesGCPBucket)
if err != nil {
return nil, fmt.Errorf("could not create evm trace uploader: %w", err)
var err error
evmTraceUploader := debug.NewNoopUploader()
if len(exeNode.exeConf.evmTracesGCPBucket) > 0 {
evmTraceUploader, err = debug.NewGCPUploader(exeNode.exeConf.evmTracesGCPBucket)
if err != nil {
return nil, fmt.Errorf("could not create evm trace uploader: %w", err)
}
}
evmTracer, err := debug.NewEVMCallTracer(evmTraceUploader, node.Logger)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/execution_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) {
flags.DurationVar(&exeConf.maxGracefulStopDuration, "max-graceful-stop-duration", stop.DefaultMaxGracefulStopDuration, "the maximum amount of time stop control will wait for ingestion engine to gracefully shutdown before crashing")
flags.IntVar(&exeConf.importCheckpointWorkerCount, "import-checkpoint-worker-count", 10, "number of workers to import checkpoint file during bootstrap")
flags.BoolVar(&exeConf.evmTracingEnabled, "evm-tracing-enabled", false, "enable EVM tracing, when set it will generate traces and upload them to the GCP bucket provided by the --evm-traces-gcp-bucket. Warning: this might affect speed of execution")
flags.StringVar(&exeConf.evmTracesGCPBucket, "evm-traces-gcp-bucket", "", "define GCP bucket name used for uploading EVM traces, must be used in combination with --evm-tracing-enabled.")
flags.StringVar(&exeConf.evmTracesGCPBucket, "evm-traces-gcp-bucket", "", "define GCP bucket name used for uploading EVM traces, must be used in combination with --evm-tracing-enabled. if left empty the upload step is skipped")

flags.BoolVar(&exeConf.onflowOnlyLNs, "temp-onflow-only-lns", false, "do not use unless required. forces node to only request collections from onflow collection nodes")
flags.BoolVar(&exeConf.enableStorehouse, "enable-storehouse", false, "enable storehouse to store registers on disk, default is false")
Expand Down
2 changes: 2 additions & 0 deletions cmd/util/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
rollback_executed_height "github.com/onflow/flow-go/cmd/util/cmd/rollback-executed-height/cmd"
run_script "github.com/onflow/flow-go/cmd/util/cmd/run-script"
"github.com/onflow/flow-go/cmd/util/cmd/snapshot"
system_addresses "github.com/onflow/flow-go/cmd/util/cmd/system-addresses"
truncate_database "github.com/onflow/flow-go/cmd/util/cmd/truncate-database"
"github.com/onflow/flow-go/cmd/util/cmd/version"
"github.com/onflow/flow-go/module/profiler"
Expand Down Expand Up @@ -114,6 +115,7 @@ func addCommands() {
rootCmd.AddCommand(atree_inlined_status.Cmd)
rootCmd.AddCommand(find_trie_root.Cmd)
rootCmd.AddCommand(run_script.Cmd)
rootCmd.AddCommand(system_addresses.Cmd)
}

func initConfig() {
Expand Down
62 changes: 62 additions & 0 deletions cmd/util/cmd/system-addresses/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package addresses

import (
"bytes"
"sort"

"github.com/spf13/cobra"

"github.com/onflow/flow-go/fvm/systemcontracts"
"github.com/onflow/flow-go/model/flow"
)

var (
flagChain string
flagSeparator string
)

var Cmd = &cobra.Command{
Use: "system-addresses",
Short: "print addresses of system contracts",
Run: run,
}

func init() {
Cmd.Flags().StringVar(&flagChain, "chain", "", "Chain name")
_ = Cmd.MarkFlagRequired("chain")

Cmd.Flags().StringVar(&flagSeparator, "separator", ",", "Separator to use between addresses")
}

func run(*cobra.Command, []string) {
chainID := flow.ChainID(flagChain)
// validate
_ = chainID.Chain()

systemContracts := systemcontracts.SystemContractsForChain(chainID)

addressSet := map[flow.Address]struct{}{}
for _, contract := range systemContracts.All() {
addressSet[contract.Address] = struct{}{}
}

addresses := make([]flow.Address, 0, len(addressSet))
for address := range addressSet {
addresses = append(addresses, address)
}

sort.Slice(addresses, func(i, j int) bool {
a := addresses[i]
b := addresses[j]
return bytes.Compare(a[:], b[:]) < 0
})

for i, address := range addresses {
str := address.Hex()

if i > 0 {
print(flagSeparator)
}
print(str)
}
}
3 changes: 0 additions & 3 deletions engine/access/rest/middleware/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ func LoggingMiddleware(logger zerolog.Logger) mux.MiddlewareFunc {
// continue to the next handler
inner.ServeHTTP(respWriter, req)
log := logger.Info()
if respWriter.statusCode != http.StatusOK {
log = logger.Error()
}
log.Str("method", req.Method).
Str("uri", req.RequestURI).
Str("client_ip", req.RemoteAddr).
Expand Down
2 changes: 1 addition & 1 deletion engine/access/rpc/backend/backend_scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (b *backendScripts) executeScriptLocally(
logEvent.Msg("script failed to execute locally")

default:
lg.Error().Err(err).Msg("script execution failed")
lg.Debug().Err(err).Msg("script execution failed")
b.metrics.ScriptExecutionErrorLocal()
}

Expand Down
22 changes: 8 additions & 14 deletions engine/common/version/version_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,10 @@ func (v *VersionControl) initBoundaries(

if vb == nil {
// no version beacon found
// this is unexpected on a live network as there should always be at least the
// starting version beacon, but not fatal.
// It can happen on new or test networks if the node starts before bootstrap is finished.
// TODO: remove when we can guarantee that there will always be a version beacon
// this is only expected when a node starts up on a network that has never had a version beacon event.
v.log.Info().
Uint64("height", processedHeight).
Msg("No version beacon found for version control")
Msg("No initial version beacon found")

return nil
}
Expand Down Expand Up @@ -296,7 +293,7 @@ func (v *VersionControl) blockFinalized(
if err != nil {
v.log.Err(err).
Uint64("height", height).
Msg("Failed to get highest version beacon for version control")
Msg("Failed to get highest version beacon")

ctx.Throw(
fmt.Errorf(
Expand All @@ -305,20 +302,17 @@ func (v *VersionControl) blockFinalized(
return
}

v.lastProcessedHeight.Store(height)

if vb == nil {
// no version beacon found
// this is unexpected as there should always be at least the
// starting version beacon, but not fatal.
// It can happen if the node starts before bootstrap is finished.
// TODO: remove when we can guarantee that there will always be a version beacon
v.log.Info().
// this is only expected when a node starts up on a network that has never had a version beacon event.
v.log.Debug().
Uint64("height", height).
Msg("No version beacon found for version control")
Msg("No version beacon found at height")
continue
}

v.lastProcessedHeight.Store(height)

previousEndHeight := v.endHeight.Load()

if previousEndHeight != NoHeight && height > previousEndHeight {
Expand Down
7 changes: 0 additions & 7 deletions fvm/environment/facade_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/onflow/flow-go/fvm/storage/snapshot"
"github.com/onflow/flow-go/fvm/storage/state"
"github.com/onflow/flow-go/fvm/tracing"
"github.com/onflow/flow-go/model/flow"
)

var _ Environment = &facadeEnvironment{}
Expand Down Expand Up @@ -338,12 +337,6 @@ func (*facadeEnvironment) GetInterpreterSharedState() *interpreter.SharedState {
}

func (env *facadeEnvironment) RecoverProgram(program *ast.Program, location common.Location) (*ast.Program, error) {
// Enabled on all networks but Mainnet,
// until https://github.com/onflow/flips/pull/283 got approved.
if env.chain.ChainID() == flow.Mainnet {
return nil, nil
}

return RecoverProgram(
env,
env.chain.ChainID(),
Expand Down
15 changes: 8 additions & 7 deletions fvm/environment/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ const (
)

// MainnetExecutionEffortWeights are the execution effort weights as they are
// on mainnet from 18.8.2022
// on mainnet from crescendo spork
var MainnetExecutionEffortWeights = meter.ExecutionEffortWeights{
common.ComputationKindStatement: 1569,
common.ComputationKindLoop: 1569,
common.ComputationKindFunctionInvocation: 1569,
ComputationKindGetValue: 808,
ComputationKindCreateAccount: 2837670,
ComputationKindSetValue: 765,
common.ComputationKindStatement: 314,
common.ComputationKindLoop: 314,
common.ComputationKindFunctionInvocation: 314,
ComputationKindGetValue: 162,
ComputationKindCreateAccount: 567534,
ComputationKindSetValue: 153,
ComputationKindEVMGasUsage: 13,
}

type Meter interface {
Expand Down
11 changes: 6 additions & 5 deletions fvm/evm/debug/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func Test_CallTracer(t *testing.T) {
data := []byte{0x02, 0x04}
amount := big.NewInt(1)

// first transaction
tr := tracer.TxTracer()
require.NotNil(t, tr)

Expand All @@ -50,8 +49,9 @@ func Test_CallTracer(t *testing.T) {
tr.OnEnter(1, byte(vm.ADD), from, to, data, 20, big.NewInt(2))
tr.OnExit(1, nil, 10, nil, false)
tr.OnExit(0, []byte{0x02}, 200, nil, false)
tr.OnTxEnd(&gethTypes.Receipt{TxHash: tx.Hash()}, nil)
tracer.Collect(tx.Hash())
tr.OnTxEnd(&gethTypes.Receipt{TxHash: txID}, nil)
res = tracer.GetResultByTxHash(txID)
tracer.Collect(txID)
})

t.Run("collect traces and upload them (after a failed transaction)", func(t *testing.T) {
Expand Down Expand Up @@ -92,8 +92,9 @@ func Test_CallTracer(t *testing.T) {
tr.OnTxStart(nil, tx, from)
tr.OnEnter(0, 0, from, to, []byte{0x01, 0x02}, 10, big.NewInt(1))
tr.OnExit(0, []byte{0x02}, 200, nil, false)
tr.OnTxEnd(&gethTypes.Receipt{TxHash: tx.Hash()}, nil)
tracer.Collect(tx.Hash())
tr.OnTxEnd(&gethTypes.Receipt{TxHash: txID}, nil)
res = tracer.GetResultByTxHash(txID)
tracer.Collect(txID)
})

t.Run("collector panic recovery", func(t *testing.T) {
Expand Down
11 changes: 11 additions & 0 deletions fvm/evm/debug/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,14 @@ func (g *GCPUploader) Upload(id string, data json.RawMessage) error {

return nil
}

// NewNoopUploader constructs a new noop uploader
func NewNoopUploader() Uploader {
return &NoopUploader{}
}

type NoopUploader struct{}

func (np *NoopUploader) Upload(id string, data json.RawMessage) error {
return nil
}
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/aws/aws-sdk-go-v2/config v1.27.15
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.1
github.com/aws/aws-sdk-go-v2/service/s3 v1.15.0
github.com/btcsuite/btcd/btcec/v2 v2.2.1
github.com/btcsuite/btcd/btcec/v2 v2.3.4
github.com/davecgh/go-spew v1.1.1
github.com/dgraph-io/badger/v2 v2.2007.4
github.com/ef-ds/deque v1.0.4
Expand Down Expand Up @@ -49,7 +49,7 @@ require (
github.com/multiformats/go-multihash v0.2.3
github.com/onflow/atree v0.8.0-rc.5
github.com/onflow/cadence v1.0.0-preview.48
github.com/onflow/crypto v0.25.1
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.1
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1
Expand Down Expand Up @@ -77,13 +77,13 @@ require (
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/atomic v1.11.0
go.uber.org/multierr v1.11.0
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.26.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/sync v0.7.0
golang.org/x/sys v0.20.0
golang.org/x/text v0.14.0
golang.org/x/sync v0.8.0
golang.org/x/sys v0.23.0
golang.org/x/text v0.17.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.20.0
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
google.golang.org/api v0.162.0
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de
google.golang.org/grpc v1.63.2
Expand Down Expand Up @@ -312,9 +312,9 @@ require (
go.uber.org/mock v0.4.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/term v0.23.0 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
Expand Down
Loading

0 comments on commit aa52dd2

Please sign in to comment.