Skip to content

Signature aggregator binary #2829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d1d3ef0
aggregator works
sukantoraymond Jun 3, 2025
35b1ef1
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 3, 2025
da59bf8
replace logger
sukantoraymond Jun 3, 2025
8388779
fix lint
sukantoraymond Jun 3, 2025
25a1152
fix lint
sukantoraymond Jun 3, 2025
40cd790
fix lint
sukantoraymond Jun 3, 2025
f70797b
fix lint
sukantoraymond Jun 3, 2025
fae8d82
fix lint
sukantoraymond Jun 3, 2025
9d17142
fix lint
sukantoraymond Jun 3, 2025
8756e04
refactor
sukantoraymond Jun 3, 2025
59914dd
refactor
sukantoraymond Jun 3, 2025
aaf9321
binary still closes after command
sukantoraymond Jun 4, 2025
43e55f5
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 4, 2025
4e0bbde
sig agg now persists
sukantoraymond Jun 4, 2025
58dec7c
fix lint
sukantoraymond Jun 4, 2025
577dc6d
pass ci
sukantoraymond Jun 4, 2025
74d5eda
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 5, 2025
82902c2
cleanup
sukantoraymond Jun 5, 2025
345a642
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 5, 2025
0558548
refactor
sukantoraymond Jun 6, 2025
1419409
refactor
sukantoraymond Jun 6, 2025
51ffb3b
refactor
sukantoraymond Jun 6, 2025
22ed0dd
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 6, 2025
a9bb9ee
add logs
sukantoraymond Jun 9, 2025
19faf24
fix ci
sukantoraymond Jun 9, 2025
4109957
update e2e
sukantoraymond Jun 9, 2025
cc2c88b
add validator
sukantoraymond Jun 9, 2025
7deaef6
signature aggregator binary
sukantoraymond Jun 10, 2025
a3e6a93
fix upsize local cluster
sukantoraymond Jun 10, 2025
e7ec9f6
fix ci
sukantoraymond Jun 10, 2025
7b8252b
fix ci
sukantoraymond Jun 10, 2025
c7f1f05
fix lint
sukantoraymond Jun 10, 2025
f3fb3e6
fix lint
sukantoraymond Jun 10, 2025
e5713f8
fix lint
sukantoraymond Jun 10, 2025
e42f8ea
fixes
sukantoraymond Jun 10, 2025
698651a
save sig agg config
sukantoraymond Jun 10, 2025
c862851
fixes
sukantoraymond Jun 10, 2025
6d143a9
fixes
sukantoraymond Jun 10, 2025
0e09da0
fixes
sukantoraymond Jun 10, 2025
f1d30ea
lint
sukantoraymond Jun 10, 2025
d624289
fix
sukantoraymond Jun 10, 2025
0119705
fix
sukantoraymond Jun 10, 2025
526573c
fixes
sukantoraymond Jun 11, 2025
bdb07de
node local validate
sukantoraymond Jun 11, 2025
2ce770f
everything covered for sigagg binary
sukantoraymond Jun 11, 2025
5452757
fixes
sukantoraymond Jun 11, 2025
5fa61b1
add network cleanup
sukantoraymond Jun 11, 2025
0e2308c
fix remove
sukantoraymond Jun 11, 2025
ed2be1d
fix ci
sukantoraymond Jun 11, 2025
d1b2764
fix stop
sukantoraymond Jun 11, 2025
e87d34d
lint
sukantoraymond Jun 12, 2025
368def3
fixes
sukantoraymond Jun 12, 2025
a042c66
fixes
sukantoraymond Jun 12, 2025
9d07d00
retry
sukantoraymond Jun 12, 2025
59fb56a
fixes
sukantoraymond Jun 12, 2025
1332873
lint
sukantoraymond Jun 12, 2025
f2c6b8c
lint
sukantoraymond Jun 12, 2025
a0d171d
lint
sukantoraymond Jun 12, 2025
665f9f0
fix cleanup
sukantoraymond Jun 12, 2025
b447348
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 12, 2025
d038b1a
update downloader
sukantoraymond Jun 12, 2025
06ea522
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 13, 2025
7d80154
fixes
sukantoraymond Jun 13, 2025
c393a7b
Merge branch 'main' into sig-agg-binary
sukantoraymond Jun 26, 2025
87ed7e3
address comments
sukantoraymond Jun 26, 2025
ebb019c
test default quorum
sukantoraymond Jun 26, 2025
14aafe9
address comments
sukantoraymond Jun 26, 2025
44aad42
address comments
sukantoraymond Jun 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix lint
  • Loading branch information
