Skip to content

Commit

Permalink
updated prev block hash ugly patch
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Feb 2, 2024
1 parent 8237654 commit 80f51df
Showing 1 changed file with 40 additions and 42 deletions.
82 changes: 40 additions & 42 deletions block/fetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (f *RPCFetcher) Fetch(ctx context.Context, requestedSlot uint64) (out *pbbs
return nil, true, nil
}

block, err := blockFromBlockResult(requestedSlot, f.latestFinalizedSlot, blockResult)
block, err := blockFromBlockResult(requestedSlot, f.latestFinalizedSlot, blockResult, f.logger)
if err != nil {
return nil, false, fmt.Errorf("decoding block %d: %w", requestedSlot, err)
}
Expand Down Expand Up @@ -139,14 +139,14 @@ func (f *RPCFetcher) fetch(ctx context.Context, requestedSlot uint64) (*rpc.GetB
return out, skipped, err
}

func blockFromBlockResult(slot uint64, finalizedSlot uint64, result *rpc.GetBlockResult) (*pbbstream.Block, error) {
func blockFromBlockResult(slot uint64, finalizedSlot uint64, result *rpc.GetBlockResult, logger *zap.Logger) (*pbbstream.Block, error) {
libNum := finalizedSlot

if finalizedSlot > slot {
libNum = result.ParentSlot
}

fixedPreviousBlockHash := fixPreviousBlockHash(result)
fixedPreviousBlockHash := fixPreviousBlockHash(result, logger)

transactions, err := toPbTransactions(result.Transactions)
if err != nil {
Expand Down Expand Up @@ -198,46 +198,44 @@ func blockFromBlockResult(slot uint64, finalizedSlot uint64, result *rpc.GetBloc

}

func fixPreviousBlockHash(blockResult *rpc.GetBlockResult) (previousFixedBlockHash string) {
switch blockResult.Blockhash.String() {
case "Goi3t9JjgDkyULZbM2TzE5QqHP1fPeMcHNaXNFBCBv1v":
//zlogger.Warn("applying horrible tweak to block Goi3t9JjgDkyULZbM2TzE5QqHP1fPeMcHNaXNFBCBv1v")
if blockResult.PreviousBlockhash.String() == "11111111111111111111111111111111" {
previousFixedBlockHash = "HQEr9qcbUVBt2okfu755FdJvJrPYTSpzzmmyeWTj5oau"
return previousFixedBlockHash
}
case "6UFQveZ94DUKGbcLFoyayn1QwthVfD3ZqvrM2916pHCR":
//zlogger.Warn("applying horrible tweak to block 63,072,071")
if blockResult.PreviousBlockhash.String() == "11111111111111111111111111111111" {
previousFixedBlockHash = "7cLQx2cZvyKbGoMuutXEZ3peg3D21D5qbX19T5V1XEiK"
return previousFixedBlockHash
}
case "Fqbm7QvCTYnToXWcCw6nbkWhMmXx2Nv91LsXBrKraB43":
//zlogger.Warn("applying horrible tweak to block 53,135,959")
if previousFixedBlockHash == "11111111111111111111111111111111" {
previousFixedBlockHash = "RfXUrekgajPSb1R4CGFJWNaHTnB6p53Tzert4gouj2u"
return previousFixedBlockHash
}
case "ABp9G2NaPzM6kQbeyZYCYgdzL8JN9AxSSbCQG2X1K9UF":
//zlogger.Warn("applying horrible tweak to block 46,223,993")
if previousFixedBlockHash == "11111111111111111111111111111111" {
previousFixedBlockHash = "9F2C7TGqUpFu6krd8vQbUv64BskrneBSgY7U2QfrGx96"
return previousFixedBlockHash
}
case "ByUxmGuaT7iQS9qGS8on5xHRjiHXcGxvwPPaTGZXQyz7":
//zlogger.Warn("applying horrible tweak to block 61,328,766")
if previousFixedBlockHash == "11111111111111111111111111111111" {
previousFixedBlockHash = "J6rRToKMK5DQDzVLqo7ibL3snwBYtqkYnRnQ7vXoUSEc"
return previousFixedBlockHash
}
case "2TLDT6Z3WJ5h5958BjdzMwmNGnVo3e4qcHyGBVgBPDm9":
//zlogger.Warn("applying horrible tweak to block 61,328,766")
if previousFixedBlockHash == "11111111111111111111111111111111" {
previousFixedBlockHash = "FCgBdK9Fufcsdc9RGu5SwMwbCFiw4SxNnJzCpZTdNpDq"
return previousFixedBlockHash
}
}
var blockToPatch = map[string]string{
"2TLDT6Z3WJ5h5958BjdzMwmNGnVo3e4qcHyGBVgBPDm9": "FCgBdK9Fufcsdc9RGu5SwMwbCFiw4SxNnJzCpZTdNpDq",
"AACrVjKzuvTLxmjC7Ktn5St1GkFHd9smvNHDf2dCPF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eMcHNaXNFBCBv1v": "HQEr9qcbUVBt2okfu755FdJvJrPYTSpzzmmyeWTj5oau",
"6UFQveZ94DUKGbcLFoyayn1QwthVfD3ZqvrM2916pHCR": "7cLQx2cZvyKbGoMuutXEZ3peg3D21D5qbX19T5V1XEiK",
"Fqbm7QvCTYnToXWcCw6nbkWhMmXx2Nv91LsXBrKraB43": "RfXUrekgajPSb1R4CGFJWNaHTnB6p53Tzert4gouj2u",
"ABp9G2NaPzM6kQbeyZYCYgdzL8JN9AxSSbCQG2X1K9UF": "9F2C7TGqUpFu6krd8vQbUv64BskrneBSgY7U2QfrGx96",
"ByUxmGuaT7iQS9qGS8on5xHRjiHXcGxvwPPaTGZXQyz7": "J6rRToKMK5DQDzVLqo7ibL3snwBYtqkYnRnQ7vXoUSEc",
}

func fixPreviousBlockHash(blockResult *rpc.GetBlockResult, logger *zap.Logger) (previousFixedBlockHash string) {
if prev, ok := blockToPatch[blockResult.Blockhash.String()]; ok {
logger.Info("patching previous block hash", zap.String("block_hash", blockResult.Blockhash.String()), zap.String("previous_block_hash", prev))
return prev

}
return blockResult.PreviousBlockhash.String()
}

Expand Down

0 comments on commit 80f51df

Please sign in to comment.