Skip to content

Commit

Permalink
Merge pull request #159 from orbs-network/feature/committee-from-elec…
Browse files Browse the repository at this point in the history
…tion

Added CallSystemContract RPC to virtual machine
  • Loading branch information
netoneko authored May 29, 2019
2 parents 533bbc3 + c6ba7da commit 51256a0
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
14 changes: 14 additions & 0 deletions interfaces/services/virtual_machine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ service VirtualMachine {

// called by ConsensusContext
rpc ProcessTransactionSet (ProcessTransactionSetInput) returns (ProcessTransactionSetOutput); // Transactions Streaming
rpc CallSystemContract (CallSystemContractInput) returns (CallSystemContractOutput);

// called by PublicApi
rpc ProcessQuery (ProcessQueryInput) returns (ProcessQueryOutput);
Expand Down Expand Up @@ -59,4 +60,17 @@ message TransactionSetPreOrderInput {
// returns error string if one of the transactions does not pass pre order checks
message TransactionSetPreOrderOutput {
repeated protocol.TransactionStatus pre_order_results = 1;
}

message CallSystemContractInput {
primitives.block_height block_height = 1;
primitives.timestamp_nano block_timestamp = 2;
primitives.contract_name contract_name = 3;
primitives.method_name method_name = 4;
protocol.ArgumentArray input_argument_array = 5;
}

message CallSystemContractOutput {
protocol.ArgumentArray output_argument_array = 1;
protocol.ExecutionResult call_result = 2;
}
69 changes: 69 additions & 0 deletions types/go/services/virtual_machine.mb.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type VirtualMachine interface {
handlers.ContractSdkCallHandler
ProcessTransactionSet(ctx context.Context, input *ProcessTransactionSetInput) (*ProcessTransactionSetOutput, error)
CallSystemContract(ctx context.Context, input *CallSystemContractInput) (*CallSystemContractOutput, error)
ProcessQuery(ctx context.Context, input *ProcessQueryInput) (*ProcessQueryOutput, error)
TransactionSetPreOrder(ctx context.Context, input *TransactionSetPreOrderInput) (*TransactionSetPreOrderOutput, error)
}
Expand Down Expand Up @@ -213,5 +214,73 @@ func (x *TransactionSetPreOrderOutput) StringPreOrderResults() (res string) {
return
}

/////////////////////////////////////////////////////////////////////////////
// message CallSystemContractInput (non serializable)

type CallSystemContractInput struct {
BlockHeight primitives.BlockHeight
BlockTimestamp primitives.TimestampNano
ContractName primitives.ContractName
MethodName primitives.MethodName
InputArgumentArray *protocol.ArgumentArray
}

func (x *CallSystemContractInput) String() string {
if x == nil {
return "<nil>"
}
return fmt.Sprintf("{BlockHeight:%s,BlockTimestamp:%s,ContractName:%s,MethodName:%s,InputArgumentArray:%s,}", x.StringBlockHeight(), x.StringBlockTimestamp(), x.StringContractName(), x.StringMethodName(), x.StringInputArgumentArray())
}

func (x *CallSystemContractInput) StringBlockHeight() (res string) {
res = fmt.Sprintf("%s", x.BlockHeight)
return
}

func (x *CallSystemContractInput) StringBlockTimestamp() (res string) {
res = fmt.Sprintf("%s", x.BlockTimestamp)
return
}

func (x *CallSystemContractInput) StringContractName() (res string) {
res = fmt.Sprintf("%s", x.ContractName)
return
}

func (x *CallSystemContractInput) StringMethodName() (res string) {
res = fmt.Sprintf("%s", x.MethodName)
return
}

func (x *CallSystemContractInput) StringInputArgumentArray() (res string) {
res = x.InputArgumentArray.String()
return
}

/////////////////////////////////////////////////////////////////////////////
// message CallSystemContractOutput (non serializable)

type CallSystemContractOutput struct {
OutputArgumentArray *protocol.ArgumentArray
CallResult protocol.ExecutionResult
}

func (x *CallSystemContractOutput) String() string {
if x == nil {
return "<nil>"
}
return fmt.Sprintf("{OutputArgumentArray:%s,CallResult:%s,}", x.StringOutputArgumentArray(), x.StringCallResult())
}

func (x *CallSystemContractOutput) StringOutputArgumentArray() (res string) {
res = x.OutputArgumentArray.String()
return
}

func (x *CallSystemContractOutput) StringCallResult() (res string) {
res = fmt.Sprintf("%x", x.CallResult)
return
}

/////////////////////////////////////////////////////////////////////////////
// enums
9 changes: 9 additions & 0 deletions types/go/services/virtual_machine_mock.mb.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ func (s *MockVirtualMachine) ProcessTransactionSet(ctx context.Context, input *P
}
}

func (s *MockVirtualMachine) CallSystemContract(ctx context.Context, input *CallSystemContractInput) (*CallSystemContractOutput, error) {
ret := s.Called(ctx, input)
if out := ret.Get(0); out != nil {
return out.(*CallSystemContractOutput), ret.Error(1)
} else {
return nil, ret.Error(1)
}
}

func (s *MockVirtualMachine) ProcessQuery(ctx context.Context, input *ProcessQueryInput) (*ProcessQueryOutput, error) {
ret := s.Called(ctx, input)
if out := ret.Get(0); out != nil {
Expand Down

0 comments on commit 51256a0

Please sign in to comment.