@@ -372,6 +372,66 @@ func (b *Backend) DoCall(
372372 return res , nil
373373}
374374
375+ func (b * Backend ) DoTacSimulate (
376+ args evmtypes.TransactionArgs ,
377+ blockNr rpctypes.BlockNumber ,
378+ stateOverride evmtypes.StateOverride ,
379+ ) (* evmtypes.TacSimulateResponse , error ) {
380+ bz , err := json .Marshal (& args )
381+ if err != nil {
382+ return nil , err
383+ }
384+
385+ header , err := b .TendermintBlockByNumber (blockNr )
386+ if err != nil {
387+ // the error message imitates geth behavior
388+ return nil , errors .New ("header not found" )
389+ }
390+
391+ overrideBz , err := json .Marshal (stateOverride )
392+ if err != nil {
393+ return nil , err
394+ }
395+
396+ req := evmtypes.TacSimulateRequest {
397+ Args : bz ,
398+ GasCap : b .RPCGasCap (),
399+ ProposerAddress : sdk .ConsAddress (header .Block .ProposerAddress ),
400+ ChainId : b .chainID .Int64 (),
401+ StateOverride : overrideBz ,
402+ }
403+
404+ // From ContextWithHeight: if the provided height is 0,
405+ // it will return an empty context and the gRPC query will use
406+ // the latest block height for querying.
407+ ctx := rpctypes .ContextWithHeight (blockNr .Int64 ())
408+ timeout := b .RPCEVMTimeout ()
409+
410+ // Setup context so it may be canceled the call has completed
411+ // or, in case of unmetered gas, setup a context with a timeout.
412+ var cancel context.CancelFunc
413+ if timeout > 0 {
414+ ctx , cancel = context .WithTimeout (ctx , timeout )
415+ } else {
416+ ctx , cancel = context .WithCancel (ctx )
417+ }
418+
419+ // Make sure the context is canceled when the call has completed
420+ // this makes sure resources are cleaned up.
421+ defer cancel ()
422+
423+ res , err := b .queryClient .TacSimulate (ctx , & req )
424+ if err != nil {
425+ return nil , err
426+ }
427+
428+ if err = handleRevertError (res .VmError , res .Ret ); err != nil {
429+ return nil , err
430+ }
431+
432+ return res , nil
433+ }
434+
375435// GasPrice returns the current gas price based on Cosmos EVM' gas price oracle.
376436func (b * Backend ) GasPrice () (* hexutil.Big , error ) {
377437 var (
0 commit comments