Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Stable Cadence feature branch #5472

Merged
merged 59 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
832c440
Add normalized time per computation logs to transaction execution
janezpodhostnik Feb 13, 2024
686df4d
extract common logic
janezpodhostnik Feb 15, 2024
d1cc0ce
Improve account migration error handling
janezpodhostnik Feb 16, 2024
68588ff
Merge branch 'master' into janez/improve-migration-err-handling
j1010001 Feb 19, 2024
2c49100
Merge branch 'master' into janez/time-per-computation-estimation-logs
j1010001 Feb 19, 2024
c979af3
disable block basefee
ramtinms Feb 21, 2024
f99a37e
add a test for tx with gas fee of zero
ramtinms Feb 21, 2024
2e1625e
update tests
ramtinms Feb 21, 2024
659ea14
disable direct call gas tip and fee cap
ramtinms Feb 21, 2024
357219a
Merge branch 'master' into ramtin/flow-evm-disable-base-fee
ramtinms Feb 22, 2024
2092351
Merge branch 'master' into janez/time-per-computation-estimation-logs
janezpodhostnik Feb 22, 2024
e3401d2
Add version, flag, and checksum to payload file
fxamacker Feb 22, 2024
159974b
Add more test assertions for EVM events
m-Peter Feb 20, 2024
b831b03
Return check-summed variant for deployed contract address
m-Peter Feb 21, 2024
c5a937b
Merge branch 'master' into fxamacker/improve-payload-file
fxamacker Feb 22, 2024
1bd3e48
set base fee to zero
ramtinms Feb 22, 2024
2cb9919
add test for dynamic fees
ramtinms Feb 22, 2024
4409090
update docs
ramtinms Feb 22, 2024
19ea14a
Merge branch 'master' into ramtin/flow-evm-disable-base-fee
ramtinms Feb 22, 2024
8a6bbaf
Merge pull request #5404 from onflow/petera/fix-event-tx-order
peterargue Feb 20, 2024
59a3b11
Merge branch 'master' into janez/time-per-computation-estimation-logs
janezpodhostnik Feb 23, 2024
14044fd
Merge branch 'master' into janez/improve-migration-err-handling
janezpodhostnik Feb 23, 2024
847cd6e
Add more logging and minor refactoring
fxamacker Feb 23, 2024
fc709b9
Merge branch 'master' into fxamacker/improve-payload-file
fxamacker Feb 23, 2024
df30b02
Merge branch 'master' into evm-events-more-test-assertions
franklywatson Feb 23, 2024
63286fc
Merge branch 'master' into janez/improve-migration-err-handling
turbolent Feb 23, 2024
75e1537
Merge branch 'master' into ramtin/flow-evm-disable-base-fee
ramtinms Feb 23, 2024
e40084b
Merge pull request #5409 from onflow/janez/improve-migration-err-hand…
turbolent Feb 23, 2024
e1e2ddd
Merge pull request #5444 from onflow/petera/backport-fix-event-tx-order
peterargue Feb 23, 2024
363c6e1
fix tx hash issue for direct calls
ramtinms Feb 23, 2024
7832f6c
Merge branch 'master' into ramtin/flow-evm-fix-tx-hash-issue
ramtinms Feb 23, 2024
2ee39c8
add test
ramtinms Feb 24, 2024
9ca5a55
Merge pull request #5432 from onflow/ramtin/flow-evm-disable-base-fee
ramtinms Feb 24, 2024
5d64f99
.
ramtinms Feb 24, 2024
ee455a8
Merge branch 'master' into ramtin/flow-evm-dont-returne-address-zero-…
ramtinms Feb 24, 2024
05e4140
Merge branch 'master' into ramtin/flow-evm-fix-tx-hash-issue
ramtinms Feb 24, 2024
8f003a5
Merge branch 'master' into janez/time-per-computation-estimation-logs
janezpodhostnik Feb 26, 2024
20efe04
Merge branch 'master' into evm-events-more-test-assertions
janezpodhostnik Feb 26, 2024
f64ed9e
Merge pull request #5385 from onflow/janez/time-per-computation-estim…
janezpodhostnik Feb 26, 2024
c4831ee
Merge pull request #5454 from onflow/ramtin/flow-evm-fix-tx-hash-issue
ramtinms Feb 26, 2024
29142a1
Merge branch 'master' into evm-events-more-test-assertions
janezpodhostnik Feb 26, 2024
3771366
apply pr feedbacks
ramtinms Feb 26, 2024
49aabc9
Merge pull request #5416 from m-Peter/evm-events-more-test-assertions
janezpodhostnik Feb 26, 2024
aa51a1b
expose more functions for evm addr
ramtinms Feb 26, 2024
583caba
Merge branch 'master' into fxamacker/improve-payload-file
fxamacker Feb 26, 2024
03c69c1
add test for nonce
ramtinms Feb 26, 2024
35d56ce
Merge pull request #5438 from onflow/fxamacker/improve-payload-file
fxamacker Feb 26, 2024
58b189e
Merge branch 'master' into ramtin/flow-evm-dont-returne-address-zero-…
ramtinms Feb 26, 2024
fbe9716
add test for codeHash
ramtinms Feb 26, 2024
ba8588e
Merge branch 'master' into ramtin/flow-evm-dont-returne-address-zero-…
ramtinms Feb 26, 2024
3df00b6
clean up
ramtinms Feb 26, 2024
a660585
Merge branch 'master' into ramtin/5458-expose-evm-code-codehash-nonce
ramtinms Feb 26, 2024
c912767
Merge pull request #5456 from onflow/ramtin/flow-evm-dont-returne-add…
ramtinms Feb 26, 2024
f9c5cbf
Merge branch 'master' into ramtin/5458-expose-evm-code-codehash-nonce
ramtinms Feb 26, 2024
6908b7e
Merge pull request #5460 from onflow/ramtin/5458-expose-evm-code-code…
ramtinms Feb 27, 2024
c8ee48d
Merge branch 'master' into ramtin/update-stable-cadence-13
ramtinms Feb 28, 2024
f0942ac
fix merge issue
ramtinms Feb 28, 2024
17df3d5
fix renamed types
ramtinms Feb 28, 2024
1dbb69d
Merge branch 'feature/stable-cadence' into ramtin/update-stable-caden…
janezpodhostnik Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions cmd/util/cmd/execution-state-extract/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,30 @@ import (

"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/cmd/util/ledger/migrations"
"github.com/onflow/flow-go/cmd/util/ledger/util"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/metrics"
"github.com/onflow/flow-go/storage/badger"
)

