Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AElf.Tools detects proto in reference as internal causing 'inherited' services rpc accessibility mismatch #48

Open
zhifenglee-aelf opened this issue Jul 9, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@zhifenglee-aelf
Copy link
Collaborator

zhifenglee-aelf commented Jul 9, 2024

Description

Currently, protos in references have all their message as internal. This is an issue because services in protos can be 'inherited' and rpcs with message references will have accessibility mismatch issue (message being internal and rpc being public). The solution is placing the proto in the message folder. This is misleading since message that not say anything about the nature of the proto class.

Steps To Reproduce

  1. In contract/hello_world_contract.proto:
syntax = "proto3";

import "aelf/options.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "Protobuf/reference/acs12.proto";
import "Protobuf/reference/request_interface.proto";
// The namespace of this class
option csharp_namespace = "AElf.Contracts.VrfTest";

service VrfTest {
  // The name of the state class the smart contract is going to use to access blockchain state
  option (aelf.csharp_state) = "AElf.Contracts.VrfTest.VrfTestState";
  option (aelf.base) = "Protobuf/reference/acs12.proto";
  option (aelf.base) = "Protobuf/reference/request_interface.proto";
  
  // Actions (methods that modify contract state)
  // Stores the value in contract state
  rpc Update (google.protobuf.StringValue) returns (google.protobuf.Empty) {
  }

  // Views (methods that don't modify contract state)
  // Get the value stored from contract state
  rpc Read (google.protobuf.Empty) returns (google.protobuf.StringValue) {
    option (aelf.is_view) = true;
  }
}

// An event that will be emitted from contract method call
message UpdatedMessage {
  option (aelf.is_event) = true;
  string value = 1;
}
  1. In reference/request_interface.proto:
// the version of the language, use proto3 for contracts
syntax = "proto3";

// some core imports for AElf chain types
import "aelf/core.proto";
import "aelf/options.proto";
import "Protobuf/reference/acs12.proto";

package oracle;

// import for using the google.protobuf.* type.
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";

option (aelf.identity) = "request_interface";
// the name of the C# namespace in which the contract code will be,
// generated code will also be in this namespace.
option csharp_namespace = "AElf.Contracts.VrfTest";

// the contract definition: a gRPC service definition.
service RequestInterface {

  // the full name of the C# class that will contain the state (here <namespace>.<state-class-name> format).
  rpc StartOracleRequest(StartOracleRequestInput) returns (google.protobuf.Empty);
  rpc HandleOracleFulfillment(HandleOracleFulfillmentInput) returns (google.protobuf.Empty);
}

message StartOracleRequestInput {
  int64 subscription_id = 1;
  int32 request_type_index = 2;
  bytes specific_data = 3;
}

message HandleOracleFulfillmentInput {
  aelf.Hash request_id = 1;
  bytes response = 2;
  bytes err = 3;
  int32 request_type_index = 4;
}

message OracleResponse {
  bytes response = 1;
  bytes err = 2;
}

Current Behavior

  • Compile error

Expected Behavior

  • Compile successfully with contracts in reference used for 'inheritance' purposes. Rename message folder to base folder instead.

Environment

  • dotnet 7.0
  • AElf.Tools 1.0.2
@zhifenglee-aelf zhifenglee-aelf added the bug Something isn't working label Jul 9, 2024
@zhifenglee-aelf zhifenglee-aelf self-assigned this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant