Skip to content

Commit

Permalink
support a ext work proof commit interval
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT committed Jun 11, 2024
1 parent 3742267 commit 0dbeab4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
1 change: 1 addition & 0 deletions generic-operator-proxy/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func operatorProxyMain(ctx *cli.Context) error {
nodeConfig.GenericOperatorAddr,
nodeConfig.RpcCfg,
nodeConfig.ChainIds,
nodeConfig.WorkProofsBlockNumMod,
)

return rpcServer.Start(mainCtx)
Expand Down
3 changes: 2 additions & 1 deletion generic-operator-proxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
44 changes: 31 additions & 13 deletions generic-operator-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0dbeab4

Please sign in to comment.