Skip to content

Commit

Permalink
Add a property to control persistence of topic messages (#3255)
Browse files Browse the repository at this point in the history
* Add a property to control persistence of topic messages
* Change Rosetta single image to disable persistence of topic messages by default

Signed-off-by: Steven Sheehy <steven.sheehy@hedera.com>
  • Loading branch information
steven-sheehy authored Feb 4, 2022
1 parent e03c382 commit 0939ae5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ value, it is recommended to only populate overridden properties in the custom `a
| `hedera.mirror.importer.parser.record.entity.persist.schedules` | true | Persist schedule transactions to the database |
| `hedera.mirror.importer.parser.record.entity.persist.systemFiles` | true | Persist only system files (number lower than `1000`) to the database |
| `hedera.mirror.importer.parser.record.entity.persist.tokens` | true | Persist token data to the database |
| `hedera.mirror.importer.parser.record.entity.persist.topics` | true | Persist topic messages to the database |
| `hedera.mirror.importer.parser.record.entity.persist.transactionBytes` | false | Persist raw transaction bytes to the database |
| `hedera.mirror.importer.parser.record.entity.persist.transactionSignatures` | SCHEDULECREATE, SCHEDULESIGN | A list of transaction types whose transaction signatures will be stored |
| `hedera.mirror.importer.parser.record.entity.redis.enabled` | true | Whether to use Redis to send messages to the gRPC process. Requires `spring.redis.*` [properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#data-properties) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class PersistProperties {

private boolean tokens = true;

private boolean topics = true;

/**
* If configured the mirror node will store the raw transaction bytes on the transaction table
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ private EntityId getAccountId(AccountID accountID) {
}

private void insertConsensusTopicMessage(RecordItem recordItem) {
if (!entityProperties.getPersist().isTopics()) {
return;
}

ConsensusSubmitMessageTransactionBody transactionBody = recordItem.getTransactionBody()
.getConsensusSubmitMessage();
TransactionRecord transactionRecord = recordItem.getRecord();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,40 @@ void submitMessageTestTopicNotFound() {
.isEqualTo(topicMessage);
}

@Test
void submitMessageDisabled() {
// given
entityProperties.getPersist().setTopics(false);
var responseCode = SUCCESS;
var topicId = TOPIC_ID;
var consensusTimestamp = 10_000_000L;
var message = "message";
var sequenceNumber = 10_000L;
var runningHash = "running-hash";
var runningHashVersion = 1;
var chunkNum = 3;
var chunkTotal = 5;
var validStartNs = 7L;
var scheduled = false;
var nonce = 0;

TransactionID initialTransactionId = createTransactionID(PAYER_ACCOUNT_ID.getEntityNum(),
TestUtils.toTimestamp(validStartNs), scheduled, nonce);

var transaction = createSubmitMessageTransaction(topicId, message, chunkNum, chunkTotal, initialTransactionId);
var transactionRecord = createTransactionRecord(topicId, sequenceNumber, runningHash
.getBytes(), runningHashVersion, consensusTimestamp, responseCode);

// when
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));

// then
assertEquals(0L, entityRepository.count());
assertEquals(0L, topicMessageRepository.count());
assertTransactionInRepository(responseCode, consensusTimestamp, TOPIC_ID.getTopicNum());
entityProperties.getPersist().setTopics(true);
}

@Test
void submitMessageTestFiltered() {
// given
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-rosetta/build/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ redirect_stderr=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
priority=10
environment=HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_PERSIST_NONFEETRANSFERS=true,HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_REDIS_ENABLED=false,HEDERA_MIRROR_IMPORTER_STARTDATE=1970-01-01T00:00:00Z
environment=HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_PERSIST_NONFEETRANSFERS=true,HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_PERSIST_TOPICS=false,HEDERA_MIRROR_IMPORTER_PARSER_RECORD_ENTITY_REDIS_ENABLED=false,HEDERA_MIRROR_IMPORTER_STARTDATE=1970-01-01T00:00:00Z

[program:rosetta]
command=/app/rosetta/hedera-mirror-rosetta
Expand Down

0 comments on commit 0939ae5

Please sign in to comment.