Skip to content

Commit

Permalink
feat: loadtest monitor new blob params + ui cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Ji Hwan <[email protected]>
  • Loading branch information
jhkimqd committed Jun 7, 2024
1 parent fa42df0 commit af7379f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cmd/monitor/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ func GetTxMethod(tx rpctypes.PolyTransaction) string {
if tx.To().String() == "0x0000000000000000000000000000000000000000" {
// Contract deployment
txMethod = "Contract Deployment"
} else if tx.Type() == 3 {
txMethod = "Blob"
} else if len(tx.Data()) > 4 {
// Contract call
txMethod = hex.EncodeToString(tx.Data()[0:4])
Expand Down Expand Up @@ -337,7 +339,7 @@ func GetTransactionsList(block rpctypes.PolyBlock, chainID *big.Int) ([]string,
txs := block.Transactions()

headerVariables := []string{"Txn Hash", "Method", "From", "To", "Value", "Gas Price"}
proportion := []int{60, 5, 15, 15, 30}
proportion := []int{60, 5, 50, 50, 20}

header := ""
for i, prop := range proportion {
Expand All @@ -352,8 +354,10 @@ func GetTransactionsList(block rpctypes.PolyBlock, chainID *big.Int) ([]string,
recordVariables := []string{
fmt.Sprintf("%s", tx.Hash()),
txMethod,
metrics.TruncateHexString(fmt.Sprintf("%s", tx.From()), 14),
metrics.TruncateHexString(fmt.Sprintf("%s", tx.To()), 14),
// metrics.TruncateHexString(fmt.Sprintf("%s", tx.From()), 14),
// metrics.TruncateHexString(fmt.Sprintf("%s", tx.To()), 14),
fmt.Sprintf("%s", tx.From()),
fmt.Sprintf("%s", tx.To()),
fmt.Sprintf("%s", tx.Value()),
fmt.Sprintf("%s", tx.GasPrice()),
}
Expand All @@ -378,14 +382,7 @@ func GetSimpleTxFields(tx rpctypes.PolyTransaction, chainID, baseFee *big.Int) [
fields := make([]string, 0)
fields = append(fields, fmt.Sprintf("Tx Hash: %s", tx.Hash()))

txMethod := "Transfer"
if tx.To().String() == "0x0000000000000000000000000000000000000000" {
// Contract deployment
txMethod = "Contract Deployment"
} else if len(tx.Data()) > 4 {
// Contract call
txMethod = hex.EncodeToString(tx.Data()[0:4])
}
txMethod := GetTxMethod(tx)

fields = append(fields, fmt.Sprintf("To: %s", tx.To()))
fields = append(fields, fmt.Sprintf("From: %s", tx.From()))
Expand All @@ -399,6 +396,9 @@ func GetSimpleTxFields(tx rpctypes.PolyTransaction, chainID, baseFee *big.Int) [
fields = append(fields, fmt.Sprintf("Type: %d", tx.Type()))
fields = append(fields, fmt.Sprintf("Data Len: %d", len(tx.Data())))
fields = append(fields, fmt.Sprintf("Data: %s", hex.EncodeToString(tx.Data())))
fields = append(fields, fmt.Sprintf("R: %s", tx.R()))
fields = append(fields, fmt.Sprintf("S: %s", tx.S()))
fields = append(fields, fmt.Sprintf("V: %s", tx.V()))

return fields
}
Expand Down Expand Up @@ -442,6 +442,8 @@ func GetSimpleReceipt(ctx context.Context, rpc *ethrpc.Client, tx rpctypes.PolyT
fields = append(fields, fmt.Sprintf("GasUsed: %d", receipt.GasUsed().Int64()))
fields = append(fields, fmt.Sprintf("ContractAddress: %s", receipt.ContractAddress().String()))
fields = append(fields, fmt.Sprintf("Root: %s", receipt.Root().String()))
fields = append(fields, fmt.Sprintf("Blob Gas Price: %s", receipt.BlobGasPrice()))
fields = append(fields, fmt.Sprintf("Blob Gas Used: %s", receipt.BlobGasUsed()))

return fields
}
Expand Down
18 changes: 18 additions & 0 deletions rpctypes/rpctypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ type (

// status: QUANTITY either 1 (success) or 0 (failure)
Status RawQuantityResponse `json:"status"`

// blobGasPrice: QUANTITY - blob gas price provided by the sender in Wei.
BlobGasPrice RawQuantityResponse `json:"blobGasPrice"`

// blobGasUsed: QUANTITY - blob gas used by this specific transaction alone.
BlobGasUsed RawQuantityResponse `json:"blobGasUsed"`
}

PolyTransaction interface {
Expand Down Expand Up @@ -267,6 +273,8 @@ type (
LogsBloom() []byte
Root() ethcommon.Hash
Status() uint64
BlobGasPrice() *big.Int
BlobGasUsed() *big.Int
}
PolyReceipts []PolyReceipt
PolyBlock interface {
Expand Down Expand Up @@ -376,6 +384,16 @@ func (i *implPolyReceipt) TransactionIndex() uint64 {
return i.inner.TransactionIndex.ToUint64()
}

// BlobGasPrice implements PolyReceipt.
func (i *implPolyReceipt) BlobGasPrice() *big.Int {
return i.inner.BlobGasPrice.ToBigInt()
}

// BlobGasUsed implements PolyReceipt.
func (i *implPolyReceipt) BlobGasUsed() *big.Int {
return i.inner.BlobGasUsed.ToBigInt()
}

func NewPolyBlock(r *RawBlockResponse) PolyBlock {
i := new(implPolyBlock)
i.inner = r
Expand Down

0 comments on commit af7379f

Please sign in to comment.