Skip to content

Commit

Permalink
Alpha6 test fix (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx authored Dec 18, 2024
1 parent fbcc28b commit 92a97b3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-integration-erigon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
os:
- ubuntu-22.04
- macos-14
- ubuntu-latest-erigontests-large
# - ubuntu-latest-erigontests-large
runs-on: ${{ matrix.os }}

steps:
Expand Down
3 changes: 2 additions & 1 deletion erigon-lib/kv/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ var ConsensusTables = append([]string{
},
ChaindataTables..., //TODO: move bor tables from chaintables to `ConsensusTables`
)

var HeimdallTables = []string{}
var PolygonBridgeTables = []string{}
var DownloaderTables = []string{
Expand Down Expand Up @@ -631,7 +632,7 @@ var ReconTablesCfg = TableCfg{

func TablesCfgByLabel(label Label) TableCfg {
switch label {
case ChainDB, TemporaryDB, CaplinDB: //TODO: move caplindb tables to own table config
case ChainDB, TemporaryDB, CaplinDB, BlobDb: //TODO: move caplindb tables to own table config
return ChaindataTablesCfg
case TxPoolDB:
return TxpoolTablesCfg
Expand Down
19 changes: 19 additions & 0 deletions p2p/sentry/eth_handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ func readAndValidatePeerStatusMessage(
return reply, nil
}

func readUpgradeStatusMsg(rw p2p.MsgReadWriter, status *eth.UpgradeStatusPacket) *p2p.PeerError {
msg, err := rw.ReadMsg()
if err != nil {
return p2p.NewPeerError(p2p.PeerErrorStatusReceive, p2p.DiscNetworkError, err, "readUpgradeStatusMsg rw.ReadMsg error")
}
if msg.Code != eth.UpgradeStatusMsg {
return p2p.NewPeerError(p2p.PeerErrorStatusReceive, p2p.DiscNetworkError, err, "readUpgradeStatusMsg: upgrade status msg code != UpgradeStatusMsg")
}

if msg.Size > eth.ProtocolMaxMsgSize {
return p2p.NewPeerError(p2p.PeerErrorStatusReceive, p2p.DiscNetworkError, fmt.Errorf("message is too large %d, limit %d", msg.Size, eth.ProtocolMaxMsgSize), "readUpgradeStatusMsg too large")
}

if err := msg.Decode(&status); err != nil {
return p2p.NewPeerError(p2p.PeerErrorStatusReceive, p2p.DiscNetworkError, err, "readUpgradeStatusMsg DecodeUpgradeStatusMsg error")
}
return nil
}

func tryDecodeStatusMessage(msg *p2p.Msg) (*eth.StatusPacket, error) {
if msg.Code != eth.StatusMsg {
return nil, fmt.Errorf("first msg has code %x (!= %x)", msg.Code, eth.StatusMsg)
Expand Down
33 changes: 22 additions & 11 deletions p2p/sentry/sentry_grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ func handShake(
return nil, p2p.NewPeerError(p2p.PeerErrorDiscReason, p2p.DiscQuitting, ctx.Err(), "sentry.handShake ctx.Done")
}
}
if version >= direct.ETH67 {
if version >= direct.ETH68 {
var upgradeStatus eth.UpgradeStatusPacket
extensionRaw, err := (&eth.UpgradeStatusExtension{}).Encode()
if err != nil {
return nil, p2p.NewPeerError(p2p.PeerErrorStatusDecode, p2p.DiscIncompatibleVersion, err, "")
Expand All @@ -368,17 +369,27 @@ func handShake(
errChan <- p2p.NewPeerError(p2p.PeerErrorStatusDecode, p2p.DiscNetworkError, err, "sentry.handShake failed to send bsc UpgradeStatusMsg")
}
}()
//todo: receive UpgradeStatus from bsc and set txBroadcast
// go func() {
// errc <- p.readUpgradeStatus(&upgradeStatus)
// }()
select {
case err := <-errChan:
if err != nil {
return nil, err

go func() {
err := readUpgradeStatusMsg(rw, &upgradeStatus)
if err == nil {
errChan <- nil
} else {
errChan <- p2p.NewPeerError(p2p.PeerErrorStatusDecode, p2p.DiscNetworkError, err, "sentry.handShake failed to send bsc UpgradeStatusMsg")
}
}()

timeout := time.NewTimer(handshakeTimeout)
defer timeout.Stop()
for i := 0; i < 2; i++ {
select {
case err := <-errChan:
if err != nil {
return nil, err
}
case <-timeout.C:
return nil, p2p.NewPeerError(p2p.PeerErrorStatusHandshakeTimeout, p2p.DiscReadTimeout, nil, "sentry.UpgradeStatusMsg timeout")
}
case <-timeout.C:
return nil, p2p.NewPeerError(p2p.PeerErrorStatusHandshakeTimeout, p2p.DiscReadTimeout, nil, "sentry.handShake send bsc UpgradeStatusMsg timeout")
}
}
peerStatus := <-resultChan
Expand Down
4 changes: 2 additions & 2 deletions p2p/sentry/sentry_grpc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func startHandshake(

// Tests that peers are correctly accepted (or rejected) based on the advertised
// fork IDs in the protocol handshake.
func TestForkIDSplit67(t *testing.T) { testForkIDSplit(t, direct.ETH67) }
func TestForkIDSplit68(t *testing.T) { testForkIDSplit(t, direct.ETH68) }

func testForkIDSplit(t *testing.T, protocol uint) {
var (
Expand Down Expand Up @@ -178,7 +178,7 @@ func testForkIDSplit(t *testing.T, protocol uint) {
t.Fatalf("fork ID rejection didn't happen")
}
}
case <-time.After(250 * time.Millisecond):
case <-time.After(10000 * time.Millisecond):
t.Fatalf("split peers not rejected")
}
}
Expand Down
2 changes: 1 addition & 1 deletion turbo/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var (
Full: Keep only blocks and latest state,
Archive: Keep the entire indexed database, aka. no pruning,
Minimal: Keep only latest state`,
Value: "full",
Value: "archive",
}
PruneDistanceFlag = cli.Uint64Flag{
Name: "prune.distance",
Expand Down

0 comments on commit 92a97b3

Please sign in to comment.