var (
flagExecutionStateDir string
flagOutputDir string
flagBlockHash string
flagStateCommitment string
flagDatadir string
flagChain string
flagNWorker int
flagNoMigration bool
flagNoReport bool
flagValidateMigration bool
flagLogVerboseValidationError bool
flagStagedContractsFile string
flagInputPayloadFileName string
flagOutputPayloadFileName string
flagOutputPayloadByAddresses string
flagExecutionStateDir string
flagOutputDir string
flagBlockHash string
flagStateCommitment string
flagDatadir string
flagChain string
flagNWorker int
flagNoMigration bool
flagNoReport bool
flagValidateMigration bool
flagAllowPartialStateFromPayloads bool
flagLogVerboseValidationError bool
flagStagedContractsFile string
Comment on lines +35 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflict resolution 1 - kept both flags

flagInputPayloadFileName string
flagOutputPayloadFileName string
flagOutputPayloadByAddresses string
)

var Cmd = &cobra.Command{
Expand Down Expand Up @@ -82,6 +84,9 @@ func init() {
Cmd.Flags().StringVar(&flagStagedContractsFile, "staged-contracts", "",
"Staged contracts CSV file")

Cmd.Flags().BoolVar(&flagAllowPartialStateFromPayloads, "allow-partial-state-from-payload-file", false,
"allow input payload file containing partial state (e.g. not all accounts)")

// If specified, the state will consist of payloads from the given input payload file.
// If not specified, then the state will be extracted from the latest checkpoint file.
// This flag can be used to reduce total duration of migrations when state extraction involves
Expand Down Expand Up @@ -172,6 +177,29 @@ func run(*cobra.Command, []string) {
if _, err := os.Stat(flagInputPayloadFileName); os.IsNotExist(err) {
log.Fatal().Msgf("payload input file %s doesn't exist", flagInputPayloadFileName)
}

partialState, err := util.IsPayloadFilePartialState(flagInputPayloadFileName)
if err != nil {
log.Fatal().Err(err).Msgf("cannot get flag from payload input file %s", flagInputPayloadFileName)
}

// Check if payload file contains partial state and is allowed by --allow-partial-state-from-payload-file.
if !flagAllowPartialStateFromPayloads && partialState {
log.Fatal().Msgf("payload input file %s contains partial state, please specify --allow-partial-state-from-payload-file", flagInputPayloadFileName)
}

msg := "input payloads represent "
if partialState {
msg += "partial state"
} else {
msg += "complete state"
}
if flagAllowPartialStateFromPayloads {
msg += ", and --allow-partial-state-from-payload-file is specified"
} else {
msg += ", and --allow-partial-state-from-payload-file is NOT specified"
}
log.Info().Msg(msg)
}

if len(flagOutputPayloadFileName) > 0 {
Expand Down
25 changes: 24 additions & 1 deletion cmd/util/cmd/execution-state-extract/execution_state_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,22 @@ func extractExecutionState(
if exportPayloads {
payloads := newTrie.AllPayloads()

log.Info().Msgf("sorting %d payloads", len(payloads))

// Sort payloads to produce deterministic payload file with
// same sequence of payloads inside.
payloads = util.SortPayloadsByAddress(payloads, nWorker)

log.Info().Msgf("sorted %d payloads", len(payloads))

log.Info().Msgf("creating payloads file %s", outputPayloadFile)

exportedPayloadCount, err := util.CreatePayloadFile(
log,
outputPayloadFile,
payloads,
exportPayloadsByAddresses,
false, // payloads represents entire state.
)
if err != nil {
return fmt.Errorf("cannot generate payloads file: %w", err)
Expand Down Expand Up @@ -218,7 +229,7 @@ func extractExecutionStateFromPayloads(
exportPayloadsByAddresses []common.Address,
) error {

payloads, err := util.ReadPayloadFile(log, inputPayloadFile)
inputPayloadsFromPartialState, payloads, err := util.ReadPayloadFile(log, inputPayloadFile)
if err != nil {
return err
}
Expand All @@ -242,11 +253,23 @@ func extractExecutionStateFromPayloads(

exportPayloads := len(outputPayloadFile) > 0
if exportPayloads {

log.Info().Msgf("sorting %d payloads", len(payloads))

// Sort payloads to produce deterministic payload file with
// same sequence of payloads inside.
payloads = util.SortPayloadsByAddress(payloads, nWorker)

log.Info().Msgf("sorted %d payloads", len(payloads))

log.Info().Msgf("creating payloads file %s", outputPayloadFile)

exportedPayloadCount, err := util.CreatePayloadFile(
log,
outputPayloadFile,
payloads,
exportPayloadsByAddresses,
inputPayloadsFromPartialState,
)
if err != nil {
return fmt.Errorf("cannot generate payloads file: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,10 @@ func TestExtractPayloadsFromExecutionState(t *testing.T) {
require.NoError(t, err)

// Verify exported payloads.
payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
partialState, payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
require.NoError(t, err)
require.Equal(t, len(keysValues), len(payloadsFromFile))
require.False(t, partialState)

for _, payloadFromFile := range payloadsFromFile {
k, err := payloadFromFile.Key()
Expand Down Expand Up @@ -397,9 +398,10 @@ func TestExtractPayloadsFromExecutionState(t *testing.T) {
require.NoError(t, err)

// Verify exported payloads.
payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
partialState, payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
require.NoError(t, err)
require.Equal(t, len(selectedKeysValues), len(payloadsFromFile))
require.True(t, partialState)

for _, payloadFromFile := range payloadsFromFile {
k, err := payloadFromFile.Key()
Expand Down Expand Up @@ -446,6 +448,7 @@ func TestExtractStateFromPayloads(t *testing.T) {
inputPayloadFileName,
payloads,
nil,
false,
)
require.NoError(t, err)
require.Equal(t, len(payloads), numOfPayloadWritten)
Expand Down Expand Up @@ -516,6 +519,7 @@ func TestExtractStateFromPayloads(t *testing.T) {
inputPayloadFileName,
payloads,
nil,
false,
)
require.NoError(t, err)
require.Equal(t, len(payloads), numOfPayloadWritten)
Expand All @@ -536,9 +540,79 @@ func TestExtractStateFromPayloads(t *testing.T) {
require.NoError(t, err)

// Verify exported payloads.
payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
partialState, payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
require.NoError(t, err)
require.Equal(t, len(keysValues), len(payloadsFromFile))
require.False(t, partialState)

for _, payloadFromFile := range payloadsFromFile {
k, err := payloadFromFile.Key()
require.NoError(t, err)

kv, exist := keysValues[k.String()]
require.True(t, exist)

require.Equal(t, kv.value, payloadFromFile.Value())
}
})
})

t.Run("input is partial state", func(t *testing.T) {
withDirs(t, func(_, execdir, outdir string) {
size := 10

inputPayloadFileName := filepath.Join(execdir, payloadFileName)
outputPayloadFileName := filepath.Join(outdir, "selected.payload")

// Generate some data
keysValues := make(map[string]keyPair)
var payloads []*ledger.Payload

for i := 0; i < size; i++ {
keys, values := getSampleKeyValues(i)

for j, key := range keys {
keysValues[key.String()] = keyPair{
key: key,
value: values[j],
}

payloads = append(payloads, ledger.NewPayload(key, values[j]))
}
}

// Create input payload file that represents partial state
numOfPayloadWritten, err := util.CreatePayloadFile(
zerolog.Nop(),
inputPayloadFileName,
payloads,
nil,
true,
)
require.NoError(t, err)
require.Equal(t, len(payloads), numOfPayloadWritten)

// Since input payload file is partial state, --allow-partial-state-from-payload-file must be specified.
Cmd.SetArgs([]string{
"--execution-state-dir", execdir,
"--output-dir", outdir,
"--no-migration",
"--no-report",
"--state-commitment", "",
"--input-payload-filename", inputPayloadFileName,
"--output-payload-filename", outputPayloadFileName,
"--extract-payloads-by-address", "",
"--allow-partial-state-from-payload-file",
"--chain", flow.Emulator.Chain().String()})

err = Cmd.Execute()
require.NoError(t, err)

// Verify exported payloads.
partialState, payloadsFromFile, err := util.ReadPayloadFile(zerolog.Nop(), outputPayloadFileName)
require.NoError(t, err)
require.Equal(t, len(keysValues), len(payloadsFromFile))
require.True(t, partialState)

for _, payloadFromFile := range payloadsFromFile {
k, err := payloadFromFile.Key()
Expand Down
Loading
Loading