Skip to content

Commit

Permalink
add rpc configs (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT authored Apr 8, 2024
1 parent dc05876 commit 8c9856a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 4 additions & 2 deletions aggregator/rpc/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
}
}

Expand Down
6 changes: 5 additions & 1 deletion config-files/aggregator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ 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

# the layer2 chain id
layer2_chain_id: 0

# the QuorumNums we use, just no change
quorum_nums: [0]
quorum_nums: [0]

6 changes: 6 additions & 0 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8c9856a

Please sign in to comment.