Skip to content

Commit

Permalink
Merge pull request #22 from automata-network/dev-v0.4
Browse files Browse the repository at this point in the history
release v0.4
  • Loading branch information
chzyer authored Aug 19, 2024
2 parents 3a26ded + ce0ad26 commit 9048afc
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 55 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@
path = sgx-prover
url = https://github.com/automata-network/sgx-prover
branch = avs
[submodule "linea-sgx-prover"]
path = linea-sgx-prover
url = https://github.com/automata-network/linea-sgx-prover
106 changes: 62 additions & 44 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,45 @@ import (
"github.com/ethereum/go-ethereum/rpc"
)

type AttestationLayer struct {
Version int
Address common.Address
RpcUrl string
}

type AttestationLayerClient struct {
client *ethclient.Client
caller *TEELivenessVerifier.TEELivenessVerifierCaller
}

func (a *AttestationLayer) Build() (*AttestationLayerClient, error) {
client, err := ethclient.Dial(a.RpcUrl)
if err != nil {
return nil, logex.Trace(err, fmt.Sprintf("connecting to AttestationLayerRpcURL:%q", a.RpcUrl))
}
caller, err := TEELivenessVerifier.NewTEELivenessVerifierCaller(a.Address, client)
if err != nil {
return nil, logex.Trace(err, a.Address)
}
return &AttestationLayerClient{
client, caller,
}, nil
}

