Skip to content

Commit

Permalink
included l1 info tree hash in api request
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Feb 3, 2025
1 parent bf0046e commit f1c0917
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ packages:
github.com/agglayer/aggkit/aggsender/db:
config:
all: true
github.com/agglayer/aggkit/aggsender/grpc:
config:
all: true
github.com/agglayer/aggkit/aggsender/rpc:
config:
all: true
Expand Down
11 changes: 7 additions & 4 deletions aggsender/grpc/aggchain_proof_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"time"

"github.com/agglayer/aggkit/aggsender/types"
"github.com/ethereum/go-ethereum/common"
)

const TIMEOUT = 2

// AggchainProofClientInterface defines an interface for aggchain proof client
type AggchainProofClientInterface interface {
GenerateAggchainProof(startBlock uint64, maxEndBlock uint64) (*types.AggchainProof, error)
GenerateAggchainProof(startBlock uint64, maxEndBlock uint64, l1infoTreeHash common.Hash) (*types.AggchainProof, error)
}

// AggchainProofClient provides an implementation for the AggchainProofClient interface
Expand All @@ -31,17 +32,19 @@ func NewAggchainProofClient(serverAddr string) (*AggchainProofClient, error) {
}

func (c *AggchainProofClient) GenerateAggchainProof(startBlock uint64,
maxEndBlock uint64) (*types.AggchainProof, error) {
maxEndBlock uint64, l1infoTreeHash common.Hash) (*types.AggchainProof, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*TIMEOUT)
defer cancel()

resp, err := c.client.GenerateAggchainProof(ctx, &types.GenerateAggchainProofRequest{
StartBlock: startBlock,
MaxEndBlock: maxEndBlock,
StartBlock: startBlock,
MaxEndBlock: maxEndBlock,
L1InfoTreeHash: l1infoTreeHash.Bytes(),
})
if err != nil {
return nil, err
}

return &types.AggchainProof{
Proof: string(resp.AggchainProof),
StartBlock: resp.StartBlock,
Expand Down
15 changes: 9 additions & 6 deletions aggsender/grpc/aggchain_proof_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/agglayer/aggkit/aggsender/mocks"
"github.com/agglayer/aggkit/aggsender/types"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand All @@ -26,11 +27,12 @@ func TestGenerateAggchainProof_Success(t *testing.T) {
}

mockClient.On("GenerateAggchainProof", mock.Anything, &types.GenerateAggchainProofRequest{
StartBlock: 100,
MaxEndBlock: 200,
StartBlock: 100,
MaxEndBlock: 200,
L1InfoTreeHash: []byte{},
}).Return(expectedResponse, nil)

result, err := client.GenerateAggchainProof(100, 200)
result, err := client.GenerateAggchainProof(100, 200, common.Hash{})

assert.NoError(t, err)
assert.Equal(t, "dummy-proof", result.Proof)
Expand All @@ -46,11 +48,12 @@ func TestGenerateAggchainProof_Error(t *testing.T) {
expectedError := errors.New("Generate error")

mockClient.On("GenerateAggchainProof", mock.Anything, &types.GenerateAggchainProofRequest{
StartBlock: 300,
MaxEndBlock: 400,
StartBlock: 300,
MaxEndBlock: 400,
L1InfoTreeHash: []byte{},
}).Return((*types.GenerateAggchainProofResponse)(nil), expectedError)

result, err := client.GenerateAggchainProof(300, 400)
result, err := client.GenerateAggchainProof(300, 400, common.Hash{})

assert.Error(t, err)
assert.Nil(t, result)
Expand Down
98 changes: 98 additions & 0 deletions aggsender/mocks/mock_aggchain_proof_client_interface.go

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

2 changes: 2 additions & 0 deletions aggsender/proto/aggsender.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ message GenerateAggchainProofRequest {
uint64 start_block = 1;
// The max end block for which the aggchain proof is requested.
uint64 max_end_block = 2;
// L1 Info tree hash for the nearest finalized block.
bytes l1info_tree_hash = 3;
}

// The aggchain proof response message.
Expand Down
70 changes: 41 additions & 29 deletions aggsender/types/aggsender.pb.go

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

0 comments on commit f1c0917

Please sign in to comment.