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

Decouple Spam Functionality from CLI into Throughput Package #1636

Merged
merged 34 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a93ecf1
move into seperate package
samliok Oct 2, 2024
56cf0b7
extract cli prompting
samliok Oct 2, 2024
9d8a718
hang condition
samliok Oct 2, 2024
fa42146
take out close database
samliok Oct 3, 2024
2e878a3
strip out all spam into seperate package
samliok Oct 3, 2024
781b29a
remove get factory from handler, potentially could move into auth
samliok Oct 3, 2024
596d48c
pull out pacer and distribute funds
samliok Oct 3, 2024
0aefe39
redundant unit prices
samliok Oct 3, 2024
39b682c
seperate logging go routine
samliok Oct 3, 2024
f99c260
remove defer stop for logging
samliok Oct 3, 2024
e18d659
remove unused errors
samliok Oct 3, 2024
ba476cd
save
samliok Oct 3, 2024
0ef4f90
seperate auth and spam helper
samliok Oct 3, 2024
6ae8f3c
spam script working
samliok Oct 4, 2024
7db9c3e
get factory into auth
samliok Oct 4, 2024
7dfde55
added defaults to cli
samliok Oct 4, 2024
bc72196
remove deploydevnetscript.sh
samliok Oct 4, 2024
deb18b4
dont hardcode balance
samliok Oct 4, 2024
e1328bc
e2e tests working
samliok Oct 4, 2024
974ed4d
remove old debugging
samliok Oct 4, 2024
787fff8
rename to throughput
samliok Oct 4, 2024
bbdc3f4
update imports
samliok Oct 4, 2024
eda116d
fmt somethings
samliok Oct 4, 2024
8ef31af
uncomment e2e
samliok Oct 4, 2024
1add5d0
merge conflicts but now returning funds not working
samliok Oct 4, 2024
0249c6a
fix log
samliok Oct 4, 2024
ccdcd7c
funds bug
samliok Oct 4, 2024
4448232
fix lint script
samliok Oct 4, 2024
7fef415
move logging into issuer
samliok Oct 7, 2024
b9f1074
update funds map correctly
samliok Oct 7, 2024
d00518b
remove lookup balance
samliok Oct 7, 2024
9e30569
vmwithcontracts lint
samliok Oct 8, 2024
02ba233
pr comments: moving packages, updated lint, nits
samliok Oct 10, 2024
c391936
Merge branch 'main' into loadgen
samliok Oct 10, 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
44 changes: 44 additions & 0 deletions auth/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package auth

import (
"errors"

"github.com/ava-labs/hypersdk/chain"
"github.com/ava-labs/hypersdk/codec"
"github.com/ava-labs/hypersdk/crypto/bls"
"github.com/ava-labs/hypersdk/crypto/ed25519"
"github.com/ava-labs/hypersdk/crypto/secp256r1"
)

var ErrInvalidKeyType = errors.New("invalid key type")

// Used for testing & CLI purposes
type PrivateKey struct {
Address codec.Address
// Bytes is the raw private key bytes
Bytes []byte
}

// GetFactory returns the [chain.AuthFactory] for a given private key.
//
// A [chain.AuthFactory] signs transactions and provides a unit estimate
// for using a given private key (needed to estimate fees for a transaction).
func GetFactory(pk *PrivateKey) (chain.AuthFactory, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was previously in the SpamHelper but I think it makes more sense to separate it out and minimize the SpamHelper interface

switch pk.Address[0] {
case ED25519ID:
return NewED25519Factory(ed25519.PrivateKey(pk.Bytes)), nil
case SECP256R1ID:
return NewSECP256R1Factory(secp256r1.PrivateKey(pk.Bytes)), nil
case BLSID:
Comment on lines +30 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

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

(followup) Could we decouple this from the exact crypto libraries that are available if we are going to move it into the auth package and switch to using a type parser of AuthFactory that uses the first byte as the typeID and uses each of these functions as the Unmarshal function ?

p, err := bls.PrivateKeyFromBytes(pk.Bytes)
if err != nil {
return nil, err
}
return NewBLSFactory(p), nil
default:
return nil, ErrInvalidKeyType
}
}
Loading
Loading