type Config struct {
ListenAddr string
TimeToExpirySecs int
MinWaitSecs int

EcdsaPrivateKey string
EthHttpEndpoint string
EthWsEndpoint string
AttestationLayerRpcURL string
MultiProverContractAddress common.Address
TEELivenessVerifierContractAddressV1 common.Address
TEELivenessVerifierContractAddress common.Address
EcdsaPrivateKey string
EthHttpEndpoint string
EthWsEndpoint string
// AttestationLayerRpcURL string
MultiProverContractAddress common.Address
// TEELivenessVerifierContractAddressV1 common.Address
// TEELivenessVerifierContractAddress common.Address

AttestationLayer []AttestationLayer

AVSRegistryCoordinatorAddress common.Address
OperatorStateRetrieverAddress common.Address
Expand Down Expand Up @@ -83,11 +110,13 @@ type Aggregator struct {

client *ethclient.Client

multiProverContract *MultiProverServiceManager.MultiProverServiceManager
TEELivenessVerifierV1 *TEELivenessVerifier.TEELivenessVerifierCaller
TEELivenessVerifierV2 *TEELivenessVerifier.TEELivenessVerifierCaller
registry *avsregistry.AvsRegistryServiceChainCaller
registryCoordinator *RegistryCoordinator.RegistryCoordinator
multiProverContract *MultiProverServiceManager.MultiProverServiceManager

attestationLayer []*AttestationLayerClient
// TEELivenessVerifierV1 *TEELivenessVerifier.TEELivenessVerifierCaller
// TEELivenessVerifierV2 *TEELivenessVerifier.TEELivenessVerifierCaller
registry *avsregistry.AvsRegistryServiceChainCaller
registryCoordinator *RegistryCoordinator.RegistryCoordinator

eigenClients *clients.Clients

Expand Down Expand Up @@ -119,10 +148,6 @@ func NewAggregator(ctx context.Context, cfg *Config) (*Aggregator, error) {
if err != nil {
return nil, logex.Trace(err, fmt.Sprintf("dial:%q", cfg.EthHttpEndpoint))
}
attestationClient, err := ethclient.Dial(cfg.AttestationLayerRpcURL)
if err != nil {
return nil, logex.Trace(err, fmt.Sprintf("connecting to AttestationLayerRpcURL:%q", cfg.AttestationLayerRpcURL))
}
chainId, err := client.ChainID(ctx)
if err != nil {
return nil, logex.Trace(err, "fetch chainID")
Expand Down Expand Up @@ -151,18 +176,6 @@ func NewAggregator(ctx context.Context, cfg *Config) (*Aggregator, error) {
if err != nil {
return nil, logex.Trace(err)
}
teeLivenessVerifier, err := TEELivenessVerifier.NewTEELivenessVerifierCaller(cfg.TEELivenessVerifierContractAddress, attestationClient)
if err != nil {
return nil, logex.Trace(err)
}
var teeLivenessVerifierV1 *TEELivenessVerifier.TEELivenessVerifierCaller
var emptyAddr common.Address
if cfg.TEELivenessVerifierContractAddressV1 != emptyAddr {
teeLivenessVerifierV1, err = TEELivenessVerifier.NewTEELivenessVerifierCaller(cfg.TEELivenessVerifierContractAddressV1, attestationClient)
if err != nil {
return nil, logex.Trace(err)
}
}

collector := xmetric.NewAggregatorCollector("avs")

Expand All @@ -184,21 +197,31 @@ func NewAggregator(ctx context.Context, cfg *Config) (*Aggregator, error) {
return nil, logex.Trace(err)
}

var attestationLayer []*AttestationLayerClient
for _, item := range cfg.AttestationLayer {
client, err := item.Build()
if err != nil {
return nil, logex.Trace(err)
}
attestationLayer = append(attestationLayer, client)
}

return &Aggregator{
cfg: cfg,
transactOpt: transactOpt,
client: client,
eigenClients: eigenClients,
blsAggregationService: blsAggregationService,
multiProverContract: multiProverContract,
TEELivenessVerifierV1: teeLivenessVerifierV1,
TEELivenessVerifierV2: teeLivenessVerifier,
registryCoordinator: registryCoordinator,
registry: avsRegistryService,
TaskManager: taskManager,
taskIndexMap: make(map[types.Bytes32]*Task),
Collector: collector,
registryCache: registryCache,
attestationLayer: attestationLayer,
// TEELivenessVerifierV1: teeLivenessVerifierV1,
// TEELivenessVerifierV2: teeLivenessVerifier,
registryCoordinator: registryCoordinator,
registry: avsRegistryService,
TaskManager: taskManager,
taskIndexMap: make(map[types.Bytes32]*Task),
Collector: collector,
registryCache: registryCache,
}, nil
}

Expand Down Expand Up @@ -241,21 +264,16 @@ func (agg *Aggregator) startUpdateOperators(ctx context.Context) (func() error,
}

func (agg *Aggregator) verifyKey(x [32]byte, y [32]byte) (bool, error) {
if agg.TEELivenessVerifierV1 != nil {
pass, err := agg.TEELivenessVerifierV1.VerifyLivenessProof(nil, x, y)
for _, layer := range agg.attestationLayer {
pass, err := layer.caller.VerifyLivenessProof(nil, x, y)
if err != nil {
return false, logex.Trace(err, "v1")
}
if pass {
return true, nil
}
}

pass, err := agg.TEELivenessVerifierV2.VerifyLivenessProof(nil, x, y)
if err != nil {
return false, logex.Trace(err, "v2")
}
return pass, nil
return false, nil
}

func (agg *Aggregator) startRpcServer(ctx context.Context) (func() error, error) {
Expand Down
9 changes: 9 additions & 0 deletions contracts/script/output/tee_deploy_output_automata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"AutomataDcapV3Attestation": "0x77311cA0051cA1c5A0d34104b55d9f1C7255f1de",
"PEMCertChainLib": "0x743207ecc2523052d1736825cAf44C7Ed7BEfcf5",
"ProxyAdmin": "0x4dbDC0E367AC7a7501561EDfba1f660Ce85B3C26",
"SigVerifyLib": "0x1335B98e130437C6e0fa347c790225B5A05FD30F",
"TEELivenessVerifierImpl": "0xAA914BA4B22A899fA3eb00BC28E1dEf868AA9f24",
"TEELivenessVerifierProxy": "0x2c674af4C9B6DE266E4515Be0E2A9C1c30452026",
"remark": "TEELivenessVerifier"
}
1 change: 0 additions & 1 deletion linea-sgx-prover
Submodule linea-sgx-prover deleted from 66f023
7 changes: 7 additions & 0 deletions operator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ type Config struct {

EthRpcUrl string

AttestationLayerProfile string
AttestationLayerEcdsaKey string
AttestationLayerRpcURL string

Expand All @@ -151,6 +152,12 @@ func (c *Config) InitFromEnv() {
if c.OperatorStateRetrieverAddress == utils.ZeroAddress {
c.OperatorStateRetrieverAddress = preset.OperatorStateRetrieverAddress
}

cfg := preset.GetAttestationLayer(c.AttestationLayerProfile)
c.TEELivenessVerifierAddress = cfg.Address
if cfg.URL != "" {
c.AttestationLayerRpcURL = cfg.URL
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion sgx-prover
Submodule sgx-prover updated 190 files
57 changes: 51 additions & 6 deletions utils/params.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,76 @@
package utils

import "github.com/ethereum/go-ethereum/common"
import (
"github.com/chzyer/logex"
"github.com/ethereum/go-ethereum/common"
)

const ATT_AUTOMATA = "automata"
const ATT_AUTOMATA_TEST = "automata_test"
const ATT_OPTIMISM = "optimism"
const ATT_HOLESKY = "holesky"

type PresetConfig struct {
RegistryCoordinatorAddress common.Address
OperatorStateRetrieverAddress common.Address
TEELivenessVerifierAddress common.Address
LineaProverURL string
ScrollProverURL string
// TEELivenessVerifierAddress common.Address
DefaultAttestationLayer string
AttestationLayer map[string]*PresetAttestationConfig
LineaProverURL string
ScrollProverURL string
}

func (p *PresetConfig) GetAttestationLayer(profile string) *PresetAttestationConfig {
if profile == "" {
profile = p.DefaultAttestationLayer
}
cfg, ok := p.AttestationLayer[profile]
if !ok {
logex.Fatal("unknown Attestation Layer Profile: %q", profile)
}
return cfg
}

type PresetAttestationConfig struct {
Address common.Address
URL string
}

var PresetConfigs = []*PresetConfig{HoleskyTestnetPreset, MainnetPreset}

var HoleskyTestnetPreset = &PresetConfig{
RegistryCoordinatorAddress: common.HexToAddress("0x62c715575cE3Ad7C5a43aA325b881c70564f2215"),
OperatorStateRetrieverAddress: common.HexToAddress("0xbfd43ac0a19c843e44491c3207ea13914818E214"),
TEELivenessVerifierAddress: common.HexToAddress("0x2E8628F6000Ef85dea615af6Da4Fd6dF4fD149e6"),
LineaProverURL: "https://avs-prover-staging.ata.network",
ScrollProverURL: "https://avs-prover-staging.ata.network",
DefaultAttestationLayer: ATT_HOLESKY,
AttestationLayer: map[string]*PresetAttestationConfig{
ATT_HOLESKY: {
Address: common.HexToAddress("0x2E8628F6000Ef85dea615af6Da4Fd6dF4fD149e6"),
},
ATT_AUTOMATA_TEST: {
URL: "https://rpc.ata.network",
Address: common.HexToAddress("0x2c674af4C9B6DE266E4515Be0E2A9C1c30452026"),
},
},
}

var MainnetPreset = &PresetConfig{
RegistryCoordinatorAddress: common.HexToAddress("0x414696E4F7f06273973E89bfD3499e8666D63Bd4"),
OperatorStateRetrieverAddress: common.HexToAddress("0x91246253d3Bff9Ae19065A90dC3AB6e09EefD2B6"),
TEELivenessVerifierAddress: common.HexToAddress("0x99886d5C39c0DF3B0EAB67FcBb4CA230EF373510"),
LineaProverURL: "https://avs-prover-mainnet1.ata.network:18232",
ScrollProverURL: "https://avs-prover-mainnet1.ata.network:18232",
DefaultAttestationLayer: ATT_OPTIMISM,
AttestationLayer: map[string]*PresetAttestationConfig{
ATT_OPTIMISM: {
URL: "",
Address: common.HexToAddress("0x99886d5C39c0DF3B0EAB67FcBb4CA230EF373510"),
},
ATT_AUTOMATA: {
URL: "https://rpc.ata.network",
Address: common.HexToAddress("0x2c674af4C9B6DE266E4515Be0E2A9C1c30452026"),
},
},
}

func PresetConfigByRegistryCoordinatorAddress(registryCoordinatorAddress common.Address) *PresetConfig {
Expand Down

0 comments on commit 9048afc

Please sign in to comment.