Skip to content

Commit

Permalink
Merge tag 'v0.5.0-beta6' into vui-chee/basedev-upstream-v0.5.0-beta6
Browse files Browse the repository at this point in the history
* tag 'v0.5.0-beta6':
  feat: write on database the number of retries per certificate and the certificates in a history table (0xPolygon#208)
  feat: return an error in case agglayer returns certificate with height lower than in local storage (0xPolygon#209)
  chore: simplify the `HashMeddler` (0xPolygon#205)
  fix: clean proof table on start (0xPolygon#207) (0xPolygon#210)
  feat: improve logs (0xPolygon#204)
  fix: cdk603 error calculating previousLocalExitRoot (0xPolygon#199)
  fix: Integration Bali PP (0xPolygon#198)
  feat: check agglayer certificate and use as initial if db is empty (0xPolygon#192)
  feat: sqlite aggregator (0xPolygon#189)
  feat: BridgeMessage e2e test (0xPolygon#184)
  feat: aggsender e2e (0xPolygon#183)
  fix: aggregating proofs (0xPolygon#191) (0xPolygon#193)
  feat: l1infotreesync can be run as individual component (0xPolygon#188)
  fix: l1infotree flaky test (0xPolygon#182)
  fix: `L1InfoRootIncorrect` error from `agglayer` (0xPolygon#185)
  feat: improve aggsender logs (0xPolygon#186) (0xPolygon#187)
  feat: remove sanity check (0xPolygon#178) (0xPolygon#179)
  refact: GetSequence method (0xPolygon#169)
  feat: epoch notifier (0xPolygon#144)
  feat: unpack and log agglayer errors (0xPolygon#158)
  • Loading branch information
Vui-Chee committed Dec 3, 2024
2 parents 4b088c7 + f792176 commit 83a3e9e
Show file tree
Hide file tree
Showing 97 changed files with 4,557 additions and 1,908 deletions.
43 changes: 13 additions & 30 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- "fork11-rollup"
- "fork12-validium"
- "fork12-rollup"
- "fork12-pessimistic"
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -32,26 +33,17 @@ jobs:

- name: Build Docker
run: make build-docker

# this is better to get the action in
- name: Install kurtosis
shell: bash
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli=1.4.1
kurtosis version
- name: Disable kurtosis analytics
shell: bash
run: kurtosis analytics disable

- name: Install yq
shell: bash
run: |
pip3 install yq
yq --version

- name: Checkout kurtosis-cdk
uses: actions/checkout@v4
with:
repository: 0xPolygon/kurtosis-cdk
path: kurtosis-cdk
ref: v0.2.24

- name: Install Kurtosis CDK tools
uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk

- name: Install polycli
run: |
POLYCLI_VERSION="${{ vars.POLYCLI_VERSION }}"
Expand All @@ -62,16 +54,6 @@ jobs:
sudo chmod +x /usr/local/bin/polycli
/usr/local/bin/polycli version
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1

- name: checkout kurtosis-cdk
uses: actions/checkout@v4
with:
repository: 0xPolygon/kurtosis-cdk
path: "kurtosis-cdk"
ref: "v0.2.19"

- name: Setup Bats and bats libs
uses: bats-core/bats-action@2.0.0

Expand All @@ -81,6 +63,7 @@ jobs:
env:
KURTOSIS_FOLDER: ${{ github.workspace }}/kurtosis-cdk
BATS_LIB_PATH: /usr/lib/
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}

- name: Dump enclave logs
if: failure()
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/test-resequence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
path: cdk

- name: Checkout kurtosis-cdk
- name: Checkout cdk-erigon
uses: actions/checkout@v4
with:
repository: 0xPolygonHermez/cdk-erigon
Expand All @@ -34,21 +34,12 @@ jobs:
uses: actions/checkout@v4
with:
repository: 0xPolygon/kurtosis-cdk
ref: a7a80b7b5d98a69a23415ab0018e556257a6dfb6
path: kurtosis-cdk
ref: v0.2.24

- name: Install Kurtosis CDK tools
uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install yq
run: |
sudo curl -L https://github.com/mikefarah/yq/releases/download/v4.44.2/yq_linux_amd64 -o /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq
/usr/local/bin/yq --version
- name: Install polycli
run: |
POLYCLI_VERSION="${{ vars.POLYCLI_VERSION }}"
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ RUN make build-go
# CONTAINER FOR RUNNING BINARY
FROM --platform=${BUILDPLATFORM} debian:bookworm-slim

RUN apt-get update && apt-get install -y ca-certificates postgresql-client libssl-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y ca-certificates sqlite3 procps libssl-dev && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/cdk /usr/local/bin/
COPY --from=build /go/src/github.com/0xPolygon/cdk/target/cdk-node /usr/local/bin/

CMD ["/bin/sh", "-c", "cdk"]
22 changes: 22 additions & 0 deletions agglayer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type AgglayerClientInterface interface {
WaitTxToBeMined(hash common.Hash, ctx context.Context) error
SendCertificate(certificate *SignedCertificate) (common.Hash, error)
GetCertificateHeader(certificateHash common.Hash) (*CertificateHeader, error)
GetLatestKnownCertificateHeader(networkID uint32) (*CertificateHeader, error)
AggLayerClientGetEpochConfiguration
}

Expand Down Expand Up @@ -158,3 +159,24 @@ func (c *AggLayerClient) GetEpochConfiguration() (*ClockConfiguration, error) {

return result, nil
}

// GetLatestKnownCertificateHeader returns the last certificate header submitted by networkID
func (c *AggLayerClient) GetLatestKnownCertificateHeader(networkID uint32) (*CertificateHeader, error) {
response, err := jSONRPCCall(c.url, "interop_getLatestKnownCertificateHeader", networkID)
if err != nil {
return nil, fmt.Errorf("GetLatestKnownCertificateHeader error jSONRPCCall. Err: %w", err)
}

if response.Error != nil {
return nil, fmt.Errorf("GetLatestKnownCertificateHeader rpc returns an error: code=%d msg=%s",
response.Error.Code, response.Error.Message)
}

var result *CertificateHeader
err = json.Unmarshal(response.Result, &result)
if err != nil {
return nil, fmt.Errorf("GetLatestKnownCertificateHeader error Unmashal. Err: %w", err)
}

return result, nil
}
89 changes: 88 additions & 1 deletion agglayer/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/0xPolygon/cdk-rpc/rpc"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)

Expand All @@ -14,11 +15,40 @@ const (

func TestExploratoryClient(t *testing.T) {
t.Skip("This test is for exploratory purposes only")
sut := NewAggLayerClient("http://127.0.0.1:32853")
sut := NewAggLayerClient("http://127.0.0.1:32781")
config, err := sut.GetEpochConfiguration()
require.NoError(t, err)
require.NotNil(t, config)
fmt.Printf("Config: %s", config.String())

lastCert, err := sut.GetLatestKnownCertificateHeader(1)
require.NoError(t, err)
require.NotNil(t, lastCert)
fmt.Printf("LastCert: %s", lastCert.String())
}

func TestExploratoryGetCertificateHeader(t *testing.T) {
t.Skip("This test is exploratory and should be skipped")
aggLayerClient := NewAggLayerClient("http://localhost:32796")
certificateID := common.HexToHash("0xf153e75e24591432ac5deafaeaafba3fec0fd851261c86051b9c0d540b38c369")
certificateHeader, err := aggLayerClient.GetCertificateHeader(certificateID)
require.NoError(t, err)
fmt.Print(certificateHeader)
}
func TestExploratoryGetEpochConfiguration(t *testing.T) {
t.Skip("This test is exploratory and should be skipped")
aggLayerClient := NewAggLayerClient("http://localhost:32796")
clockConfig, err := aggLayerClient.GetEpochConfiguration()
require.NoError(t, err)
fmt.Print(clockConfig)
}

func TestExploratoryGetLatestKnownCertificateHeader(t *testing.T) {
t.Skip("This test is exploratory and should be skipped")
aggLayerClient := NewAggLayerClient("http://localhost:32843")
cert, err := aggLayerClient.GetLatestKnownCertificateHeader(1)
require.NoError(t, err)
fmt.Print(cert)
}

func TestGetEpochConfigurationResponseWithError(t *testing.T) {
Expand Down Expand Up @@ -74,3 +104,60 @@ func TestGetEpochConfigurationOkResponse(t *testing.T) {
GenesisBlock: 1,
}, *clockConfig)
}

func TestGetLatestKnownCertificateHeaderOkResponse(t *testing.T) {
sut := NewAggLayerClient(testURL)
response := rpc.Response{
Result: []byte(`{"network_id":1,"height":0,"epoch_number":223,"certificate_index":0,"certificate_id":"0xf9179d2fbe535814b5a14496e2eed474f49c6131227a9dfc5d2d8caf9e212054","new_local_exit_root":"0x7ae06f4a5d0b6da7dd4973fb6ef40d82c9f2680899b3baaf9e564413b59cc160","metadata":"0x00000000000000000000000000000000000000000000000000000000000001a7","status":"Settled"}`),
}
jSONRPCCall = func(url, method string, params ...interface{}) (rpc.Response, error) {
return response, nil
}
cert, err := sut.GetLatestKnownCertificateHeader(1)
require.NotNil(t, cert)
require.NoError(t, err)
require.Nil(t, cert.PreviousLocalExitRoot)
}

func TestGetLatestKnownCertificateHeaderErrorResponse(t *testing.T) {
sut := NewAggLayerClient(testURL)
jSONRPCCall = func(url, method string, params ...interface{}) (rpc.Response, error) {
return rpc.Response{}, fmt.Errorf("unittest error")
}

cert, err := sut.GetLatestKnownCertificateHeader(1)

require.Nil(t, cert)
require.Error(t, err)
}

func TestGetLatestKnownCertificateHeaderResponseBadJson(t *testing.T) {
sut := NewAggLayerClient(testURL)
response := rpc.Response{
Result: []byte(`{`),
}
jSONRPCCall = func(url, method string, params ...interface{}) (rpc.Response, error) {
return response, nil
}

cert, err := sut.GetLatestKnownCertificateHeader(1)

require.Nil(t, cert)
require.Error(t, err)
}

func TestGetLatestKnownCertificateHeaderWithPrevLERResponse(t *testing.T) {
sut := NewAggLayerClient(testURL)
response := rpc.Response{
Result: []byte(`{"network_id":1,"height":0,"epoch_number":223,"certificate_index":0,"certificate_id":"0xf9179d2fbe535814b5a14496e2eed474f49c6131227a9dfc5d2d8caf9e212054","prev_local_exit_root":"0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757","new_local_exit_root":"0x7ae06f4a5d0b6da7dd4973fb6ef40d82c9f2680899b3baaf9e564413b59cc160","metadata":"0x00000000000000000000000000000000000000000000000000000000000001a7","status":"Settled"}`),
}
jSONRPCCall = func(url, method string, params ...interface{}) (rpc.Response, error) {
return response, nil
}
cert, err := sut.GetLatestKnownCertificateHeader(1)

require.NoError(t, err)
require.NotNil(t, cert)

require.Equal(t, "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757", cert.PreviousLocalExitRoot.String())
}
58 changes: 58 additions & 0 deletions agglayer/mock_agglayer_client.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"expected_error": "value of key leaf_count is not of type uint32",
"certificate_header": "{\"network_id\":1,\"height\":6,\"epoch_number\":null,\"certificate_index\":null,\"certificate_id\":\"0xa80cd4abb016bbb3c3058f923a88be1ad49d68277366c55554d6f13d62428a1f\",\"new_local_exit_root\":\"0x566244fbf813b6926f6895142979f61ed6706184909cb8c819cd0216202a8aa9\",\"metadata\":\"0x000000000000000000000000000000000000000000000000000000000000001f\",\"status\":{\"InError\":{\"error\":{\"TypeConversionError\":{\"L1InfoRootIncorrect\":{\"leaf_count\":\"invalid\",\"declared\":\"0x566244fbf813b6926f6895142979f61ed6706184909cb8c819cd0216202a8aa9\",\"retrieved\":\"0xa80cd4abb016bbb3c3058f923a88be1ad49d68277366c55554d6f13d62428a1f\"}}}}}}"
}
]
]
Loading

0 comments on commit 83a3e9e

Please sign in to comment.