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

use 10 positions #24

Merged
merged 52 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0dd85ac
add empowering text
faddat Oct 24, 2024
0a8432a
update readme
faddat Oct 26, 2024
c3830d6
abstract out the joint pieces that are used to broadcast
faddat Oct 26, 2024
e5f11cf
add the position feature
faddat Oct 27, 2024
5a5bf70
continue cleaning
faddat Oct 27, 2024
0963dd5
add cursorignore
faddat Oct 27, 2024
7972f1a
eliminate dirtiness
faddat Oct 27, 2024
87bcc32
cleanup rust contract code
faddat Oct 27, 2024
149ab9d
additional cleanup & linting
faddat Oct 27, 2024
cc71bc1
Merge branch 'main' into faddat/grpc2
faddat Oct 27, 2024
a8f5a12
additional positions related code
faddat Oct 27, 2024
0416856
fix typo
faddat Oct 27, 2024
62426e6
Merge branch 'faddat/grpc2' of https://github.com/somatic-labs/meteor…
faddat Oct 27, 2024
33706bb
run latest clippy
faddat Oct 27, 2024
187391e
additional updates while debugging
faddat Oct 27, 2024
a9b16ba
Update main.go
faddat Oct 27, 2024
588b2e2
Update types/types.go
faddat Oct 27, 2024
8fa323b
Merge branch 'faddat/grpc2' of https://github.com/somatic-labs/meteor…
faddat Oct 27, 2024
c282598
Merge branch 'faddat/grpc2' of https://github.com/somatic-labs/meteor…
faddat Oct 27, 2024
9a7e418
add tests
faddat Oct 27, 2024
99e7b0b
add main_test
faddat Oct 27, 2024
f923132
Update main.go
faddat Oct 27, 2024
bc7ffba
Update lib/lib.go
faddat Oct 27, 2024
1472db3
Update lib/lib.go
faddat Oct 27, 2024
356d029
further test related updates
faddat Oct 27, 2024
928e1a9
Merge branch 'faddat/grpc2' of https://github.com/somatic-labs/meteor…
faddat Oct 27, 2024
0f8bdd7
save place
faddat Oct 27, 2024
4ffab1d
get back to working state
faddat Oct 27, 2024
f148821
update tests
faddat Oct 27, 2024
6582f45
reduce errors to 1
faddat Oct 27, 2024
e0c2963
Update lib/lib.go
faddat Oct 27, 2024
82268b6
Update main.go
faddat Oct 27, 2024
cab072b
Update main_test.go
faddat Oct 27, 2024
ffa2175
Update main.go
faddat Oct 27, 2024
a12f662
balancing transactions now working
faddat Oct 28, 2024
0dbeb4f
Merge branch 'faddat/grpc2' of https://github.com/somatic-labs/meteor…
faddat Oct 28, 2024
f792535
bring in the army: positions are here
faddat Oct 28, 2024
066fedb
add cursor rules
faddat Oct 28, 2024
a4a90dd
early version of gatling gun mode
faddat Oct 28, 2024
6d238d0
Update main.go
faddat Oct 28, 2024
9fb70bc
Create test.yml
faddat Oct 28, 2024
b38a583
Revert "Update main.go"
faddat Oct 28, 2024
669f150
add further timing debugging tools
faddat Oct 28, 2024
33abf49
bank send....
faddat Oct 28, 2024
9c0ce57
further accelerate, supporting 50 simultaneous positions
faddat Oct 28, 2024
7a1d973
Update main.go
faddat Oct 28, 2024
82c12d3
Update lib/lib.go
faddat Oct 28, 2024
51812e6
hardhat
faddat Oct 28, 2024
5ff4bc1
fix tests
faddat Oct 28, 2024
7e0b920
Merge branch 'faddat/grpc2' of https://github.com/somatic-labs/meteor…
faddat Oct 28, 2024
26dcf75
Update lib/lib.go
faddat Oct 28, 2024
f662930
Update main.go
faddat Oct 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
3 changes: 3 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
emails/
configurations/
23 changes: 23 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Hardhat .cursorrules

// HTMX and Go best practices
const htmxGoBestPractices = [
"follow practices suited for cosmos-sdk v0.50.x",
"follow practices suited for ibc-go v8.x.x"
];

// Folder structure
const folderStructure = `
main.go
lib/

modules/
go.mod
go.sum
`;

