Skip to content

Commit

Permalink
Rename beethoven repo
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm committed Jan 25, 2024
1 parent 0abeeff commit e2ef6a9
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 111 deletions.
44 changes: 22 additions & 22 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"time"
"unicode"

"github.com/0xPolygon/beethoven/client"
beethovenTypes "github.com/0xPolygon/beethoven/rpc/types"
"github.com/0xPolygon/beethoven/tx"
"github.com/0xPolygon/agglayer/client"
agglayerTypes "github.com/0xPolygon/agglayer/rpc/types"

Check failure on line 18 in aggregator/aggregator.go

View workflow job for this annotation

GitHub Actions / json-schema (1.21.x, amd64)

github.com/0xPolygon/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/7c387218d32c30b42d7f16ea9c6d5515d4d876b117f4d008fd68123e67afa92f: exit status 128:
"github.com/0xPolygon/agglayer/tx"

Check failure on line 19 in aggregator/aggregator.go

View workflow job for this annotation

GitHub Actions / json-schema (1.21.x, amd64)

github.com/0xPolygon/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/7c387218d32c30b42d7f16ea9c6d5515d4d876b117f4d008fd68123e67afa92f: exit status 128:
"github.com/0xPolygonHermez/zkevm-node/aggregator/metrics"
"github.com/0xPolygonHermez/zkevm-node/aggregator/prover"
"github.com/0xPolygonHermez/zkevm-node/config/types"
Expand Down Expand Up @@ -71,7 +71,7 @@ type Aggregator struct {
exit context.CancelFunc

sequencerPrivateKey *ecdsa.PrivateKey
BeethovenClient client.ClientInterface
agglayerClient client.ClientInterface
}

// New creates a new aggregator.
Expand All @@ -80,7 +80,7 @@ func New(
stateInterface stateInterface,
ethTxManager ethTxManager,
etherman etherman,
beethovenClient client.ClientInterface,
agglayerClient client.ClientInterface,
sequencerPrivateKey *ecdsa.PrivateKey,
) (Aggregator, error) {
var profitabilityChecker aggregatorTxProfitabilityChecker
Expand All @@ -91,7 +91,7 @@ func New(
profitabilityChecker = NewTxProfitabilityCheckerAcceptAll(stateInterface, cfg.IntervalAfterWhichBatchConsolidateAnyway.Duration)
}

if cfg.SettlementBackend == Beethoven {
if cfg.SettlementBackend == agglayer {
if sequencerPrivateKey == nil {
return Aggregator{}, fmt.Errorf("the private key of the sequencer needs to be provided")
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func New(
TimeCleanupLockedProofs: cfg.CleanupLockedProofsInterval,

finalProof: make(chan finalProofMsg),
BeethovenClient: beethovenClient,
agglayerClient: agglayerClient,
sequencerPrivateKey: sequencerPrivateKey,
}

Expand Down Expand Up @@ -302,8 +302,8 @@ func (a *Aggregator) sendFinalProof() {
if success := a.settleProofToL1(ctx, proof, inputs); !success {
continue
}
case Beethoven:
if success := a.settleProofToBeethoven(ctx, proof, inputs); !success {
case agglayer:
if success := a.settleProofToagglayer(ctx, proof, inputs); !success {
continue
}
default:
Expand Down Expand Up @@ -1144,47 +1144,47 @@ func (a *Aggregator) settleProofToL1(ctx context.Context, proof *state.Proof, in
return true
}

func (a *Aggregator) settleProofToBeethoven(ctx context.Context, proof *state.Proof, inputs ethmanTypes.FinalProofInputs) (success bool) {
func (a *Aggregator) settleProofToagglayer(ctx context.Context, proof *state.Proof, inputs ethmanTypes.FinalProofInputs) (success bool) {
l1Contract := a.Ethman.GetL1ContractAddress()
proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x")
proofBytes := common.Hex2Bytes(proofStrNo0x)
tx := tx.Tx{
L1Contract: l1Contract,
LastVerifiedBatch: beethovenTypes.ArgUint64(proof.BatchNumber - 1),
NewVerifiedBatch: beethovenTypes.ArgUint64(proof.BatchNumberFinal),
LastVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumber - 1),
NewVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumberFinal),
ZKP: tx.ZKP{
NewStateRoot: common.BytesToHash(inputs.NewStateRoot),
NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot),
Proof: beethovenTypes.ArgBytes(proofBytes),
Proof: agglayerTypes.ArgBytes(proofBytes),
},
}
signedTx, err := tx.Sign(a.sequencerPrivateKey)
if err != nil {
log.Errorf("failed to sign tx: %v", err)
a.handleFailureToSendToBeethoven(ctx, proof)
a.handleFailureToSendToagglayer(ctx, proof)
return false
}
log.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex())
txHash, err := a.BeethovenClient.SendTx(*signedTx)
txHash, err := a.agglayerClient.SendTx(*signedTx)
if err != nil {
log.Errorf("failed to send tx to the interop: %v", err)
a.handleFailureToSendToBeethoven(ctx, proof)
a.handleFailureToSendToagglayer(ctx, proof)
return false
}
log.Infof("tx %s sent to beethoven, waiting to be mined", txHash.Hex())
log.Debugf("Timeout set to %f seconds", a.cfg.BeethovenTxTimeout.Duration.Seconds())
waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.BeethovenTxTimeout.Duration))
log.Infof("tx %s sent to agglayer, waiting to be mined", txHash.Hex())
log.Debugf("Timeout set to %f seconds", a.cfg.agglayerTxTimeout.Duration.Seconds())
waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.agglayerTxTimeout.Duration))
defer cancelFunc()
if err := a.BeethovenClient.WaitTxToBeMined(txHash, waitCtx); err != nil {
if err := a.agglayerClient.WaitTxToBeMined(txHash, waitCtx); err != nil {
log.Errorf("interop didn't mine the tx: %v", err)
a.handleFailureToSendToBeethoven(ctx, proof)
a.handleFailureToSendToagglayer(ctx, proof)
return false
}
// TODO: wait for synchronizer to catch up
return true
}

