0xPolygon / polygon-edge

A Framework for Building Ethereum-compatible Blockchain Networks
https://polygon.technology/solutions/polygon-edge/
Apache License 2.0
1.01k stars 527 forks source link

Checkpoint Submission stopped saying INVALID_EPOCH #2206

Closed kr-advait closed 1 week ago

kr-advait commented 1 week ago

Checkpoint submission stopped INVALID_EPOCH

We are running polygon supernet from past 3 months and chain was working fine until 6 days ago, out of nowhere, checkpoint submission have been stopped. According to what i feel, one of the checkpoint was missed to be submitted due to some reason which created this gap between checkpoint in blockchain as it moved ahead with other blocks and checkpoint manager contract left behind.

Now the error i am facing is INVALID_EPOCH from checkpoint manager contract and that requires checkpoint to be either same or current epoch + 1. I have tried debugging and have added logs and i can see that when it goes to send pending checkpoints the epoch is current epoch on contract + 1.

eg : Current epoch on contract = 29660, so supernet is trying to send checkpoint for epoch = 29661

but still getting error INVALID_EPOCH

Your environment

Steps to reproduce

Expected behavior

Logs

2024-09-18T11:18:39.242Z [DEBUG] polygon.server.polybft.consensus_runtime: on block inserted already handled: current=3836289 block=3836289 2024-09-18T11:18:39.369Z [DEBUG] polygon.server.polybft: validator message received: type=PREPARE height=3836289 round=0 addr=0x0B9aC1dc962e2a1131eaF05Fc103222f9b71409f 2024-09-18T11:18:39.369Z [DEBUG] polygon.server.polybft: validator message received: type=COMMIT height=3836289 round=0 addr=0x0B9aC1dc962e2a1131eaF05Fc103222f9b71409f 2024-09-18T11:18:39.370Z [DEBUG] polygon.server.polybft: validator message received: type=COMMIT height=3836289 round=0 addr=0x0B9aC1dc962e2a1131eaF05Fc103222f9b71409f 2024-09-18T11:18:39.370Z [DEBUG] polygon.server.polybft: validator message received: type=PREPARE height=3836289 round=0 addr=0x0B9aC1dc962e2a1131eaF05Fc103222f9b71409f 2024-09-18T11:18:39.545Z [DEBUG] polygon.server.polybft.checkpoint_manager: submitCheckpoint invoked...: latest checkpoint block=3766820 checkpoint block=3836289

[Encode & Send Checkpoint for Epoch] : 29661

2024-09-18T11:18:39.926Z [DEBUG] polygon.server.polybft.checkpoint_manager: send checkpoint txn...: block number=3766947

[Submit Checkpoint for BlockNumber] : 3766947

[Submit Checkpoint for Epoch] : 29661

[Sending Transaction For currentExtra Epoch from address 0xa31110B4c8A7d0eDBc4269B4a5d21F3C71CC711a] : 29661

[Sending Transaction For param Extra Epoch from address 0xa31110B4c8A7d0eDBc4269B4a5d21F3C71CC711a] : 29661

[Error in Sending Epoch To Polygon] : failed to estimate gas: {"code":3,"message":"execution reverted: INVALID_EPOCH","data":"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d494e56414c49445f45504f434800000000000000000000000000000000000000"}

2024-09-18T11:18:40.448Z [WARN] polygon.server.polybft.checkpoint_manager: failed to submit checkpoint: checkpoint block=3836289 epoch number=30207 error="failed to estimate gas: {\"code\":3,\"message\":\"execution reverted: INVALID_EPOCH\",\"data\":\"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d494e56414c49445f45504f434800000000000000000000000000000000000000\"}"

kr-advait commented 1 week ago

Fixed the issue!

I believe the main issue is with estimate gas in send transaction.

Here is the fix :

Location : txrelayer / txrelayer.go => sendTransactionLocked() function


Replace below code :

image

with this code :

image