// Additional instructions
const additionalInstructions = `
1. We are building a high speed test framework for mainnets
2. We should aim for this application to be precise and performant
`;
29 changes: 29 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .github/workflows/clippy.yml
name: Clippy

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
clippy:
name: Run Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- name: Run Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --manifest-path contracts/statefilestore/Cargo.toml -- -D warnings
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
branches:
- main
pull_request:
branches:
- main
name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.23.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- run: go test ./...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
**seedphrase
**meteorite
**meteorite
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ This will initiate the testing suite with your specified configurations.

## Important Notes

- **Responsible Use**: meteorite is designed for use on test networks and should be used responsibly. Ensure you have proper authorization before testing on any network you do not own or operate.
- **Responsible Use**: meteorite is designed for use on mainnets. The tokens you own grant you the right to make any valid transaction. Like any user of any chain, meteorite can only make valid transactions.
* Test your favorite mainnet, yourself, and make sure that you can't get Luna'd
* Test your favorite mainnet, yourself, and make sure that you can't get Levana'd

Over $70,001,400,000 has been lost to the class of issues named p2p storms.

If you're investing, test the chain. It's free if you tweet about using meteorite.
Comment on lines +47 to +49
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Citation needed for financial loss claim and promotional terms need revision

  1. While P2P storms are documented as a significant issue (mentioned in multiple places in the README and configuration files, with specific incidents in Luna Classic 2022 and Stride 2023), the exact financial loss figure ($70,001,400,000) lacks any verifiable source or citation.

  2. The promotional offer needs to be more specific:

    • Replace "It's free if you tweet about using meteorite" with clearer terms that specify:
      • The exact testing service being offered
      • Required tweet content/format (hashtag, mention)
      • Where to claim the free testing after tweeting
🔗 Analysis chain

Add citation and clarify promotional offer.

  1. The specific financial loss figure ($70,001,400,000) should include a citation or reference to its source for credibility.
  2. The promotional offer about free testing needs clarification:
    • What exactly is being offered for free?
    • What are the specific terms of the promotion?
    • Where should users tweet (specific hashtag or mention)?

Let's verify if this figure is mentioned elsewhere in the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any mentions of the financial loss figure
rg -i "70.*billion|70.*000.*000" 

Length of output: 34


Script:

#!/bin/bash
# Let's try a broader search for any mentions of financial losses or P2P storms
rg -i "lost.*p2p|p2p.*storm" -A 2 -B 2

# Also search for any promotional or testing related content
rg -i "free.*test|test.*free" -A 2 -B 2

Length of output: 7531


- **Valid Transactions Only**: The tool operates within the bounds of valid transactions explicitly supported by the chains it tests.
- **Reporting Issues**: For questions about meteorite's capabilities or to report potential security issues, please contact the project maintainers through the appropriate channels listed in this repository.

Expand Down
134 changes: 118 additions & 16 deletions broadcast/broadcast.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
package broadcast

import (
"context"
"fmt"
"log"
"time"

cometrpc "github.com/cometbft/cometbft/rpc/client/http"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
tmtypes "github.com/cometbft/cometbft/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/somatic-labs/meteorite/lib"
types "github.com/somatic-labs/meteorite/types"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

// Add these at the top of the file
type TimingMetrics struct {
PrepStart time.Time
SignStart time.Time
BroadStart time.Time
Complete time.Time
Position int
}

func (t *TimingMetrics) LogTiming(sequence uint64, success bool, err error) {
prepTime := t.SignStart.Sub(t.PrepStart)
signTime := t.BroadStart.Sub(t.SignStart)
broadcastTime := t.Complete.Sub(t.BroadStart)
totalTime := t.Complete.Sub(t.PrepStart)

status := "SUCCESS"
if !success {
status = "FAILED"
}

fmt.Printf("[POS-%d] %s Transaction %s: seq=%d prep=%v sign=%v broadcast=%v total=%v%s\n",
t.Position,
time.Now().Format("15:04:05.000"),
status,
sequence,
prepTime,
signTime,
broadcastTime,
totalTime,
formatError(err))
}

func formatError(err error) string {
if err != nil {
return fmt.Sprintf(" error=\"%v\"", err)
}
return ""
}
faddat marked this conversation as resolved.
Show resolved Hide resolved

var cdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())

