Skip to content

Commit

Permalink
added aggregator address to prover input (0xPolygonHermez#1109)
Browse files Browse the repository at this point in the history
* added aggregator address to prover input

* fixing lint

* fixing lint
  • Loading branch information
Mikelle authored Aug 31, 2022
1 parent e5ebe60 commit d7ff1cb
Show file tree
Hide file tree
Showing 14 changed files with 3,604 additions and 2,051 deletions.
1 change: 1 addition & 0 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
BatchHashData: batchHashData.String(),
BatchNum: uint32(batchToVerify.BatchNumber),
EthTimestamp: uint64(batchToVerify.Timestamp.Unix()),
AggregatorAddr: a.Ethman.GetPublicAddress().String(),
},
GlobalExitRoot: batchToVerify.GlobalExitRoot.String(),
BatchL2Data: hex.EncodeToString(batchToVerify.BatchL2Data),
Expand Down
5 changes: 5 additions & 0 deletions aggregator/aggregator_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func TestBuildInputProver(t *testing.T) {
GlobalExitRoot: batchToVerify.GlobalExitRoot.String(),
BatchL2Data: hex.EncodeToString(batchL2Data),
}

etherman.On("GetPublicAddress").Return(common.HexToAddress("0x123"))
ip, err := a.buildInputProver(ctx, batchToVerify)
require.NoError(t, err)
require.NotNil(t, ip)
Expand Down Expand Up @@ -202,6 +204,7 @@ func TestAggregatorFlow(t *testing.T) {
oldLocalExitRoot = common.HexToHash("0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1")
newLocalExitRoot = common.HexToHash("0x40a885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9a0")
seqAddress = common.HexToAddress("0x123")
aggrAddress = common.HexToAddress("0x123")
verifiedBatch = &state.VerifiedBatch{BatchNumber: 1}
tx = *types.NewTransaction(1, common.HexToAddress("1"), big.NewInt(1), 0, big.NewInt(1), []byte("bbb"))
previousBatch = &state.Batch{
Expand All @@ -227,6 +230,7 @@ func TestAggregatorFlow(t *testing.T) {
SequencerAddr: seqAddress.String(),
BatchNum: uint32(batchToVerify.BatchNumber),
EthTimestamp: uint64(batchToVerify.Timestamp.Unix()),
AggregatorAddr: aggrAddress.String(),
},
GlobalExitRoot: batchToVerify.GlobalExitRoot.String(),
Db: map[string]string{},
Expand Down Expand Up @@ -259,6 +263,7 @@ func TestAggregatorFlow(t *testing.T) {
// isSynced
st.On("GetLastVerifiedBatch", mock.Anything, nil).Return(verifiedBatch, nil)
etherman.On("GetLatestVerifiedBatchNum").Return(uint64(1), nil)
etherman.On("GetPublicAddress").Return(aggrAddress)

lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(context.Background(), nil)
require.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions aggregator/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/0xPolygonHermez/zkevm-node/proverclient/pb"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/ethereum/go-ethereum/common"
"github.com/jackc/pgx/v4"
)

Expand All @@ -20,6 +21,7 @@ type ethTxManager interface {
// etherman contains the methods required to interact with ethereum
type etherman interface {
GetLatestVerifiedBatchNum() (uint64, error)
GetPublicAddress() common.Address
}

// aggregatorTxProfitabilityChecker interface for different profitability
Expand Down
21 changes: 20 additions & 1 deletion aggregator/mocks/mock_etherman.go

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

5 changes: 5 additions & 0 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ func (etherMan *Client) GetTrustedSequencerURL() (string, error) {
return etherMan.PoE.TrustedSequencerURL(&bind.CallOpts{Pending: false})
}

// GetPublicAddress returns eth client public address
func (etherMan *Client) GetPublicAddress() common.Address {
return etherMan.auth.From
}

// VerifyBatch function allows the aggregator send the proof for a batch and consolidate it
func (etherMan *Client) verifyBatch(opts *bind.TransactOpts, batchNumber uint64, resGetProof *pb.GetProofResponse) (*types.Transaction, error) {
publicInputs := resGetProof.Public.PublicInputs
Expand Down
Loading

0 comments on commit d7ff1cb

Please sign in to comment.