mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
rpctest: add option to requestAndCompare to permit to save only success tx (#8726)
This commit is contained in:
parent
cc8bdc5185
commit
def2457b1c
@ -50,7 +50,7 @@ func BenchDebugTraceBlockByNumber(erigonUrl, gethUrl string, needCompare bool, b
|
||||
reqGen.reqID++
|
||||
request := reqGen.debugTraceBlockByNumber(bn)
|
||||
errCtx := fmt.Sprintf("block %d", bn)
|
||||
if err := requestAndCompare(request, "debug_traceBlockByNumber", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "debug_traceBlockByNumber", errCtx, reqGen, needCompare, rec, errs, resultsCh /* insertOnlyIfSuccess */, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,8 @@ func BenchDebugTraceCall(erigonURL, gethURL string, needCompare bool, blockFrom
|
||||
|
||||
request := reqGen.debugTraceCall(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input, bn-1)
|
||||
errCtx := fmt.Sprintf("block %d tx %s", bn, tx.Hash)
|
||||
if err := requestAndCompare(request, "debug_traceCall", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "debug_traceCall", errCtx, reqGen, needCompare, rec, errs, nil,
|
||||
/* insertOnlyIfSuccess*/ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -98,14 +98,18 @@ func BenchEthCall(erigonURL, gethURL string, needCompare, latest bool, blockFrom
|
||||
nTransactions = nTransactions + 1
|
||||
|
||||
var request string
|
||||
var insertedOnlyIfSuccess bool
|
||||
if latest {
|
||||
request = reqGen.ethCallLatest(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input)
|
||||
insertedOnlyIfSuccess = true
|
||||
} else {
|
||||
request = reqGen.ethCall(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input, bn-1)
|
||||
insertedOnlyIfSuccess = false
|
||||
}
|
||||
errCtx := fmt.Sprintf(" bn=%d hash=%s", bn, tx.Hash)
|
||||
|
||||
if err := requestAndCompare(request, "eth_call", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_call", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
insertedOnlyIfSuccess); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,8 @@ func BenchEthGetBlockByHash(erigonURL, gethURL string, needCompare, latest bool,
|
||||
request = reqGen.getBlockByHash(b.Result.Hash, true)
|
||||
errCtx := fmt.Sprintf(" bn=%d hash=%s", bn, b.Result.Hash)
|
||||
|
||||
if err := requestAndCompare(request, "eth_getBlockByHash", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getBlockByHash", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,8 @@ func BenchEthGetBlockByNumber2(erigonURL, gethURL string, needCompare, latest bo
|
||||
request = reqGen.getBlockByNumber(bn, true)
|
||||
errCtx := fmt.Sprintf(" bn=%d ", bn)
|
||||
|
||||
if err := requestAndCompare(request, "eth_getBlockByNumber", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getBlockByNumber", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,8 @@ func BenchEthGetLogs(erigonURL, gethURL string, needCompare bool, blockFrom uint
|
||||
reqGen.reqID++
|
||||
request := reqGen.getLogs(prevBn, bn, account)
|
||||
errCtx := fmt.Sprintf("account %x blocks %d-%d", account, prevBn, bn)
|
||||
if err := requestAndCompare(request, "eth_getLogs", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getLogs", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
@ -103,7 +104,8 @@ func BenchEthGetLogs(erigonURL, gethURL string, needCompare bool, blockFrom uint
|
||||
reqGen.reqID++
|
||||
request = reqGen.getLogs1(prevBn, bn+10000, account, topic)
|
||||
errCtx := fmt.Sprintf("account %x topic %x blocks %d-%d", account, topic, prevBn, bn)
|
||||
if err := requestAndCompare(request, "eth_getLogs", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getLogs", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
@ -118,7 +120,8 @@ func BenchEthGetLogs(erigonURL, gethURL string, needCompare bool, blockFrom uint
|
||||
reqGen.reqID++
|
||||
request = reqGen.getLogs2(prevBn, bn+100000, account, topics[idx1], topics[idx2])
|
||||
errCtx := fmt.Sprintf("account %x topic1 %x topic2 %x blocks %d-%d", account, topics[idx1], topics[idx2], prevBn, bn)
|
||||
if err := requestAndCompare(request, "eth_getLogs", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getLogs", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -103,7 +103,8 @@ func BenchEthGetTransactionByHash(erigonURL, gethURL string, needCompare bool, b
|
||||
request = reqGen.getTransactionByHash(tx.Hash)
|
||||
errCtx := fmt.Sprintf(" bn=%d hash=%s", bn, tx.Hash)
|
||||
|
||||
if err := requestAndCompare(request, "eth_getTransactionByHash", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getTransactionByHash", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func BenchTraceBlock(erigonURL, oeURL string, needCompare bool, blockFrom uint64
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceBlock(bn)
|
||||
errCtx := fmt.Sprintf("block %d", bn)
|
||||
if err := requestAndCompare(request, "trace_block", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_block", errCtx, reqGen, needCompare, rec, errs, nil /* insertOnlyIfSuccess */, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func BenchTraceCall(erigonURL, oeURL string, needCompare bool, blockFrom uint64,
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceCall(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input, bn-1)
|
||||
errCtx := fmt.Sprintf("block %d, tx %s", bn, tx.Hash)
|
||||
if err := requestAndCompare(request, "trace_call", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_call", errCtx, reqGen, needCompare, rec, errs, nil /* insertOnlyIfSuccess */, false); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func BenchTraceCallMany(erigonURL, oeURL string, needCompare bool, blockFrom uin
|
||||
|
||||
request := reqGen.traceCallMany(from, to, gas, gasPrice, value, data, bn-1)
|
||||
errCtx := fmt.Sprintf("block %d", bn)
|
||||
if err := requestAndCompare(request, "trace_callMany", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_callMany", errCtx, reqGen, needCompare, rec, errs, nil /* insertOnlyIfSuccess */, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -95,14 +95,14 @@ func BenchTraceFilter(erigonURL, oeURL string, needCompare bool, blockFrom uint6
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceFilterFrom(prevBn, bn, account)
|
||||
errCtx := fmt.Sprintf("traceFilterFrom fromBlock %d, toBlock %d, fromAddress %x", prevBn, bn, account)
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil /* insertOnlyIfSuccess */, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
reqGen.reqID++
|
||||
request = reqGen.traceFilterTo(prevBn, bn, account)
|
||||
errCtx = fmt.Sprintf("traceFilterTo fromBlock %d, toBlock %d, fromAddress %x", prevBn, bn, account)
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil /* insertOnlyIfSuccess */, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
@ -114,28 +114,28 @@ func BenchTraceFilter(erigonURL, oeURL string, needCompare bool, blockFrom uint6
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceFilterUnion(prevBn, bn, from, to)
|
||||
errCtx := fmt.Sprintf("traceFilterUnion fromBlock %d, toBlock %d, fromAddress %x, toAddress %x", prevBn, bn, from, to)
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
reqGen.reqID++
|
||||
request = reqGen.traceFilterAfter(prevBn, bn, 1)
|
||||
errCtx = fmt.Sprintf("traceFilterAfter fromBlock %d, toBlock %d, after %x", prevBn, bn, 1)
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
reqGen.reqID++
|
||||
request = reqGen.traceFilterCount(prevBn, bn, 1)
|
||||
errCtx = fmt.Sprintf("traceFilterCount fromBlock %d, toBlock %d, count %x", prevBn, bn, 1)
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
reqGen.reqID++
|
||||
request = reqGen.traceFilterCountAfter(prevBn, bn, 1, 1)
|
||||
errCtx = fmt.Sprintf("traceFilterCountAfter fromBlock %d, toBlock %d, count %x, after %x", prevBn, bn, 1, 1)
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_filter", errCtx, reqGen, needCompare, rec, errs, nil, false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -59,7 +59,8 @@ func BenchTraceReplayTransaction(erigonUrl, gethUrl string, needCompare bool, bl
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceReplayTransaction(tx.Hash)
|
||||
errCtx := fmt.Sprintf("block %d, tx %s", bn, tx.Hash)
|
||||
if err := requestAndCompare(request, "trace_replayTransaction", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "trace_replayTransaction", errCtx, reqGen, needCompare, rec, errs, nil,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ func BenchTraceBlockByHash(erigonUrl, gethUrl string, needCompare bool, blockFro
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceBlockByHash(b.Result.Hash.Hex())
|
||||
errCtx := fmt.Sprintf("block %d, tx %s", bn, b.Result.Hash.Hex())
|
||||
if err := requestAndCompare(request, "debug_traceBlockByHash", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "debug_traceBlockByHash", errCtx, reqGen, needCompare, rec, errs, nil,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
@ -116,7 +117,8 @@ func BenchTraceTransaction(erigonUrl, gethUrl string, needCompare bool, blockFro
|
||||
reqGen.reqID++
|
||||
request := reqGen.traceTransaction(tx.Hash)
|
||||
errCtx := fmt.Sprintf("block %d, tx %s", bn, tx.Hash)
|
||||
if err := requestAndCompare(request, "debug_traceTransaction", errCtx, reqGen, needCompare, rec, errs, nil); err != nil {
|
||||
if err := requestAndCompare(request, "debug_traceTransaction", errCtx, reqGen, needCompare, rec, errs, nil,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
@ -77,7 +77,8 @@ func BenchTxReceipt(erigonURL, gethURL string, needCompare bool, blockFrom uint6
|
||||
reqGen.reqID++
|
||||
request := reqGen.getTransactionReceipt(tx.Hash)
|
||||
errCtx := fmt.Sprintf("block %d, tx %s", bn, tx.Hash)
|
||||
if err := requestAndCompare(request, "eth_getTransactionReceipt", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil {
|
||||
if err := requestAndCompare(request, "eth_getTransactionReceipt", errCtx, reqGen, needCompare, rec, errs, resultsCh,
|
||||
/* insertOnlyIfSuccess */ false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ func compareErrors(errVal *fastjson.Value, errValg *fastjson.Value, methodName s
|
||||
return nil
|
||||
}
|
||||
|
||||
func requestAndCompare(request string, methodName string, errCtx string, reqGen *RequestGenerator, needCompare bool, rec *bufio.Writer, errs *bufio.Writer, channel chan CallResult) error {
|
||||
func requestAndCompare(request string, methodName string, errCtx string, reqGen *RequestGenerator, needCompare bool, rec *bufio.Writer, errs *bufio.Writer, channel chan CallResult, insertOnlyIfSuccess bool) error {
|
||||
recording := rec != nil
|
||||
res := reqGen.Erigon2(methodName, request)
|
||||
if res.Err != nil {
|
||||
@ -243,9 +243,6 @@ func requestAndCompare(request string, methodName string, errCtx string, reqGen
|
||||
return fmt.Errorf("error invoking %s (Erigon): %d %s", methodName, errVal.GetInt("code"), errVal.GetStringBytes("message"))
|
||||
}
|
||||
}
|
||||
if channel != nil {
|
||||
channel <- res
|
||||
}
|
||||
if needCompare {
|
||||
resg := reqGen.Geth2(methodName, request)
|
||||
if resg.Err != nil {
|
||||
@ -279,7 +276,14 @@ func requestAndCompare(request string, methodName string, errCtx string, reqGen
|
||||
} else {
|
||||
return compareErrors(errVal, errValg, methodName, errCtx, errs)
|
||||
}
|
||||
} else {
|
||||
if channel != nil {
|
||||
if insertOnlyIfSuccess == false || (insertOnlyIfSuccess && errVal == nil) {
|
||||
channel <- res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if recording {
|
||||
fmt.Fprintf(rec, "%s\n%s\n\n", request, res.Response)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user