From 8c9856aab31684f6dceb7d89236180434f221c2d Mon Sep 17 00:00:00 2001 From: fyInALT <97101459+fyInALT@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:54:18 +0800 Subject: [PATCH] add rpc configs (#112) --- aggregator/aggregator.go | 2 +- aggregator/rpc/jsonrpc.go | 6 ++++-- config-files/aggregator.yaml | 6 +++++- core/config/config.go | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index ad4a95f..6b4ea4c 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -116,7 +116,7 @@ func NewAggregator(c *config.Config) (*Aggregator, error) { var jsonrpcServer *rpc.JsonRpcServer if c.AggregatorJSONRPCServerIpPortAddr != "" { c.Logger.Infof("Create json rpc server in %s", c.AggregatorJSONRPCServerIpPortAddr) - jsonrpcServer = rpc.NewJsonRpcServer(c.Logger, service) + jsonrpcServer = rpc.NewJsonRpcServer(c.Logger, service, c.RpcVhosts, c.RpcCors) } return &Aggregator{ diff --git a/aggregator/rpc/jsonrpc.go b/aggregator/rpc/jsonrpc.go index cd04aa8..08775bb 100644 --- a/aggregator/rpc/jsonrpc.go +++ b/aggregator/rpc/jsonrpc.go @@ -21,14 +21,16 @@ type JsonRpcServer struct { wg *sync.WaitGroup } -func NewJsonRpcServer(logger logging.Logger, aggreagtor AggregatorRpcHandler) *JsonRpcServer { +func NewJsonRpcServer(logger logging.Logger, aggreagtor AggregatorRpcHandler, vhosts []string, cors []string) *JsonRpcServer { return &JsonRpcServer{ logger: logger, handler: JsonRpcHandler{ logger: logger, aggreagtor: aggreagtor, }, - wg: &sync.WaitGroup{}, + vhosts: vhosts, + cors: cors, + wg: &sync.WaitGroup{}, } } diff --git a/config-files/aggregator.yaml b/config-files/aggregator.yaml index 5ddb1bd..f8f3f29 100644 --- a/config-files/aggregator.yaml +++ b/config-files/aggregator.yaml @@ -12,6 +12,9 @@ aggregator_grpc_server_ip_port_address: localhost:8190 # address which the aggregator json rpc listens on for operator signed messages aggregator_jsonrpc_server_ip_port_address: localhost:8290 +rpc_vhosts: ["*", "localhost"] +rpc_cors: ["*", "localhost"] + # the layer1 chain id the avs contracts in layer1_chain_id: 31337 @@ -19,4 +22,5 @@ layer1_chain_id: 31337 layer2_chain_id: 0 # the QuorumNums we use, just no change -quorum_nums: [0] \ No newline at end of file +quorum_nums: [0] + diff --git a/core/config/config.go b/core/config/config.go index 235f307..50a012d 100644 --- a/core/config/config.go +++ b/core/config/config.go @@ -42,6 +42,8 @@ type Config struct { AggregatorJSONRPCServerIpPortAddr string Layer1ChainId uint32 Layer2ChainId uint32 + RpcVhosts []string + RpcCors []string QuorumNums types.QuorumNums // json:"-" skips this field when marshaling (only used for logging to stdout), since SignerFn doesnt implement marshalJson SignerFn signerv2.SignerFn `json:"-"` @@ -61,6 +63,8 @@ type ConfigRaw struct { Layer1ChainId uint32 `yaml:"layer1_chain_id"` Layer2ChainId uint32 `yaml:"layer2_chain_id"` QuorumNums []uint8 `yaml:"quorum_nums"` + RpcVhosts []string `yaml:"rpc_vhosts"` + RpcCors []string `yaml:"rpc_cors"` } // These are read from DeploymentFileFlag @@ -225,6 +229,8 @@ func NewConfig(ctx *cli.Context) (*Config, error) { Layer1ChainId: configRaw.Layer1ChainId, Layer2ChainId: configRaw.Layer2ChainId, QuorumNums: quorumNums, + RpcVhosts: configRaw.RpcVhosts, + RpcCors: configRaw.RpcCors, } config.validate() return config, nil