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

Feature/#2669 lx ly #2694

Merged
merged 43 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b15eecc
smc
ARR552 Oct 16, 2023
4b848c6
rename matic to pol
ARR552 Oct 16, 2023
3f051d6
WIP
ARR552 Oct 18, 2023
3ca8dc6
Etherman + unit tests
ARR552 Oct 19, 2023
7a73521
Addresses
ARR552 Oct 19, 2023
957ae4b
aggregator
ARR552 Oct 19, 2023
6ecb7da
New genesis file
ARR552 Oct 19, 2023
38f5c66
new genesis
ARR552 Oct 20, 2023
f30958f
state unit tests
ARR552 Oct 20, 2023
774b6ed
aggregator unit test
ARR552 Oct 20, 2023
552a8ef
sequencer uni tests
ARR552 Oct 20, 2023
07412c0
pool unit test
ARR552 Oct 20, 2023
aae460c
Merge branch 'develop' into feature/#2669_LxLy
ARR552 Oct 20, 2023
fd7e703
fix symLinks
ARR552 Oct 20, 2023
12b7e6d
linter
ARR552 Oct 20, 2023
1d05517
documentation
ARR552 Oct 20, 2023
3a51ed5
Wip
ARR552 Oct 23, 2023
617bec6
oldPolygonZkevmBridge
ARR552 Oct 23, 2023
26d0ee4
fix e2e group 1
ARR552 Oct 24, 2023
1fcda5a
linter
ARR552 Oct 24, 2023
394b528
docs
ARR552 Oct 24, 2023
3b8a9b1
Fix init Batch 1
ARR552 Oct 24, 2023
0c136f7
linter
ARR552 Oct 24, 2023
2fae56c
Fix e2e
ARR552 Oct 25, 2023
cfaa28b
Fix forced
ARR552 Oct 26, 2023
c846f3d
Revert "Fix forced"
ARR552 Oct 26, 2023
16cf62c
wip
ARR552 Oct 26, 2023
e08c2ca
fix forced e2e
ARR552 Oct 30, 2023
abb5418
support genesis config with pointer to BatchData (#2729)
joanestebanr Oct 30, 2023
e09661a
genesis fix
ARR552 Nov 6, 2023
7bb568e
Merge remote-tracking branch 'origin/develop' into feature/#2669_LxLy
ARR552 Nov 8, 2023
91096e9
forkID 6
ARR552 Nov 15, 2023
32de438
Merge remote-tracking branch 'origin/develop' into feature/#2669_LxLy
ARR552 Nov 15, 2023
bcd7afc
fix e2e forcedBatches again
ARR552 Nov 15, 2023
ff1a41e
new smc
ARR552 Nov 22, 2023
e6dc337
genesis
ARR552 Nov 22, 2023
ba30e58
Merge branch 'develop' into feature/#2669_LxLy
ARR552 Nov 22, 2023
ddb5bc7
linter
ARR552 Nov 22, 2023
a72ff51
Fix e2e
ARR552 Nov 22, 2023
47feea3
genesis
ARR552 Nov 22, 2023
323758a
new docker + genesis
ARR552 Nov 22, 2023
f282741
json doc
ARR552 Nov 22, 2023
2860941
fix e2e
ARR552 Nov 22, 2023
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
6 changes: 3 additions & 3 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (a *Aggregator) sendFinalProof() {

// add batch verification to be monitored
sender := common.HexToAddress(a.cfg.SenderAddress)
to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(proof.BatchNumber-1, proof.BatchNumberFinal, &inputs)
to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(proof.BatchNumber-1, proof.BatchNumberFinal, &inputs, sender)
if err != nil {
log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err)
a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
Expand Down Expand Up @@ -766,15 +766,15 @@ func (a *Aggregator) getAndLockBatchToProve(ctx context.Context, prover proverIn

log.Info("Checking profitability to aggregate batch")

// pass matic collateral as zero here, bcs in smart contract fee for aggregator is not defined yet
// pass pol collateral as zero here, bcs in smart contract fee for aggregator is not defined yet
isProfitable, err := a.ProfitabilityChecker.IsProfitable(ctx, big.NewInt(0))
if err != nil {
log.Errorf("Failed to check aggregator profitability, err: %v", err)
return nil, nil, err
}

if !isProfitable {
log.Infof("Batch is not profitable, matic collateral %d", big.NewInt(0))
log.Infof("Batch is not profitable, pol collateral %d", big.NewInt(0))
return nil, nil, err
}

Expand Down
8 changes: 4 additions & 4 deletions aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestSendFinalProof(t *testing.T) {
NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(),
NewStateRoot: finalBatch.StateRoot.Bytes(),
}
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs).Run(func(args mock.Arguments) {
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
assert.True(a.verifyingProof)
}).Return(nil, nil, errBanana).Once()
m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
Expand All @@ -108,7 +108,7 @@ func TestSendFinalProof(t *testing.T) {
NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(),
NewStateRoot: finalBatch.StateRoot.Bytes(),
}
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs).Run(func(args mock.Arguments) {
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
assert.True(a.verifyingProof)
}).Return(nil, nil, errBanana).Once()
m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
Expand All @@ -131,7 +131,7 @@ func TestSendFinalProof(t *testing.T) {
NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(),
NewStateRoot: finalBatch.StateRoot.Bytes(),
}
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs).Run(func(args mock.Arguments) {
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
assert.True(a.verifyingProof)
}).Return(&to, data, nil).Once()
monitoredTxID := buildMonitoredTxID(batchNum, batchNumFinal)
Expand All @@ -156,7 +156,7 @@ func TestSendFinalProof(t *testing.T) {
NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(),
NewStateRoot: finalBatch.StateRoot.Bytes(),
}
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs).Run(func(args mock.Arguments) {
m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
assert.True(a.verifyingProof)
}).Return(&to, data, nil).Once()
monitoredTxID := buildMonitoredTxID(batchNum, batchNumFinal)
Expand Down
2 changes: 1 addition & 1 deletion aggregator/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type ethTxManager interface {
// etherman contains the methods required to interact with ethereum
type etherman interface {
GetLatestVerifiedBatchNum() (uint64, error)
BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs) (to *common.Address, data []byte, err error)
BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error)
}

