Add block height to ConfirmedBlock structs (#17523)

* Add BlockHeight CF to blockstore

* Rename CacheBlockTimeService to be more general

* Cache block-height using service

* Fixup previous proto mishandling

* Add block_height to block structs

* Add block-height to solana block

* Fallback to BankForks if block time or block height are not yet written to Blockstore

* Add docs

* Review comments
This commit is contained in:
Tyera Eulberg
2021-05-26 22:16:16 -06:00
committed by GitHub
parent 9541411c15
commit ab581dafc2
21 changed files with 184 additions and 80 deletions

View File

@@ -9,6 +9,7 @@ message ConfirmedBlock {
repeated ConfirmedTransaction transactions = 4;
repeated Reward rewards = 5;
UnixTimestamp block_time = 6;
BlockHeight block_height = 7;
}
message ConfirmedTransaction {
@@ -96,3 +97,7 @@ message Rewards {
message UnixTimestamp {
int64 timestamp = 1;
}
message BlockHeight {
uint64 block_height = 1;
}

View File

@@ -118,6 +118,7 @@ impl From<ConfirmedBlock> for generated::ConfirmedBlock {
transactions,
rewards,
block_time,
block_height,
} = confirmed_block;
Self {
@@ -127,6 +128,7 @@ impl From<ConfirmedBlock> for generated::ConfirmedBlock {
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
rewards: rewards.into_iter().map(|r| r.into()).collect(),
block_time: block_time.map(|timestamp| generated::UnixTimestamp { timestamp }),
block_height: block_height.map(|block_height| generated::BlockHeight { block_height }),
}
}
}
@@ -143,6 +145,7 @@ impl TryFrom<generated::ConfirmedBlock> for ConfirmedBlock {
transactions,
rewards,
block_time,
block_height,
} = confirmed_block;
Ok(Self {
@@ -155,6 +158,7 @@ impl TryFrom<generated::ConfirmedBlock> for ConfirmedBlock {
.collect::<std::result::Result<Vec<TransactionWithStatusMeta>, Self::Error>>()?,
rewards: rewards.into_iter().map(|r| r.into()).collect(),
block_time: block_time.map(|generated::UnixTimestamp { timestamp }| timestamp),
block_height: block_height.map(|generated::BlockHeight { block_height }| block_height),
})
}
}
@@ -596,7 +600,7 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
tx_by_addr::TransactionErrorType::InstructionError
}
TransactionError::AccountBorrowOutstanding => {
tx_by_addr::TransactionErrorType::AccountBorrowOutstanding
tx_by_addr::TransactionErrorType::AccountBorrowOutstandingTx
}
} as i32,
instruction_error: match transaction_error {

View File

@@ -30,7 +30,7 @@ enum TransactionErrorType {
PROGRAM_ACCOUNT_NOT_FOUND = 3;
INSUFFICIENT_FUNDS_FOR_FEE = 4;
INVALID_ACCOUNT_FOR_FEE = 5;
DUPLICATE_SIGNATURE = 6;
ALREADY_PROCESSED = 6;
BLOCKHASH_NOT_FOUND = 7;
INSTRUCTION_ERROR = 8;
CALL_CHAIN_TOO_DEEP = 9;
@@ -40,6 +40,7 @@ enum TransactionErrorType {
INVALID_PROGRAM_FOR_EXECUTION = 13;
SANITIZE_FAILURE = 14;
CLUSTER_MAINTENANCE = 15;
ACCOUNT_BORROW_OUTSTANDING_TX = 16;
}
message InstructionError {
@@ -97,6 +98,7 @@ enum InstructionErrorType {
ACCOUNT_NOT_RENT_EXEMPT = 45;
INVALID_ACCOUNT_OWNER = 46;
ARITHMETIC_OVERFLOW = 47;
UNSUPPORTED_SYSVAR = 48;
}
message UnixTimestamp {