Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(taiko-client): check p2pSigner before gossiping #18981

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/taiko-client/driver/preconf_blocks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/rlp"
"github.com/holiman/uint256"
"github.com/labstack/echo/v4"
"github.com/modern-go/reflect2"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/utils"
Expand Down Expand Up @@ -188,7 +189,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {

// Propagate the preconfirmation block to the P2P network, if the current server
// connects to the P2P network.
if s.p2pNode != nil {
if s.p2pNode != nil && !reflect2.IsNil(s.p2pSigner) {
log.Info("Gossiping L2 Payload", "blockID", header.Number.Uint64(), "time", header.Time)

var u256 uint256.Int
Expand Down Expand Up @@ -220,6 +221,19 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
log.Warn("Failed to propagate the preconfirmation block to the P2P network", "error", err)
}
}
} else {
log.Info(
"P2P network / signer is disabled, skip propagating the preconfirmation block",
"blockID", header.Number,
"hash", header.Hash(),
"coinbase", header.Coinbase.Hex(),
"timestamp", header.Time,
"gasLimit", header.GasLimit,
"gasUsed", header.GasUsed,
"mixDigest", common.Bytes2Hex(header.MixDigest[:]),
"extraData", common.Bytes2Hex(header.Extra),
"baseFee", utils.WeiToEther(header.BaseFee),
)
}

return c.JSON(http.StatusOK, BuildPreconfBlockResponseBody{BlockHeader: header})
Expand Down
Loading