Skip to content
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

test: aggregator bump fee #1297

Conversation

MarcosNicolau
Copy link
Collaborator

@MarcosNicolau MarcosNicolau commented Oct 18, 2024

Test aggregator bump fee

Description

This pr is to test #1286. The respondToTaskV2 function in AlignedServiceManagerContract has been modified to successfully respond if an ith higher or equal to 4 is provided, this is to avoid reverts in next iterations.

Then, the context timeout is modified to 1sec. This way, the context will be done faster than the block WaitForTransactionReceipt so a new iteration will start and a new tx will be sent with a higher gasPrice.

Testing

To test it, just setup a local devnet as usual and sends proofs of any type.

You should see in the logs how the gas price is increased after every iteration:

[2024-10-18 16:44:41.607 -03] INFO (pkg/aggregator.go:270) Sending aggregated response onchain {"batchIdentifierHash":"0x4a99727c126f5de1585ae54b493f046d3c0bfdb56fb4a59711427b0f1dd098c1","taskIndex":0}
[2024-10-18 16:44:41.607 -03] INFO (pkg/aggregator.go:299) - Locked Wallet Resources: Sending aggregated response for batch%!(EXTRA string=merkleRoot, string=da4f89d5540acf7e2aec9eadc60da129beb23c9da4b0346a53d7fd360cddd7ad, string=senderAddress, string=7969c5ed335650692bc04293b07f5bf2e7a673c0, string=batchIdentifierHash, string=4a99727c126f5de1585ae54b493f046d3c0bfdb56fb4a59711427b0f1dd098c1)
[2024-10-18 16:44:41.704 -03] INFO (chainio/avs_writer.go:149) Simulated cost {"cost":"262651003677114"}
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:167) Batch RespondToTaskFeeLimit {"RespondToTaskFeeLimit":"1500000010500000"}
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:199) Aggregator balance {"balance":"9999998939516696560420"}
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:217) Batcher balance {"balance":"1001070133935012705"}
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:108) Sending ResponseToTask transaction for 1th with a gas price of 1100000015
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:149) Simulated cost {"cost":"262651003677114"}
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:167) Batch RespondToTaskFeeLimit {"RespondToTaskFeeLimit":"1500000010500000"}
[2024-10-18 16:44:41.705 -03] INFO (chainio/avs_writer.go:199) Aggregator balance {"balance":"9999998939516696560420"}
[2024-10-18 16:44:41.706 -03] INFO (chainio/avs_writer.go:217) Batcher balance {"balance":"1001070133935012705"}
[2024-10-18 16:44:43.710 -03] INFO (chainio/avs_writer.go:108) Sending ResponseToTask transaction for 2th with a gas price of 1320000018
[2024-10-18 16:44:43.710 -03] INFO (chainio/avs_writer.go:149) Simulated cost {"cost":"48687100663915"}
[2024-10-18 16:44:43.712 -03] INFO (chainio/avs_writer.go:167) Batch RespondToTaskFeeLimit {"RespondToTaskFeeLimit":"1500000010500000"}
[2024-10-18 16:44:43.712 -03] INFO (chainio/avs_writer.go:199) Aggregator balance {"balance":"9999998939516696560420"}
[2024-10-18 16:44:43.713 -03] INFO (chainio/avs_writer.go:217) Batcher balance {"balance":"1001070133935012705"}
[2024-10-18 16:44:45.722 -03] INFO (chainio/avs_writer.go:108) Sending ResponseToTask transaction for 3th with a gas price of 1716000023
[2024-10-18 16:44:45.722 -03] INFO (chainio/avs_writer.go:149) Simulated cost {"cost":"58424520796698"}
[2024-10-18 16:44:45.724 -03] INFO (chainio/avs_writer.go:167) Batch RespondToTaskFeeLimit {"RespondToTaskFeeLimit":"1500000010500000"}
[2024-10-18 16:44:45.725 -03] INFO (chainio/avs_writer.go:199) Aggregator balance {"balance":"9999998939516696560420"}
[2024-10-18 16:44:45.725 -03] INFO (chainio/avs_writer.go:217) Batcher balance {"balance":"1001070133935012705"}
[2024-10-18 16:44:47.734 -03] INFO (chainio/avs_writer.go:108) Sending ResponseToTask transaction for 4th with a gas price of 2402400032
[2024-10-18 16:44:47.734 -03] INFO (chainio/avs_writer.go:149) Simulated cost {"cost":"75951877018003"}
[2024-10-18 16:44:47.736 -03] INFO (chainio/avs_writer.go:167) Batch RespondToTaskFeeLimit {"RespondToTaskFeeLimit":"1500000010500000"}
[2024-10-18 16:44:47.736 -03] INFO (chainio/avs_writer.go:199) Aggregator balance {"balance":"9999998939516696560420"}
[2024-10-18 16:44:47.737 -03] INFO (chainio/avs_writer.go:217) Batcher balance {"balance":"1001070133935012705"}
[2024-10-18 16:44:48.836 -03] INFO (pkg/aggregator.go:313) - Unlocked Wallet Resources: Sending aggregated response for batch 4a99727c126f5de1585ae54b493f046d3c0bfdb56fb4a59711427b0f1dd098c1
[2024-10-18 16:44:48.837 -03] INFO (pkg/aggregator.go:275) Aggregator successfully responded to task {"batchIdentifierHash":"0x4a99727c126f5de1585ae54b493f046d3c0bfdb56fb4a59711427b0f1dd098c1","taskIndex":0}

Note: you might get NonceToLow, that is a matter of timing, since the timer for waiting for a receipt is changed to be 1 second, maybe a transaction gets accepted and when sending again, it can't replace it since it has been accepted. To lower the probability of that, block time was modified to 15s.

Finally, you should also be able to see the metrics in the aggregator section:

Screenshot 2024-11-04 at 11 54 40 AM

Type of change

  • Test

Checklist

  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue

@MarcosNicolau MarcosNicolau self-assigned this Oct 18, 2024
) external onlyAggregator {
uint256 initialGasLeft = gasleft();

if (i < 4) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can modify this 4 to a higher value to test higher retries. Don't forget to re-deploy the contracts.

@@ -74,11 +74,11 @@ func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMerkleRoot [32]byte, senderAddress [20]byte, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature) (*types.Receipt, error) {
txOpts := *w.Signer.GetTxOpts()
txOpts.NoSend = true // simulate the transaction
tx, err := w.AvsContractBindings.ServiceManager.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
tx, err := w.AvsContractBindings.ServiceManager.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature, new(big.Int).SetUint64(5))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you modify the contract, make sure you pass a larger number so that this transaction does not revert.


if err != nil {
// Retry with fallback
tx, err = w.AvsContractBindings.ServiceManagerFallback.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
tx, err = w.AvsContractBindings.ServiceManagerFallback.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature, new(big.Int).SetUint64(5))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@MarcosNicolau MarcosNicolau deleted the test-aggregator-bump-fee branch November 11, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant