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

Pingpong nft #2007

Merged
merged 8 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions cmd/pingpong/runCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var appProgGlobKeys uint32
var appProgLocalKeys uint32
var duration uint32
var rekey bool
var nftAsaPerSecond uint32

func init() {
rootCmd.AddCommand(runCmd)
Expand Down Expand Up @@ -105,6 +106,7 @@ func init() {
runCmd.Flags().BoolVar(&randomLease, "randomlease", false, "set the lease to contain a random value")
runCmd.Flags().BoolVar(&rekey, "rekey", false, "Create RekeyTo transactions. Requires groupsize=2 and any of random flags exc random dst")
runCmd.Flags().Uint32Var(&duration, "duration", 0, "The number of seconds to run the pingpong test, forever if 0")
runCmd.Flags().Uint32Var(&nftAsaPerSecond, "nftasapersecond", 0, "The number of NFT-style ASAs to create per second")

}

Expand Down Expand Up @@ -302,11 +304,15 @@ var runCmd = &cobra.Command{
}
}

cfg.NftAsaPerSecond = nftAsaPerSecond

reportInfof("Preparing to initialize PingPong with config:\n")
cfg.Dump(os.Stdout)

pps := pingpong.NewPingpong(cfg)

// Initialize accounts if necessary
accounts, cinfo, cfg, err := pingpong.PrepareAccounts(ac, cfg)
err = pps.PrepareAccounts(ac)
if err != nil {
reportErrorf("Error preparing accounts for transfers: %v\n", err)
}
Expand All @@ -319,7 +325,7 @@ var runCmd = &cobra.Command{
cfg.Dump(os.Stdout)

// Kick off the real processing
pingpong.RunPingPong(context.Background(), ac, accounts, cinfo, cfg)
pps.RunPingPong(context.Background(), ac)
},
}

Expand Down
6 changes: 4 additions & 2 deletions shared/pingpong/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ func throttleTransactionRate(startTime time.Time, cfg PpConfig, totalSent uint64
// Step 1) Create X assets for each of the participant accounts
// Step 2) For each participant account, opt-in to assets of all other participant accounts
// Step 3) Evenly distribute the assets across all participant accounts
func prepareAssets(accounts map[string]uint64, client libgoal.Client, cfg PpConfig) (resultAssetMaps map[uint64]v1.AssetParams, optIns map[uint64][]string, err error) {
func (pps *WorkerState) prepareAssets(assetAccounts map[string]uint64, client libgoal.Client) (resultAssetMaps map[uint64]v1.AssetParams, optIns map[uint64][]string, err error) {
accounts := assetAccounts
cfg := pps.cfg
proto, err := getProto(client)
if err != nil {
return
Expand Down Expand Up @@ -353,7 +355,7 @@ func prepareAssets(accounts map[string]uint64, client libgoal.Client, cfg PpConf
fmt.Printf("Distributing assets from %v to %v \n", creator, addr)
}

tx, sendErr := constructTxn(creator, addr, cfg.MaxFee, assetAmt, k, CreatablesInfo{}, client, cfg)
tx, sendErr := pps.constructTxn(creator, addr, cfg.MaxFee, assetAmt, k, client)
if sendErr != nil {
fmt.Printf("Cannot transfer asset %v from account %v\n", k, creator)
err = sendErr
Expand Down
8 changes: 8 additions & 0 deletions shared/pingpong/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ type PpConfig struct {
AppLocalKeys uint32
Rekey bool
MaxRuntime time.Duration

// asset spam; make lots of NFT ASAs
NftAsaPerSecond uint32 // e.g. 100
NftAsaPerAccount uint32 // 0..999
NftAsaAccountInFlight uint32
}

// DefaultConfig object for Ping Pong
Expand Down Expand Up @@ -88,6 +93,9 @@ var DefaultConfig = PpConfig{
AppProgHashSize: "sha256",
Rekey: false,
MaxRuntime: 0,

NftAsaAccountInFlight: 5,
NftAsaPerAccount: 900,
}

// LoadConfigFromFile reads and loads Ping Pong configuration
Expand Down
Loading