Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ctxc/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ func (b *CortexAPIBackend) GetTd(ctx context.Context, blockHash common.Hash) *bi
return b.ctxc.blockchain.GetTdByHash(blockHash)
}

func (b *CortexAPIBackend) GetCVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.CVM, func() error) {
func (b *CortexAPIBackend) GetCVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) *vm.CVM {

txContext := core.NewCVMTxContext(msg)
context := core.NewCVMBlockContext(header, b.ctxc.BlockChain(), nil)
return vm.NewCVM(context, txContext, state, b.ctxc.chainConfig, vmCfg), state.Error
return vm.NewCVM(context, txContext, state, b.ctxc.chainConfig, vmCfg)
}

func (b *CortexAPIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
Expand Down
6 changes: 3 additions & 3 deletions internal/ctxcapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func (s *PublicBlockChainAPI) GetSolidityBytes(ctx context.Context, address comm
}
header := block.Header()
msg, err := core.TransactionToMessage(tx, types.MakeSigner(s.b.ChainConfig(), block.Number(), block.Time()))
cvm, _ := s.b.GetCVM(ctx, msg, state, header, vm.Config{})
cvm := s.b.GetCVM(ctx, msg, state, header, vm.Config{})
_, _, _, failed, err := core.ApplyMessage(cvm, msg, gp, qp)
if err != nil || failed {
return nil, err
Expand Down Expand Up @@ -899,7 +899,7 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr

// Get a new instance of the CVM.
vmCfg.CallFakeVM = true
cvm, vmError := s.b.GetCVM(ctx, msg, state, header, vmCfg)
cvm := s.b.GetCVM(ctx, msg, state, header, vmCfg)
// Wait for the context to be done and cancel the cvm. Even if the
// CVM has finished, cancelling may be done (repeatedly)
go func() {
Expand All @@ -912,7 +912,7 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
gp := new(core.GasPool).AddGas(math.MaxUint64)
qp := new(core.QuotaPool).AddQuota(math.MaxUint64)
res, gas, _, failed, err := core.ApplyMessage(cvm, msg, gp, qp)
if err := vmError(); err != nil {
if err := state.Error(); err != nil {
return nil, 0, false, err
}

Expand Down
2 changes: 1 addition & 1 deletion internal/ctxcapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Backend interface {
GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error)
GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
GetTd(ctx context.Context, blockHash common.Hash) *big.Int
GetCVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.CVM, func() error)
GetCVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) *vm.CVM
SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
Expand Down