sukantoraymond committed Jun 3, 2025
commit 40cd790b654a5d8d22129ba978f6d6427b4f8d1b
1 change: 0 additions & 1 deletion cmd/blockchaincmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@
} else {
ux.Logger.PrintToUser("Initializing Proof of Authority Validator Manager contract on blockchain %s ...", blockchainName)
if err := subnetSDK.InitializeProofOfAuthority(
aggregatorCtx,
app.Log,
network.SDKNetwork(),
genesisPrivateKey,
Expand All @@ -448,7 +447,7 @@
managerAddress,
useACP99,
app.GetSignatureAggregatorBinDir(),
); err != nil {

Check failure on line 450 in cmd/blockchaincmd/convert.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to subnetSDK.InitializeProofOfAuthority
return tracked, err
}
ux.Logger.GreenCheckmarkToUser("Proof of Authority Validator Manager contract successfully initialized on blockchain %s", blockchainName)
Expand Down
1 change: 0 additions & 1 deletion cmd/contractcmd/init_validator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"github.com/ava-labs/avalanche-cli/pkg/prompts"
"github.com/ava-labs/avalanche-cli/pkg/signatureaggregator"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanche-cli/pkg/validatormanager"

Check failure on line 20 in cmd/contractcmd/init_validator_manager.go

View workflow job for this annotation

GitHub Actions / Lint

could not import github.com/ava-labs/avalanche-cli/pkg/validatormanager (-: # github.com/ava-labs/avalanche-cli/pkg/validatormanager
blockchainSDK "github.com/ava-labs/avalanche-cli/sdk/blockchain"
sdkutils "github.com/ava-labs/avalanche-cli/sdk/utils"
validatormanagerSDK "github.com/ava-labs/avalanche-cli/sdk/validatormanager"
Expand Down Expand Up @@ -194,7 +194,6 @@
ux.Logger.PrintToUser(logging.Yellow.Wrap("Initializing Proof of Authority Validator Manager contract on blockchain %s"), blockchainName)

if err := validatormanager.SetupPoA(
aggregatorCtx,
app.Log,
subnetSDK,
network,
Expand Down
7 changes: 4 additions & 3 deletions pkg/signatureaggregator/signature-aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ package signatureaggregator

import (
"fmt"
"path/filepath"
"runtime"
"strings"

"github.com/ava-labs/avalanche-cli/pkg/application"
"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/utils"
"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanchego/utils/logging"
"path/filepath"
"runtime"
"strings"
)

func NewSignatureAggregatorLogger(
Expand Down
2 changes: 0 additions & 2 deletions pkg/validatormanager/validatormanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@
// [convertSubnetValidators], together with an evm [ownerAddress]
// to set as the owner of the PoA manager
func SetupPoA(
ctx context.Context,
log logging.Logger,
subnet blockchainSDK.Subnet,
network models.Network,
Expand All @@ -307,7 +306,6 @@
v2_0_0 bool,
) error {
return subnet.InitializeProofOfAuthority(
ctx,
log,
network.SDKNetwork(),
privateKey,
Expand All @@ -315,7 +313,7 @@
aggregatorLogger,
validatorManagerAddressStr,
v2_0_0,
"",

Check failure on line 316 in pkg/validatormanager/validatormanager.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-24.04)

not enough arguments in call to subnet.InitializeProofOfAuthority

Check failure on line 316 in pkg/validatormanager/validatormanager.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to subnet.InitializeProofOfAuthority

Check failure on line 316 in pkg/validatormanager/validatormanager.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to subnet.InitializeProofOfAuthority

Check failure on line 316 in pkg/validatormanager/validatormanager.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to subnet.InitializeProofOfAuthority

Check failure on line 316 in pkg/validatormanager/validatormanager.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to subnet.InitializeProofOfAuthority
)
}

Expand Down
31 changes: 18 additions & 13 deletions sdk/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@ func (c *Subnet) InitializeProofOfAuthority(

subnetConversionUnsignedMessage, err := validatormanager.GetPChainSubnetToL1ConversionUnsignedMessage(
network,
0,
aggregatorExtraPeerEndpoints,
c.SubnetID,
c.BlockchainID,
managerAddress,
Expand All @@ -417,10 +415,7 @@ func (c *Subnet) InitializeProofOfAuthority(
}

// Create config file for signature aggregator
config, err := createSignatureAggregatorConfig(c.SubnetID.String(), network.Endpoint, aggregatorExtraPeerEndpoints)
if err != nil {
return fmt.Errorf("failed to create signature aggregator config: %w", err)
}
config := createSignatureAggregatorConfig(c.SubnetID.String(), network.Endpoint, aggregatorExtraPeerEndpoints)

configPath := filepath.Join(signatureAggregatorBinDir, "config.json")
if err := writeSignatureAggregatorConfig(config, configPath); err != nil {
Expand Down Expand Up @@ -475,8 +470,8 @@ func startSignatureAggregator(binPath string, configPath string, logFile string,
killExistingProcess := func() error {
// Try pkill first
cmd := exec.Command("pkill", "-f", "signature-aggregator")
if err := cmd.Run(); err == nil {
return nil
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to kill existing signature-aggregator process: %w", err)
}
return nil
}
Expand Down Expand Up @@ -517,7 +512,11 @@ func startSignatureAggregator(binPath string, configPath string, logFile string,
cmd.Stderr = logWriter

if err := cmd.Start(); err != nil {
logWriter.Close()
if closeErr := logWriter.Close(); closeErr != nil {
logger.Warn("Failed to close log writer",
zap.Error(closeErr),
)
}
if i == maxRetries-1 {
return 0, fmt.Errorf("failed to start signature-aggregator after %d attempts: %w", maxRetries, err)
}
Expand Down Expand Up @@ -690,7 +689,7 @@ type PeerConfig struct {
IP string `json:"ip"`
}

func createSignatureAggregatorConfig(subnetID string, networkEndpoint string, peers []info.Peer) (*SignatureAggregatorConfig, error) {
func createSignatureAggregatorConfig(subnetID string, networkEndpoint string, peers []info.Peer) *SignatureAggregatorConfig {
config := &SignatureAggregatorConfig{
LogLevel: "debug",
PChainAPI: APIConfig{BaseURL: networkEndpoint},
Expand All @@ -713,7 +712,7 @@ func createSignatureAggregatorConfig(subnetID string, networkEndpoint string, pe
})
}

return config, nil
return config
}

func writeSignatureAggregatorConfig(config *SignatureAggregatorConfig, configPath string) error {
Expand All @@ -722,7 +721,7 @@ func writeSignatureAggregatorConfig(config *SignatureAggregatorConfig, configPat
return fmt.Errorf("failed to marshal config: %w", err)
}

if err := os.WriteFile(configPath, configBytes, 0600); err != nil {
if err := os.WriteFile(configPath, configBytes, 0o600); err != nil {
return fmt.Errorf("failed to write config file: %w", err)
}

Expand Down Expand Up @@ -769,7 +768,13 @@ func SignMessage(message, justification, signingSubnetID string, quorumPercentag
)
return nil, fmt.Errorf("failed to make request: %w", err)
}
defer resp.Body.Close()
defer func() {
if closeErr := resp.Body.Close(); closeErr != nil {
logger.Warn("Failed to close response body",
zap.Error(closeErr),
)
}
}()

// Read response body
body, err := io.ReadAll(resp.Body)
Expand Down
8 changes: 0 additions & 8 deletions sdk/interchain/signature-aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,6 @@ func (s *SignatureAggregator) Sign(
msg *warp.UnsignedMessage,
justification []byte,
) (*warp.Message, error) {
fmt.Printf("msg %s \n", msg)
fmt.Printf("msg id %s \n", msg.ID())
fmt.Printf("msg id string %s \n", msg.ID().String())
fmt.Printf("justificaiton %s \n", justification)
fmt.Printf("s.subnetID %s \n", s.subnetID)
fmt.Printf("s.quorumPercentage %s \n", s.quorumPercentage)

if signed, err := s.aggregator.CreateSignedMessage(
msg,
justification,
Expand All @@ -251,7 +244,6 @@ func (s *SignatureAggregator) Sign(
); err == nil {
return signed, nil
}
fmt.Printf("we have err here\n")
// many times first attempt just fails for connection timeouts (<= 10 secs spent there)
return s.aggregator.CreateSignedMessage(
msg,
Expand Down
7 changes: 3 additions & 4 deletions sdk/validatormanager/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package validatormanager
import (
"context"
"fmt"
"math/big"
"strings"

"github.com/ava-labs/avalanche-cli/pkg/signatureaggregator"
"github.com/ava-labs/avalanche-cli/sdk/interchain"
"github.com/ava-labs/avalanche-cli/sdk/network"
Expand All @@ -14,8 +17,6 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
warpMessage "github.com/ava-labs/avalanchego/vms/platformvm/warp/message"
warpPayload "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload"
"math/big"
"strings"

"github.com/ava-labs/avalanche-cli/pkg/contract"
"github.com/ava-labs/avalanche-cli/sdk/validator"
Expand Down Expand Up @@ -270,8 +271,6 @@ func GetPChainSubnetToL1ConversionMessage(

func GetPChainSubnetToL1ConversionUnsignedMessage(
network network.Network,
aggregatorQuorumPercentage uint64,
aggregatorExtraPeerEndpoints []info.Peer,
subnetID ids.ID,
managerBlockchainID ids.ID,
managerAddress common.Address,
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/testcases/validatormanager/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,9 @@
BootstrapValidators: avaGoBootstrapValidators,
}

ctx, cancel := utils.GetSignatureAggregatorContext()
_, cancel := utils.GetSignatureAggregatorContext()
defer cancel()
err = subnetSDK.InitializeProofOfAuthority(
ctx,
logging.NoLog{},
network.SDKNetwork(),
k.PrivKeyHex(),
Expand All @@ -227,7 +226,7 @@
ProxyContractAddress,
true,
"",
)

Check failure on line 229 in tests/e2e/testcases/validatormanager/suite.go

View workflow job for this annotation

GitHub Actions / Lint

not enough arguments in call to subnetSDK.InitializeProofOfAuthority
gomega.Expect(err).Should(gomega.BeNil())
})
})
Loading