From 8b73cfdbab4dfa4a13a2d48ab0a4b196ac43732c Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Mon, 15 Jan 2024 16:17:04 -0500 Subject: [PATCH] Adding StackHeight handling and fixPreviousBlockHash func --- block/fetcher/rpc.go | 76 ++++++++++++++++++++++++-------------------- go.mod | 2 +- go.sum | 1 + 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/block/fetcher/rpc.go b/block/fetcher/rpc.go index 87c386c8..7d129889 100644 --- a/block/fetcher/rpc.go +++ b/block/fetcher/rpc.go @@ -99,36 +99,7 @@ func blockFromBlockResult(requestedSlot uint64, confirmedSlot uint64, finalizedS libNum = result.ParentSlot } - //todo: //horrible tweaks - // switch blk.Blockhash { - // case "Goi3t9JjgDkyULZbM2TzE5QqHP1fPeMcHNaXNFBCBv1v": - // zlogger.Warn("applying horrible tweak to block Goi3t9JjgDkyULZbM2TzE5QqHP1fPeMcHNaXNFBCBv1v") - // if blk.PreviousBlockhash == "11111111111111111111111111111111" { - // blk.PreviousBlockhash = "HQEr9qcbUVBt2okfu755FdJvJrPYTSpzzmmyeWTj5oau" - // } - // case "6UFQveZ94DUKGbcLFoyayn1QwthVfD3ZqvrM2916pHCR": - // zlogger.Warn("applying horrible tweak to block 63,072,071") - // if blk.PreviousBlockhash == "11111111111111111111111111111111" { - // blk.PreviousBlockhash = "7cLQx2cZvyKbGoMuutXEZ3peg3D21D5qbX19T5V1XEiK" - // } - // case "Fqbm7QvCTYnToXWcCw6nbkWhMmXx2Nv91LsXBrKraB43": - // zlogger.Warn("applying horrible tweak to block 53,135,959") - // if blk.PreviousBlockhash == "11111111111111111111111111111111" { - // blk.PreviousBlockhash = "RfXUrekgajPSb1R4CGFJWNaHTnB6p53Tzert4gouj2u" - // } - // case "ABp9G2NaPzM6kQbeyZYCYgdzL8JN9AxSSbCQG2X1K9UF": - // zlogger.Warn("applying horrible tweak to block 46,223,993") - // if blk.PreviousBlockhash == "11111111111111111111111111111111" { - // blk.PreviousBlockhash = "9F2C7TGqUpFu6krd8vQbUv64BskrneBSgY7U2QfrGx96" - // } - // case "ByUxmGuaT7iQS9qGS8on5xHRjiHXcGxvwPPaTGZXQyz7": - // zlogger.Warn("applying horrible tweak to block 61,328,766") - // if blk.PreviousBlockhash == "11111111111111111111111111111111" { - // blk.PreviousBlockhash = "J6rRToKMK5DQDzVLqo7ibL3snwBYtqkYnRnQ7vXoUSEc" - // } - // } - - //todo: horrible tweaks validate parent slot number + fixedPreviousBlockHash := fixPreviousBlockHash(result) transactions, err := toPbTransactions(result.Transactions) if err != nil { @@ -136,7 +107,7 @@ func blockFromBlockResult(requestedSlot uint64, confirmedSlot uint64, finalizedS } block := &pbsol.Block{ PreviousBlockhash: result.PreviousBlockhash.String(), - Blockhash: result.Blockhash.String(), + Blockhash: fixedPreviousBlockHash, ParentSlot: result.ParentSlot, Transactions: transactions, Rewards: toPBReward(result.Rewards), @@ -155,7 +126,7 @@ func blockFromBlockResult(requestedSlot uint64, confirmedSlot uint64, finalizedS pbBlock := &pbbstream.Block{ Number: requestedSlot, Id: result.Blockhash.String(), - ParentId: result.PreviousBlockhash.String(), + ParentId: fixedPreviousBlockHash, Timestamp: timestamppb.New(result.BlockTime.Time()), LibNum: libNum, ParentNum: result.ParentSlot, @@ -166,6 +137,43 @@ func blockFromBlockResult(requestedSlot uint64, confirmedSlot uint64, finalizedS } +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 + } + } + + return blockResult.PreviousBlockhash.String() +} + func toPbTransactions(transactions []rpc.TransactionWithMeta) (out []*pbsol.ConfirmedTransaction, err error) { for _, transaction := range transactions { meta, err := toPbTransactionMeta(transaction.Meta) @@ -303,7 +311,7 @@ func compileInstructionsToPbInnerInstructionArray(instructions []solana.Compiled ProgramIdIndex: uint32(compiledInstruction.ProgramIDIndex), Accounts: accounts, Data: compiledInstruction.Data, - StackHeight: nil, //not return by the rpc endpoint getBlockCall //todo: check if it part of bigtable data + StackHeight: &compiledInstruction.StackHeight, //not return by the rpc endpoint getBlockCall }) } return @@ -334,8 +342,6 @@ func toPbTransaction(transaction *solana.Transaction) *pbsol.Transaction { } -//todo: review message implementation with Charles - func toPbMessage(message solana.Message) *pbsol.Message { return &pbsol.Message{ Header: toPbMessageHeader(message.Header), diff --git a/go.mod b/go.mod index 3995ea2f..90669609 100644 --- a/go.mod +++ b/go.mod @@ -242,7 +242,7 @@ require ( replace ( github.com/ShinyTrinkets/overseer => github.com/dfuse-io/overseer v0.2.1-0.20191024193921-39856397cf3f github.com/bytecodealliance/wasmtime-go/v4 => github.com/streamingfast/wasmtime-go/v4 v4.0.0-freemem3 - github.com/gagliardetto/solana-go => github.com/streamingfast/gagliardetto-solana-go v0.0.0-20240111145418-2be68b59fe4c + github.com/gagliardetto/solana-go => github.com/streamingfast/gagliardetto-solana-go v0.0.0-20240115191424-05c37cd0760d github.com/graph-gophers/graphql-go => github.com/streamingfast/graphql-go v0.0.0-20210204202750-0e485a040a3c github.com/jhump/protoreflect => github.com/streamingfast/protoreflect v0.0.0-20231205191344-4b629d20ce8d ) diff --git a/go.sum b/go.sum index 64db45eb..34388a6a 100644 --- a/go.sum +++ b/go.sum @@ -766,6 +766,7 @@ github.com/streamingfast/firehose-core v1.0.1-0.20240109054458-3f1edeff522c h1:P github.com/streamingfast/firehose-core v1.0.1-0.20240109054458-3f1edeff522c/go.mod h1:Y/Sza/3iOeabRhVC/hPoRx21jZDcyQFBYRNR8wgIk7I= github.com/streamingfast/gagliardetto-solana-go v0.0.0-20240111145418-2be68b59fe4c h1:GWlMGvspp2Mb5iCZBV31FeOHwliPI/LoIowvlx253qA= github.com/streamingfast/gagliardetto-solana-go v0.0.0-20240111145418-2be68b59fe4c/go.mod h1:i+7aAyNDTHG0jK8GZIBSI4OVvDqkt2Qx+LklYclRNG8= +github.com/streamingfast/gagliardetto-solana-go v0.0.0-20240115191424-05c37cd0760d/go.mod h1:i+7aAyNDTHG0jK8GZIBSI4OVvDqkt2Qx+LklYclRNG8= github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0 h1:g8eEYbFSykyzIyuxNMmHEUGGUvJE0ivmqZagLDK42gw= github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0/go.mod h1:cTNObq2Uofb330y05JbbZZ6RwE6QUXw5iVcHk1Fx3fk= github.com/streamingfast/logging v0.0.0-20210811175431-f3b44b61606a/go.mod h1:4GdqELhZOXj4xwc4IaBmzofzdErGynnaSzuzxy0ZIBo=