diff --git a/generic-operator-proxy/cmd/main.go b/generic-operator-proxy/cmd/main.go index aa96485..7b7dd3d 100644 --- a/generic-operator-proxy/cmd/main.go +++ b/generic-operator-proxy/cmd/main.go @@ -76,6 +76,7 @@ func operatorProxyMain(ctx *cli.Context) error { nodeConfig.GenericOperatorAddr, nodeConfig.RpcCfg, nodeConfig.ChainIds, + nodeConfig.WorkProofsBlockNumMod, ) return rpcServer.Start(mainCtx) diff --git a/generic-operator-proxy/config.go b/generic-operator-proxy/config.go index 6b5c8c1..f9684ca 100644 --- a/generic-operator-proxy/config.go +++ b/generic-operator-proxy/config.go @@ -5,5 +5,6 @@ import proxyUtils "github.com/alt-research/avs-generic-aggregator/proxy/utils" type MachProxyConfig struct { proxyUtils.ProxyConfig - ChainIds map[string]uint32 `yaml:"chain_ids"` + ChainIds map[string]uint32 `yaml:"chain_ids"` + WorkProofsBlockNumMod map[string]uint32 `yaml:"work_proofs_mod"` } diff --git a/generic-operator-proxy/proxy.go b/generic-operator-proxy/proxy.go index d8ee2e9..1d59ec9 100644 --- a/generic-operator-proxy/proxy.go +++ b/generic-operator-proxy/proxy.go @@ -23,11 +23,12 @@ import ( ) type ProxyHashRpcServer struct { - baseServers map[string]*proxyUtils.ProxyRpcServerBase - avsCfgs map[string]config.GenericAVSConfig - chainIds map[string]uint32 - defaultAVSName string - logger logging.Logger + baseServers map[string]*proxyUtils.ProxyRpcServerBase + avsCfgs map[string]config.GenericAVSConfig + chainIds map[string]uint32 + workProofsBlockNumMod map[string]uint32 + defaultAVSName string + logger logging.Logger // We use this rpc server as the handler for jsonrpc // to make sure same as legacy operator 's api rpcServer operator.RpcServer @@ -46,6 +47,7 @@ func NewAlertProxyRpcServer( genericOperatorAddr string, jsonrpcCfg config.JsonRpcServerConfig, chainIds map[string]uint32, + workProofsBlockNumMod map[string]uint32, ) *ProxyHashRpcServer { bases := make(map[string]*proxyUtils.ProxyRpcServerBase, len(avsCfgs)) avsCfgsMap := make(map[string]config.GenericAVSConfig, len(avsCfgs)) @@ -68,14 +70,15 @@ func NewAlertProxyRpcServer( rpcServer := operator.NewRpcServer(logger, jsonrpcCfg.Addr, newTaskCreatedChan, newWorkProofChan) server := &ProxyHashRpcServer{ - baseServers: bases, - logger: logger, - defaultAVSName: defaultAVSName, - newTaskCreatedChan: newTaskCreatedChan, - newWorkProofChan: newWorkProofChan, - rpcServer: rpcServer, - avsCfgs: avsCfgsMap, - chainIds: chainIds, + baseServers: bases, + logger: logger, + defaultAVSName: defaultAVSName, + newTaskCreatedChan: newTaskCreatedChan, + newWorkProofChan: newWorkProofChan, + rpcServer: rpcServer, + avsCfgs: avsCfgsMap, + chainIds: chainIds, + workProofsBlockNumMod: workProofsBlockNumMod, } // not need do this because we not need use this server impl @@ -314,6 +317,21 @@ func (s *ProxyHashRpcServer) commitWorkProof(ctx context.Context, avsName string return errors.Errorf("not found chain id for avs name %v", avsNameToProxy) } + blockNumMod, ok := s.workProofsBlockNumMod[avsNameToProxy] + if ok { + if index > blockNumMod { + i := index % blockNumMod + if i != 0 { + s.logger.Info( + "work proof not need commit", + "avsName", avsName, "index", index, + "inc", i, + "next", index-i+blockNumMod) + return nil + } + } + } + baseServer, ok := s.baseServers[avsNameToProxy] if !ok || baseServer == nil { return errors.Errorf("not found avs name %v", avsNameToProxy)