func (a *Aggregator) handleFailureToSendToBeethoven(ctx context.Context, proof *state.Proof) {
func (a *Aggregator) handleFailureToSendToagglayer(ctx context.Context, proof *state.Proof) {
log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
proof.GeneratingSince = nil
err := a.State.UpdateGeneratedProof(ctx, proof, nil)
Expand Down
16 changes: 8 additions & 8 deletions aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (t *TokenAmountWithDecimals) UnmarshalText(data []byte) error {
type SettlementBackend string

const (
// Beethoven specifies to send ZKPs to Beethoven service
Beethoven SettlementBackend = "beethoven"
// agglayer specifies to send ZKPs to agglayer service
agglayer SettlementBackend = "agglayer"
// L1 specifies to send ZKPs to L1 chain
L1 SettlementBackend = "l1"
)
Expand Down Expand Up @@ -96,15 +96,15 @@ type Config struct {
// final gas: 1100
GasOffset uint64 `mapstructure:"GasOffset"`

// SettlementBackend indicates where ZKPs are settled. It can be "l1" or "beethoven"
// SettlementBackend indicates where ZKPs are settled. It can be "l1" or "agglayer"
SettlementBackend SettlementBackend `mapstructure:"SettlementBackend"`

// BeethovenTxTimeout is the interval time to wait for a tx to be mined from the beethoven
BeethovenTxTimeout types.Duration `mapstructure:"BeethovenTxTimeout"`
// agglayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer
agglayerTxTimeout types.Duration `mapstructure:"agglayerTxTimeout"`

// BeethovenURL url of the beethoven service
BeethovenURL string `mapstructure:"BeethovenURL"`
// agglayerURL url of the agglayer service
agglayerURL string `mapstructure:"agglayerURL"`

// SequencerPrivateKey of the sequencer, used to authorize txs sent to the beethoven
// SequencerPrivateKey of the sequencer, used to authorize txs sent to the agglayer
SequencerPrivateKey types.KeystoreFileConfig `mapstructure:"SequencerPrivateKey"`
}
8 changes: 4 additions & 4 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"runtime"
"time"

beethovenClient "github.com/0xPolygon/beethoven/client"
agglayerClient "github.com/0xPolygon/agglayer/client"

Check failure on line 16 in cmd/run.go

View workflow job for this annotation

GitHub Actions / json-schema (1.21.x, amd64)

github.com/0xPolygon/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/7c387218d32c30b42d7f16ea9c6d5515d4d876b117f4d008fd68123e67afa92f: exit status 128:
dataCommitteeClient "github.com/0xPolygon/cdk-data-availability/client"
datastreamerlog "github.com/0xPolygonHermez/zkevm-data-streamer/log"
"github.com/0xPolygonHermez/zkevm-node"
Expand Down Expand Up @@ -432,11 +432,11 @@ func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxm
}

func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) {
var beethCli *beethovenClient.Client
var beethCli *agglayerClient.Client
var sequencerPrivateKey *ecdsa.PrivateKey
if c.SettlementBackend == aggregator.Beethoven {
if c.SettlementBackend == aggregator.agglayer {
var err error
beethCli = beethovenClient.New(c.BeethovenURL)
beethCli = agglayerClient.New(c.agglayerURL)
_, sequencerPrivateKey, err = etherman.LoadAuthFromKeyStore(
c.SequencerPrivateKey.Path, c.SequencerPrivateKey.Password,
)
Expand Down
8 changes: 4 additions & 4 deletions docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2307,10 +2307,10 @@ MaxBatchesForL1=300
| - [CleanupLockedProofsInterval](#Aggregator_CleanupLockedProofsInterval ) | No | string | No | - | Duration |
| - [GeneratingProofCleanupThreshold](#Aggregator_GeneratingProofCleanupThreshold ) | No | string | No | - | GeneratingProofCleanupThreshold represents the time interval after<br />which a proof in generating state is considered to be stuck and<br />allowed to be cleared. |
| - [GasOffset](#Aggregator_GasOffset ) | No | integer | No | - | GasOffset is the amount of gas to be added to the gas estimation in order<br />to provide an amount that is higher than the estimated one. This is used<br />to avoid the TX getting reverted in case something has changed in the network<br />state after the estimation which can cause the TX to require more gas to be<br />executed.<br /><br />ex:<br />gas estimation: 1000<br />gas offset: 100<br />final gas: 1100 |
| - [SettlementBackend](#Aggregator_SettlementBackend ) | No | string | No | - | SettlementBackend indicates where ZKPs are settled. It can be "l1" or "beethoven" |
| - [BeethovenTxTimeout](#Aggregator_BeethovenTxTimeout ) | No | string | No | - | Duration |
| - [BeethovenURL](#Aggregator_BeethovenURL ) | No | string | No | - | BeethovenURL url of the beethoven service |
| - [SequencerPrivateKey](#Aggregator_SequencerPrivateKey ) | No | object | No | - | SequencerPrivateKey of the sequencer, used to authorize txs sent to the beethoven |
| - [SettlementBackend](#Aggregator_SettlementBackend ) | No | string | No | - | SettlementBackend indicates where ZKPs are settled. It can be "l1" or "agglayer" |
| - [agglayerTxTimeout](#Aggregator_agglayerTxTimeout ) | No | string | No | - | Duration |
| - [agglayerURL](#Aggregator_agglayerURL ) | No | string | No | - | agglayerURL url of the agglayer service |
| - [SequencerPrivateKey](#Aggregator_SequencerPrivateKey ) | No | object | No | - | SequencerPrivateKey of the sequencer, used to authorize txs sent to the agglayer |

### <a name="Aggregator_Host"></a>12.1. `Aggregator.Host`

Expand Down Expand Up @@ -2580,23 +2580,23 @@ GasOffset=0

**Default:** `""`

**Description:** SettlementBackend indicates where ZKPs are settled. It can be "l1" or "beethoven"
**Description:** SettlementBackend indicates where ZKPs are settled. It can be "l1" or "agglayer"

**Example setting the default value** (""):
```
[Aggregator]
SettlementBackend=""
```

### <a name="Aggregator_BeethovenTxTimeout"></a>12.16. `Aggregator.BeethovenTxTimeout`
### <a name="Aggregator_agglayerTxTimeout"></a>12.16. `Aggregator.agglayerTxTimeout`

**Title:** Duration

**Type:** : `string`

**Default:** `"0s"`

**Description:** BeethovenTxTimeout is the interval time to wait for a tx to be mined from the beethoven
**Description:** agglayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer

**Examples:**

Expand All @@ -2611,27 +2611,27 @@ SettlementBackend=""
**Example setting the default value** ("0s"):
```
[Aggregator]
BeethovenTxTimeout="0s"
agglayerTxTimeout="0s"
```

### <a name="Aggregator_BeethovenURL"></a>12.17. `Aggregator.BeethovenURL`
### <a name="Aggregator_agglayerURL"></a>12.17. `Aggregator.agglayerURL`

**Type:** : `string`

**Default:** `""`

**Description:** BeethovenURL url of the beethoven service
**Description:** agglayerURL url of the agglayer service

**Example setting the default value** (""):
```
[Aggregator]
BeethovenURL=""
agglayerURL=""
```

### <a name="Aggregator_SequencerPrivateKey"></a>12.18. `[Aggregator.SequencerPrivateKey]`

**Type:** : `object`
**Description:** SequencerPrivateKey of the sequencer, used to authorize txs sent to the beethoven
**Description:** SequencerPrivateKey of the sequencer, used to authorize txs sent to the agglayer

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------- | ------- | ------ | ---------- | ---------- | ------------------------------------------------------ |
Expand Down
14 changes: 7 additions & 7 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,22 +994,22 @@
},
"SettlementBackend": {
"type": "string",
"description": "SettlementBackend indicates where ZKPs are settled. It can be \"l1\" or \"beethoven\"",
"description": "SettlementBackend indicates where ZKPs are settled. It can be \"l1\" or \"agglayer\"",
"default": ""
},
"BeethovenTxTimeout": {
"agglayerTxTimeout": {
"type": "string",
"title": "Duration",
"description": "BeethovenTxTimeout is the interval time to wait for a tx to be mined from the beethoven",
"description": "agglayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer",
"default": "0s",
"examples": [
"1m",
"300ms"
]
},
"BeethovenURL": {
"agglayerURL": {
"type": "string",
"description": "BeethovenURL url of the beethoven service",
"description": "agglayerURL url of the agglayer service",
"default": ""
},
"SequencerPrivateKey": {
Expand All @@ -1027,7 +1027,7 @@
},
"additionalProperties": false,
"type": "object",
"description": "SequencerPrivateKey of the sequencer, used to authorize txs sent to the beethoven"
"description": "SequencerPrivateKey of the sequencer, used to authorize txs sent to the agglayer"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -1582,4 +1582,4 @@
"additionalProperties": false,
"type": "object",
"description": "Config represents the configuration of the entire Hermez Node The file is TOML format You could find some examples:\n\n[TOML format]: https://en.wikipedia.org/wiki/TOML"
}
}
Loading

0 comments on commit e2ef6a9

Please sign in to comment.