Skip to content

Commit

Permalink
renaming and fixing integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
diyahir committed Aug 15, 2024
1 parent fc49019 commit 8481d45
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 38 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ send-fund: ## sends fund to the operator saved in tests/keys/test.ecdsa.key.json
____OFFCHAIN_SOFTWARE___: ##
start-aggregator: ##
go run aggregator/cmd/main.go --config config-files/anvil/aggregator.yaml \
--credible-squaring-deployment ${DEPLOYMENT_FILES_DIR}/anzen_avs_deployment_output.json \
--anzen-deployment ${DEPLOYMENT_FILES_DIR}/anzen_avs_deployment_output.json \
--ecdsa-private-key ${AGGREGATOR_ECDSA_PRIV_KEY} \
2>&1 | zap-pretty

start-aggregator-holesky:
go run aggregator/cmd/main.go --config config-files/holesky/aggregator.yaml \
--credible-squaring-deployment ${HOLESKY_FILES_DIR}/holesky_anzen_avs_deployment_output.json \
--anzen-deployment ${HOLESKY_FILES_DIR}/holesky_anzen_avs_deployment_output.json \
--ecdsa-private-key ${AGGREGATOR_ECDSA_PRIV_KEY} \
2>&1 | zap-pretty

Expand All @@ -103,7 +103,7 @@ start-operator-3: ##

start-challenger: ##
go run challenger/cmd/main.go --config config-files/anvil/challenger.yaml \
--credible-squaring-deployment ${DEPLOYMENT_FILES_DIR}/anzen_avs_deployment_output.json \
--anzen-deployment ${DEPLOYMENT_FILES_DIR}/anzen_avs_deployment_output.json \
--ecdsa-private-key ${CHALLENGER_ECDSA_PRIV_KEY} \
2>&1 | zap-pretty

Expand All @@ -125,3 +125,5 @@ tests-contract: ## runs all forge tests
tests-integration: ## runs all integration tests
go test ./tests/integration/... -v -count=1

tests-all: tests-unit tests-contract tests-integration ## runs all tests

