diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 330961a2..3bda35c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,12 +70,12 @@ jobs: go-version: ${{ env.go_version }} - run: make test-cover COVERALLS_TOKEN="$COVERALLS_TOKEN" - Salus: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - version: latest - - run: make salus + # Salus: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # with: + # version: latest + # - run: make salus \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index 5a1b52e3..db54134b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -61,6 +61,7 @@ var ( requestUUID string statusPort uint InfoMetaData string + targetAccount string // Config is the populated *configuration.Configuration from // the configurationFile. If none is provided, this is set @@ -246,6 +247,13 @@ default values.`, "Override online node url in configuration file", ) + checkDataCmd.Flags().StringVar( + &targetAccount, + "target-account", + "", + "Override target account in configuration file", + ) + checkDataCmd.Flags().Int64Var( &startIndex, "start-block", @@ -425,6 +433,10 @@ func initConfig() { Config.Construction.OfflineURL = offlineURL } + if len(targetAccount) != 0 { + Config.TargetAccount = targetAccount + } + // Override start and end syncing index in configuration file when it's explicitly set via CLI if startIndex != -1 { Config.Data.StartIndex = &startIndex diff --git a/configuration/types.go b/configuration/types.go index f8b2da48..4e2ecfeb 100644 --- a/configuration/types.go +++ b/configuration/types.go @@ -362,6 +362,9 @@ type Configuration struct { // OnlineURL is the URL of a Rosetta API implementation in "online mode". OnlineURL string `json:"online_url"` + // TargetAccount will be the only interest account + TargetAccount string `json:"target_account,omitempty"` + // DataDirectory is a folder used to store logs and any data used to perform validation. // The path can be absolute, or it can be relative to where rosetta-cli // binary is being executed. diff --git a/pkg/tester/data.go b/pkg/tester/data.go index 68afd896..1de767a5 100644 --- a/pkg/tester/data.go +++ b/pkg/tester/data.go @@ -149,6 +149,30 @@ func loadAccounts(filePath string) ([]*types.AccountCurrency, error) { return accounts, nil } +// loadAccount is a utility function to parse the []*types.AccountCurrency +// from a string. +func loadAccount(accountAddress string) []*types.AccountCurrency { + if len(accountAddress) == 0 { + return []*types.AccountCurrency{} + } + + accounts := []*types.AccountCurrency{} + accountIndentifier := &types.AccountIdentifier{ + Address: accountAddress, + // You can set other fields of AccountIdentifier here if needed. + } + + // Create an AccountCurrency instance with the Account field set to the created AccountIdentifier. + targetAccount := &types.AccountCurrency{ + Account: accountIndentifier, + // You can set other fields of AccountCurrency here if needed. + } + + accounts = append(accounts, targetAccount) + + return accounts +} + // CloseDatabase closes the database used by DataTester. func (t *DataTester) CloseDatabase(ctx context.Context) { if err := t.database.Close(ctx); err != nil { @@ -249,6 +273,14 @@ func InitializeData( color.Red(err.Error()) return nil, err } + if len(config.TargetAccount) != 0 { + interestingAccounts = loadAccount(config.TargetAccount) + } + + interestingOnly := false + if len(interestingAccounts) != 0 { + interestingOnly = true + } counterStorage := modules.NewCounterStorage(localStore) blockStorage := modules.NewBlockStorage(localStore, config.SerialBlockWorkers) @@ -357,11 +389,17 @@ func InitializeData( counterStorage, historicalBalanceEnabled, exemptAccounts, - false, + interestingOnly, networkOptions.Allow.BalanceExemptions, config.Data.InitialBalanceFetchDisabled, ) + if interestingOnly { + for _, interesinterestingAccount := range interestingAccounts { + balanceStorageHelper.AddInterestingAddress(interesinterestingAccount.Account.Address) + } + } + balanceStorageHandler := processor.NewBalanceStorageHandler( logger, r,