Skip to content

Commit

Permalink
Adding StackHeight handling and fixPreviousBlockHash func
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Jan 15, 2024
1 parent 0cb98e5 commit 8b73cfd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 36 deletions.
76 changes: 41 additions & 35 deletions block/fetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,44 +99,15 @@ 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 {
return nil, fmt.Errorf("decoding transactions: %w", err)
}
block := &pbsol.Block{
PreviousBlockhash: result.PreviousBlockhash.String(),
Blockhash: result.Blockhash.String(),
Blockhash: fixedPreviousBlockHash,
ParentSlot: result.ParentSlot,
Transactions: transactions,
Rewards: toPBReward(result.Rewards),
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 8b73cfd

Please sign in to comment.