func init() {
Expand All @@ -24,24 +62,88 @@ func init() {

// Transaction broadcasts the transaction bytes to the given RPC endpoint.
func Transaction(txBytes []byte, rpcEndpoint string) (*coretypes.ResultBroadcastTx, error) {
cmtCli, err := cometrpc.New(rpcEndpoint, "/websocket")
client, err := GetClient(rpcEndpoint)
if err != nil {
log.Fatal(err)
return nil, err
}

t := tmtypes.Tx(txBytes)
return client.Transaction(txBytes)
}

ctx := context.Background()
res, err := cmtCli.BroadcastTxSync(ctx, t)
if err != nil {
fmt.Println("Error at broadcast:", err)
return nil, err
// Loop handles the main transaction broadcasting logic
func Loop(
txParams types.TransactionParams,
batchSize int,
position int,
) (successfulTxns, failedTxns int, responseCodes map[uint32]int, updatedSequence uint64) {
successfulTxns = 0
failedTxns = 0
responseCodes = make(map[uint32]int)
sequence := txParams.Sequence

for i := 0; i < batchSize; i++ {
currentSequence := sequence
metrics := &TimingMetrics{
PrepStart: time.Now(),
Position: position,
}

metrics.SignStart = time.Now()
metrics.BroadStart = time.Now()
resp, _, err := SendTransactionViaRPC(txParams, currentSequence)
metrics.Complete = time.Now()

if err != nil {
metrics.LogTiming(currentSequence, false, err)
failedTxns++

if resp != nil && resp.Code == 32 {
newSeq, success, newResp := handleSequenceMismatch(txParams, position, sequence, err)
sequence = newSeq
if success {
successfulTxns++
responseCodes[newResp.Code]++
}
continue
}
continue
}

metrics.LogTiming(currentSequence, true, nil)
successfulTxns++
responseCodes[resp.Code]++
sequence++
}

updatedSequence = sequence
return successfulTxns, failedTxns, responseCodes, updatedSequence
}

// handleSequenceMismatch handles the case where a transaction fails due to sequence mismatch
func handleSequenceMismatch(txParams types.TransactionParams, position int, sequence uint64, err error) (uint64, bool, *coretypes.ResultBroadcastTx) {
expectedSeq, parseErr := lib.ExtractExpectedSequence(err.Error())
if parseErr != nil {
fmt.Printf("[POS-%d] Failed to parse expected sequence: %v\n", position, parseErr)
return sequence, false, nil
}

if res.Code != 0 {
// Return an error containing the code and log message
return res, fmt.Errorf("broadcast error code %d: %s", res.Code, res.Log)
fmt.Printf("[POS-%d] Set sequence to expected value %d due to mismatch\n", position, expectedSeq)

metrics := &TimingMetrics{
PrepStart: time.Now(),
Position: position,
}

metrics.SignStart = time.Now()
metrics.BroadStart = time.Now()
resp, _, err := SendTransactionViaRPC(txParams, expectedSeq)
metrics.Complete = time.Now()

if err != nil {
metrics.LogTiming(expectedSeq, false, err)
return expectedSeq, false, nil
}

return res, nil
metrics.LogTiming(expectedSeq, true, nil)
return expectedSeq + 1, true, resp
}
68 changes: 68 additions & 0 deletions broadcast/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package broadcast

import (
"context"
"fmt"
"sync"
"time"

cometrpc "github.com/cometbft/cometbft/rpc/client/http"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
tmtypes "github.com/cometbft/cometbft/types"
)

type Client struct {
client *cometrpc.HTTP
}

var (
clients = make(map[string]*Client)
clientsMux sync.RWMutex
)

func GetClient(rpcEndpoint string) (*Client, error) {
clientsMux.RLock()
if client, exists := clients[rpcEndpoint]; exists {
clientsMux.RUnlock()
return client, nil
}
clientsMux.RUnlock()

// If client doesn't exist, acquire write lock and create it
clientsMux.Lock()
defer clientsMux.Unlock()

// Double-check after acquiring write lock
if client, exists := clients[rpcEndpoint]; exists {
return client, nil
}

// Create new client
cmtCli, err := cometrpc.New(rpcEndpoint, "/websocket")
if err != nil {
return nil, err
}

client := &Client{
client: cmtCli,
}
clients[rpcEndpoint] = client
return client, nil
}

func (b *Client) Transaction(txBytes []byte) (*coretypes.ResultBroadcastTx, error) {
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()

t := tmtypes.Tx(txBytes)
res, err := b.client.BroadcastTxSync(ctx, t)
if err != nil {
return nil, err
}

if res.Code != 0 {
return res, fmt.Errorf("broadcast error code %d: %s", res.Code, res.Log)
}

return res, nil
}
Loading
Loading