go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

debug_traceCall returning inaccurate gasUsed when both blockOverrides and stateOverrides are used

Open Bitwise0x opened this issue 8 months ago • 11 comments

System information Geth 1.14.5 Go Version: go1.22.4

The gas returned from debug_traceCall with stateOverrides often resulting inaccuracy when trying to simulate for the next block. Over estimating in all the cases. Am I missing something?


``` ` // Adding 12 seconds to the current timestamp
nextBlockTime = header.Time + 12
tx := request{To: transaction.To().Hex(), From: from.Hex(), Value: fmt.Sprintf("0x%x", transaction.Value()), Gas: fmt.Sprintf("0x%x", transaction.Gas()), GasPrice: "0x" + transaction.GasFeeCap().Text(16),Data: hexutil.Encode(transaction.Data())}
	params := make(map[string]interface{})
	params[]"tracer"] = "callTracer"
	params["tracerConfig"] = tracerConfig{OnlyTopCall: true}
        params["blockOverrides"] = make(map[string]interface{})
	params["blockOverrides"].(map[string]interface{})["number"] = "0x" + nextBlock.Text(16)
	params["blockOverrides"].(map[string]interface{})["time"] = fmt.Sprintf("0x%x", nextBlockTime)
	if overrides != nil {
		params["stateOverrides"] = make(map[string]interface{})
		switch stateoverride := params["stateOverrides"].(type) {
		case map[string]interface{}:
			for key, value := range overrides {
				stateoveride[key] = make(map[string]interface{})
				switch statediff := stateoveride[key].(type) {
				case map[string]interface{}:
					statediff["stateDiff"] = make(map[string]string)
					statediff["stateDiff"] = value
				}
			}
		}
	}
gClient.Call(&result, "debug_traceCall", tx, "latest", params)``

Bitwise0x avatar Jun 14 '24 18:06 Bitwise0x