5 changes: 3 additions & 2 deletions aggregator/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (

// all operators in quorum0 must sign the task response in order for it to be accepted
// TODO: our contracts require uint8 but right now sdktypes.QuorumThresholdPercentage is uint8
// prob need to update our inc-sq contracts to use uint8 as well?
//
// prob need to update our inc-sq contracts to use uint8 as well?
const QUORUM_THRESHOLD_NUMERATOR = sdktypes.QuorumThresholdPercentage(100)
const QUORUM_THRESHOLD_DENOMINATOR = sdktypes.QuorumThresholdPercentage(100)

const QUERY_FILTER_FROM_BLOCK = uint64(1)

// we only use a single quorum (quorum 0) for incredible squaring
// we only use a single quorum (quorum 0) for anzen
var QUORUM_NUMBERS = sdktypes.QuorumNums{0}

type BlockNumber = uint32
Expand Down
4 changes: 2 additions & 2 deletions challenger/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func main() {
app := cli.NewApp()
app.Flags = config.Flags
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate)
app.Name = "credible-squaring-challenger"
app.Usage = "Credible Squaring Challenger"
app.Name = "anzen-challenger"
app.Usage = "Anzen Challenger"
app.Description = "Service that challenges wrong response to the task."

app.Action = challengerMain
Expand Down
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
{
Name: "print-operator-status",
Aliases: []string{"s"},
Usage: "prints operator status as viewed from incredible squaring contracts",
Usage: "prints operator status as viewed from anzen contracts",
Action: actions.PrintOperatorStatus,
},
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/script/AnzenDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract AnzenDeployer is Script, Utils {
ERC20Mock public erc20Mock;
StrategyBaseTVLLimits public erc20MockStrategy;

// Credible Squaring contracts
// anzen contracts
ProxyAdmin public anzenProxyAdmin;
PauserRegistry public anzenPauserReg;

Expand Down
2 changes: 1 addition & 1 deletion contracts/script/HoleskyAnzenDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract AnzenDeployer is Script, Utils {
// ERC20 and Strategy: we need to deploy this erc20, create a strategy for it, and whitelist this strategy in the strategymanager
StrategyBaseTVLLimits public erc20Strategy;

// Credible Squaring contracts
// anzen contracts
ProxyAdmin public anzenProxyAdmin;
PauserRegistry public anzenPauserReg;

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/AnzenServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "@eigenlayer-middleware/src/ServiceManagerBase.sol";
import "./AnzenTaskManager.sol";

/**
* @title Primary entrypoint for procuring services from IncredibleSquaring.
* @title Primary entrypoint for procuring services from Anzen.
* @author Layr Labs, Inc.
*/
contract AnzenServiceManager is ServiceManagerBase {
Expand Down
36 changes: 18 additions & 18 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
sdkutils "github.com/Layr-Labs/eigensdk-go/utils"
)

// Config contains all of the configuration information for a credible squaring aggregators and challengers.
// Config contains all of the configuration information for an anzen aggregators and challengers.
// Operators use a separate config. (see config-files/anvil/operator.yaml)
type Config struct {
EcdsaPrivateKey *ecdsa.PrivateKey
Expand Down Expand Up @@ -53,11 +53,11 @@ type ConfigRaw struct {
RegisterOperatorOnStartup bool `yaml:"register_operator_on_startup"`
}

// These are read from CredibleSquaringDeploymentFileFlag
type IncredibleSquaringDeploymentRaw struct {
Addresses IncredibleSquaringContractsRaw `json:"addresses"`
// These are read from AnzenDeploymentFileFlag
type AnzenDeploymentRaw struct {
Addresses AnzenContractsRaw `json:"addresses"`
}
type IncredibleSquaringContractsRaw struct {
type AnzenContractsRaw struct {
RegistryCoordinatorAddr string `json:"registryCoordinator"`
OperatorStateRetrieverAddr string `json:"operatorStateRetriever"`
SafetyFactorOracleAddr string `json:"safetyFactorOracle"`
Expand All @@ -74,12 +74,12 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
sdkutils.ReadYamlConfig(configFilePath, &configRaw)
}

var credibleSquaringDeploymentRaw IncredibleSquaringDeploymentRaw
credibleSquaringDeploymentFilePath := ctx.GlobalString(CredibleSquaringDeploymentFileFlag.Name)
if _, err := os.Stat(credibleSquaringDeploymentFilePath); errors.Is(err, os.ErrNotExist) {
panic("Path " + credibleSquaringDeploymentFilePath + " does not exist")
var anzenDeploymentRaw AnzenDeploymentRaw
anzenDeploymentFilePath := ctx.GlobalString(AnzenDeploymentFileFlag.Name)
if _, err := os.Stat(anzenDeploymentFilePath); errors.Is(err, os.ErrNotExist) {
panic("Path " + anzenDeploymentFilePath + " does not exist")
}
sdkutils.ReadJsonConfig(credibleSquaringDeploymentFilePath, &credibleSquaringDeploymentRaw)
sdkutils.ReadJsonConfig(anzenDeploymentFilePath, &anzenDeploymentRaw)

logger, err := sdklogging.NewZapLogger(configRaw.Environment)
if err != nil {
Expand Down Expand Up @@ -137,9 +137,9 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
EthHttpRpcUrl: configRaw.EthRpcUrl,
EthHttpClient: ethRpcClient,
EthWsClient: ethWsClient,
OperatorStateRetrieverAddr: common.HexToAddress(credibleSquaringDeploymentRaw.Addresses.OperatorStateRetrieverAddr),
AnzenRegistryCoordinatorAddr: common.HexToAddress(credibleSquaringDeploymentRaw.Addresses.RegistryCoordinatorAddr),
SafetyFactorOracleAddr: common.HexToAddress(credibleSquaringDeploymentRaw.Addresses.SafetyFactorOracleAddr),
OperatorStateRetrieverAddr: common.HexToAddress(anzenDeploymentRaw.Addresses.OperatorStateRetrieverAddr),
AnzenRegistryCoordinatorAddr: common.HexToAddress(anzenDeploymentRaw.Addresses.RegistryCoordinatorAddr),
SafetyFactorOracleAddr: common.HexToAddress(anzenDeploymentRaw.Addresses.SafetyFactorOracleAddr),
AggregatorServerIpPortAddr: configRaw.AggregatorServerIpPortAddr,
RegisterOperatorOnStartup: configRaw.RegisterOperatorOnStartup,
SignerFn: signerV2,
Expand All @@ -156,7 +156,7 @@ func (c *Config) validate() {
panic("Config: BLSOperatorStateRetrieverAddr is required")
}
if c.AnzenRegistryCoordinatorAddr == common.HexToAddress("") {
panic("Config: IncredibleSquaringRegistryCoordinatorAddr is required")
panic("Config: AnzenRegistryCoordinatorAddr is required")
}
if c.SafetyFactorOracleAddr == common.HexToAddress("") {
panic("Config: SafetyFactorOracleAddr is required")
Expand All @@ -170,10 +170,10 @@ var (
Required: true,
Usage: "Load configuration from `FILE`",
}
CredibleSquaringDeploymentFileFlag = cli.StringFlag{
Name: "credible-squaring-deployment",
AnzenDeploymentFileFlag = cli.StringFlag{
Name: "anzen-deployment",
Required: true,
Usage: "Load credible squaring contract addresses from `FILE`",
Usage: "Load anzen contract addresses from `FILE`",
}
EcdsaPrivateKeyFlag = cli.StringFlag{
Name: "ecdsa-private-key",
Expand All @@ -186,7 +186,7 @@ var (

var requiredFlags = []cli.Flag{
ConfigFileFlag,
CredibleSquaringDeploymentFileFlag,
AnzenDeploymentFileFlag,
EcdsaPrivateKeyFlag,
}

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
command:
- --config
- config-files/aggregator-docker-compose.yaml
- --credible-squaring-deployment
- --anzen-deployment
- contracts/script/output/31337/anzen_avs_deployment_output.json
- --ecdsa-private-key
- "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
Expand Down Expand Up @@ -78,7 +78,7 @@ services:
# volumes:
# - ./:/incredible-squaring/
# working_dir: /incredible-squaring
# command: --config config-files/operator-docker-compose.anvil.yaml --credible-squaring-deployment contracts/script/output/31337/anzen_avs_deployment_output.json --ecdsa-private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --bls-private-key 2
# command: --config config-files/operator-docker-compose.anvil.yaml --anzen-deployment contracts/script/output/31337/anzen_avs_deployment_output.json --ecdsa-private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --bls-private-key 2
# networks:
# - anzen-network

Expand Down
29 changes: 22 additions & 7 deletions tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"math/big"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -53,9 +54,9 @@ func TestIntegration(t *testing.T) {
aggConfigRaw.EthRpcUrl = "http://" + anvilEndpoint
aggConfigRaw.EthWsUrl = "ws://" + anvilEndpoint

var credibleSquaringDeploymentRaw config.IncredibleSquaringDeploymentRaw
credibleSquaringDeploymentFilePath := "../../contracts/script/output/31337/anzen_avs_deployment_output.json"
sdkutils.ReadJsonConfig(credibleSquaringDeploymentFilePath, &credibleSquaringDeploymentRaw)
var anzenDeploymentRaw config.AnzenDeploymentRaw
anzenDeploymentFilePath := "../../contracts/script/output/31337/anzen_avs_deployment_output.json"
sdkutils.ReadJsonConfig(anzenDeploymentFilePath, &anzenDeploymentRaw)

logger, err := sdklogging.NewZapLogger(aggConfigRaw.Environment)
if err != nil {
Expand All @@ -70,6 +71,7 @@ func TestIntegration(t *testing.T) {
t.Fatalf("Failed to create eth client: %s", err.Error())
}

// TODO: this is a hack to get the operator address
aggregatorEcdsaPrivateKeyString := "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
if aggregatorEcdsaPrivateKeyString[:2] == "0x" {
aggregatorEcdsaPrivateKeyString = aggregatorEcdsaPrivateKeyString[2:]
Expand Down Expand Up @@ -105,8 +107,9 @@ func TestIntegration(t *testing.T) {
EthHttpClient: ethRpcClient,
EthWsRpcUrl: aggConfigRaw.EthWsUrl,
EthWsClient: ethWsClient,
OperatorStateRetrieverAddr: common.HexToAddress(credibleSquaringDeploymentRaw.Addresses.OperatorStateRetrieverAddr),
AnzenRegistryCoordinatorAddr: common.HexToAddress(credibleSquaringDeploymentRaw.Addresses.RegistryCoordinatorAddr),
OperatorStateRetrieverAddr: common.HexToAddress(anzenDeploymentRaw.Addresses.OperatorStateRetrieverAddr),
AnzenRegistryCoordinatorAddr: common.HexToAddress(anzenDeploymentRaw.Addresses.RegistryCoordinatorAddr),
SafetyFactorOracleAddr: common.HexToAddress(anzenDeploymentRaw.Addresses.SafetyFactorOracleAddr),
AggregatorServerIpPortAddr: aggConfigRaw.AggregatorServerIpPortAddr,
RegisterOperatorOnStartup: aggConfigRaw.RegisterOperatorOnStartup,
TxMgr: txMgr,
Expand Down Expand Up @@ -166,9 +169,10 @@ func TestIntegration(t *testing.T) {
if err != nil {
t.Fatalf("Cannot create AVS Reader: %s", err.Error())
}
// TODO: Figure out why this is failing with task 1 not being completed

// check if the task is recorded in the contract for task index 1
taskHash, err := avsReader.AvsServiceBindings.TaskManager.AllTaskHashes(&bind.CallOpts{}, 1)
taskHash, err := avsReader.AvsServiceBindings.TaskManager.AllTaskHashes(&bind.CallOpts{}, 0)
if err != nil {
t.Fatalf("Cannot get task hash: %s", err.Error())
}
Expand All @@ -177,7 +181,7 @@ func TestIntegration(t *testing.T) {
}

// check if the task response is recorded in the contract for task index 1
taskResponseHash, err := avsReader.AvsServiceBindings.TaskManager.AllTaskResponses(&bind.CallOpts{}, 1)
taskResponseHash, err := avsReader.AvsServiceBindings.TaskManager.AllTaskResponses(&bind.CallOpts{}, 0)
log.Printf("taskResponseHash: %v", taskResponseHash)
if err != nil {
t.Fatalf("Cannot get task response hash: %s", err.Error())
Expand All @@ -186,6 +190,17 @@ func TestIntegration(t *testing.T) {
t.Fatalf("Task response hash is empty")
}

// check if the safety factor is recorded in the oracle contract
safetyFactorInfo, err := avsReader.AvsServiceBindings.SafetyFactorOracle.GetSafetyFactor(&bind.CallOpts{}, 0)
if err != nil {
t.Fatalf("Cannot get safety factor: %s", err.Error())
}
if safetyFactorInfo.SafetyFactor.Cmp(big.NewInt(0)) == 0 {
t.Fatalf("Safety factor is empty")
}
if safetyFactorInfo.Timestamp.Cmp(big.NewInt(0)) == 0 {
t.Fatalf("Safety factor timestamp is empty")
}
}

// TODO(samlaf): have to advance chain to a block where the task is answered
Expand Down

0 comments on commit 8481d45

Please sign in to comment.