erigon-pulse/cmd/devnettest/commands/parity.go
leonardchinonso 3102a04d7f
Draft PR for the devnet automation (#4057)
* Draft PR for the devnet automation

* Committing to save for later edit

* Finished creating shells, to test

* Changes:
* Added a shell for picking eth commands
* Implemented erigon node running with the --http flag to save processes
* Shell commands for get-balance and send-tx implemented
TODO:
* Make UX more friendly by adding start, stop and exit commands
* Add progress bar to show wait in progress
* Add flag or input to enable mining option for erigon node
* Implemented stress tests for other eth methods

* Experimenting

* little clean up

* lint

* Transitioned to static runs and tests from shell

* Finished stress test methods

* Rendering fixes

* save

* Cleanup

* Fixed lint

* Still fixing lint

* Removed args append ineffect

* Removed println in genesis init.go

* Removed println in genesis init.go

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Enrique Avila <eavilaasapche@gmail.com>
2022-05-26 13:08:25 +01:00

46 lines
1.5 KiB
Go

package commands
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
"strings"
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
"github.com/ledgerwatch/erigon/common"
"github.com/spf13/cobra"
)
var (
offsetAddr string
quantity int
)
func init() {
//listStorageKeysCmd.Flags().StringVar(&services.DevAddress, "addr", "", "String address to list keys")
//listStorageKeysCmd.MarkFlagRequired("addr")
//listStorageKeysCmd.Flags().StringVar(&offsetAddr, "offset", "", "Offset storage key from which the batch should start")
//listStorageKeysCmd.Flags().IntVar(&quantity, "quantity", 10, "Integer number of addresses to display in a batch")
//listStorageKeysCmd.Flags().StringVar(&blockNum, "block", "latest", "Integer block number, or the string 'latest', 'earliest' or 'pending'; now only 'latest' is available")
rootCmd.AddCommand(listStorageKeysCmd)
}
var listStorageKeysCmd = &cobra.Command{
Use: "parity-list",
Short: "Returns all storage keys of the given address",
RunE: func(cmd *cobra.Command, args []string) error {
if clearDev {
defer services.ClearDevDB()
}
if !common.IsHexAddress(services.DevAddress) {
return fmt.Errorf("address: %v, is not a valid hex address\n", services.DevAddress)
}
toAddress := common.HexToAddress(services.DevAddress)
offset := common.Hex2Bytes(strings.TrimSuffix(offsetAddr, "0x"))
if err := requests.ParityList(reqId, toAddress, quantity, offset, blockNum); err != nil {
fmt.Printf("error getting parity list: %v\n", err)
}
return nil
},
}