// aggregatorTxProfitabilityChecker interface for different profitability
Expand Down
22 changes: 11 additions & 11 deletions aggregator/mocks/mock_etherman.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions aggregator/profitabilitychecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
type TxProfitabilityCheckerType string

const (
// ProfitabilityBase checks matic collateral with min reward
// ProfitabilityBase checks pol collateral with min reward
ProfitabilityBase = "base"
// ProfitabilityAcceptAll validate batch anyway and don't check anything
ProfitabilityAcceptAll = "acceptall"
)

// TxProfitabilityCheckerBase checks matic collateral with min reward
// TxProfitabilityCheckerBase checks pol collateral with min reward
type TxProfitabilityCheckerBase struct {
State stateInterface
IntervalAfterWhichBatchSentAnyway time.Duration
Expand All @@ -32,8 +32,8 @@ func NewTxProfitabilityCheckerBase(state stateInterface, interval time.Duration,
}
}

// IsProfitable checks matic collateral with min reward
func (pc *TxProfitabilityCheckerBase) IsProfitable(ctx context.Context, maticCollateral *big.Int) (bool, error) {
// IsProfitable checks pol collateral with min reward
func (pc *TxProfitabilityCheckerBase) IsProfitable(ctx context.Context, polCollateral *big.Int) (bool, error) {
//if pc.IntervalAfterWhichBatchSentAnyway != 0 {
// ok, err := isConsolidatedBatchAppeared(ctx, pc.State, pc.IntervalAfterWhichBatchSentAnyway)
// if err != nil {
Expand All @@ -44,7 +44,7 @@ func (pc *TxProfitabilityCheckerBase) IsProfitable(ctx context.Context, maticCol
// }
//}

return maticCollateral.Cmp(pc.MinReward) >= 0, nil
return polCollateral.Cmp(pc.MinReward) >= 0, nil
}

// TxProfitabilityCheckerAcceptAll validate batch anyway and don't check anything
Expand All @@ -62,7 +62,7 @@ func NewTxProfitabilityCheckerAcceptAll(state stateInterface, interval time.Dura
}

// IsProfitable validate batch anyway and don't check anything
func (pc *TxProfitabilityCheckerAcceptAll) IsProfitable(ctx context.Context, maticCollateral *big.Int) (bool, error) {
func (pc *TxProfitabilityCheckerAcceptAll) IsProfitable(ctx context.Context, polCollateral *big.Int) (bool, error) {
//if pc.IntervalAfterWhichBatchSentAnyway != 0 {
// ok, err := isConsolidatedBatchAppeared(ctx, pc.State, pc.IntervalAfterWhichBatchSentAnyway)
// if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func approveTokens(ctx *cli.Context) error {
return err
}

tx, err := etherman.ApproveMatic(ctx.Context, auth.From, amount, c.NetworkConfig.L1Config.ZkEVMAddr)
tx, err := etherman.ApprovePol(ctx.Context, auth.From, amount, c.NetworkConfig.L1Config.ZkEVMAddr)
if err != nil {
return err
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,7 @@ func runMigrations(c db.Config, name string) {
}

func newEtherman(c config.Config) (*etherman.Client, error) {
etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config)
if err != nil {
return nil, err
}
return etherman, nil
return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config)
}

func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerStorage *ethtxmanager.PostgresStorage, st *state.State, pool *pool.Pool, eventLog *event.EventLog) {
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func Test_Defaults(t *testing.T) {
expectedValue: common.HexToAddress("0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A"),
},
{
path: "NetworkConfig.L1Config.MaticAddr",
path: "NetworkConfig.L1Config.PolAddr",
expectedValue: common.HexToAddress("0x1319D23c2F7034F52Eb07399702B040bA278Ca49"),
},
{
Expand Down
Loading