mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
ethclient: add maxUsedGas to simulate call results
This commit is contained in:
parent
8091994e7b
commit
a740a1f716
3 changed files with 14 additions and 0 deletions
|
|
@ -914,6 +914,7 @@ type SimulateCallResult struct {
|
||||||
ReturnValue []byte `json:"returnData"`
|
ReturnValue []byte `json:"returnData"`
|
||||||
Logs []*types.Log `json:"logs"`
|
Logs []*types.Log `json:"logs"`
|
||||||
GasUsed uint64 `json:"gasUsed"`
|
GasUsed uint64 `json:"gasUsed"`
|
||||||
|
MaxUsedGas uint64 `json:"maxUsedGas"`
|
||||||
Status uint64 `json:"status"`
|
Status uint64 `json:"status"`
|
||||||
Error *CallError `json:"error,omitempty"`
|
Error *CallError `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
@ -921,6 +922,7 @@ type SimulateCallResult struct {
|
||||||
type simulateCallResultMarshaling struct {
|
type simulateCallResultMarshaling struct {
|
||||||
ReturnValue hexutil.Bytes
|
ReturnValue hexutil.Bytes
|
||||||
GasUsed hexutil.Uint64
|
GasUsed hexutil.Uint64
|
||||||
|
MaxUsedGas hexutil.Uint64
|
||||||
Status hexutil.Uint64
|
Status hexutil.Uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -861,6 +861,12 @@ func TestSimulateV1(t *testing.T) {
|
||||||
if results[0].Calls[0].Error != nil {
|
if results[0].Calls[0].Error != nil {
|
||||||
t.Errorf("expected no error, got %v", results[0].Calls[0].Error)
|
t.Errorf("expected no error, got %v", results[0].Calls[0].Error)
|
||||||
}
|
}
|
||||||
|
if results[0].Calls[0].MaxUsedGas == 0 {
|
||||||
|
t.Error("expected maxUsedGas to be set")
|
||||||
|
}
|
||||||
|
if results[0].Calls[0].MaxUsedGas < results[0].Calls[0].GasUsed {
|
||||||
|
t.Errorf("expected maxUsedGas >= gasUsed, got %d < %d", results[0].Calls[0].MaxUsedGas, results[0].Calls[0].GasUsed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulateV1WithBlockOverrides(t *testing.T) {
|
func TestSimulateV1WithBlockOverrides(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ func (s SimulateCallResult) MarshalJSON() ([]byte, error) {
|
||||||
ReturnValue hexutil.Bytes `json:"returnData"`
|
ReturnValue hexutil.Bytes `json:"returnData"`
|
||||||
Logs []*types.Log `json:"logs"`
|
Logs []*types.Log `json:"logs"`
|
||||||
GasUsed hexutil.Uint64 `json:"gasUsed"`
|
GasUsed hexutil.Uint64 `json:"gasUsed"`
|
||||||
|
MaxUsedGas hexutil.Uint64 `json:"maxUsedGas"`
|
||||||
Status hexutil.Uint64 `json:"status"`
|
Status hexutil.Uint64 `json:"status"`
|
||||||
Error *CallError `json:"error,omitempty"`
|
Error *CallError `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
@ -24,6 +25,7 @@ func (s SimulateCallResult) MarshalJSON() ([]byte, error) {
|
||||||
enc.ReturnValue = s.ReturnValue
|
enc.ReturnValue = s.ReturnValue
|
||||||
enc.Logs = s.Logs
|
enc.Logs = s.Logs
|
||||||
enc.GasUsed = hexutil.Uint64(s.GasUsed)
|
enc.GasUsed = hexutil.Uint64(s.GasUsed)
|
||||||
|
enc.MaxUsedGas = hexutil.Uint64(s.MaxUsedGas)
|
||||||
enc.Status = hexutil.Uint64(s.Status)
|
enc.Status = hexutil.Uint64(s.Status)
|
||||||
enc.Error = s.Error
|
enc.Error = s.Error
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
|
|
@ -35,6 +37,7 @@ func (s *SimulateCallResult) UnmarshalJSON(input []byte) error {
|
||||||
ReturnValue *hexutil.Bytes `json:"returnData"`
|
ReturnValue *hexutil.Bytes `json:"returnData"`
|
||||||
Logs []*types.Log `json:"logs"`
|
Logs []*types.Log `json:"logs"`
|
||||||
GasUsed *hexutil.Uint64 `json:"gasUsed"`
|
GasUsed *hexutil.Uint64 `json:"gasUsed"`
|
||||||
|
MaxUsedGas *hexutil.Uint64 `json:"maxUsedGas"`
|
||||||
Status *hexutil.Uint64 `json:"status"`
|
Status *hexutil.Uint64 `json:"status"`
|
||||||
Error *CallError `json:"error,omitempty"`
|
Error *CallError `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +54,9 @@ func (s *SimulateCallResult) UnmarshalJSON(input []byte) error {
|
||||||
if dec.GasUsed != nil {
|
if dec.GasUsed != nil {
|
||||||
s.GasUsed = uint64(*dec.GasUsed)
|
s.GasUsed = uint64(*dec.GasUsed)
|
||||||
}
|
}
|
||||||
|
if dec.MaxUsedGas != nil {
|
||||||
|
s.MaxUsedGas = uint64(*dec.MaxUsedGas)
|
||||||
|
}
|
||||||
if dec.Status != nil {
|
if dec.Status != nil {
|
||||||
s.Status = uint64(*dec.Status)
|
s.Status = uint64(*dec.Status)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue