-
Notifications
You must be signed in to change notification settings - Fork 142
Description
Is your feature request related to a problem? Please describe.
On the Concordium blockchain we have the concept of account aliases, i.e. only the first 29 (of 32) bytes of an account address are significant. This confuses rosetta-cli check:data as it has no way of knowing if two addresses actually reference the same account. If an operation was performed for some address, it will observe that the balance of the "account" of the aliases changed for no reason.
Describe the solution you'd like
I've been trying to find a way to patch rosetta-cli (via rosetta-sdk-go) to translate all addresses into the "canonical" one. I've gotten it working by adding the following abomination of a hack into Syncer.processBlock:
@@ -187,6 +229,11 @@ func (s *Syncer) processBlock(
}
block := br.block
+ for i := range block.Transactions {
+ for j := range block.Transactions[i].Operations {
+ canonicalizeAccountAddr(block.Transactions[i].Operations[j].Account)
+ }
+ }
err = s.handler.BlockAdded(ctx, block)
if err != nil {
return err
where canonicalizeAccountAddr does a lookup using the Concordium SDK and replaces the address in-place.
I've not been able to find a proper place to implement the behavior as Syncer, StatefulSyncer, Fetcher, etc. are all structs and not interfaces. Helper is an interface type but it's not being constructed in a factory that can be overriden.
I'm not sure if monkey patching the block result is the correct solution, but it's the only one I've gotten to work (also tried BalanceStorage.AddingBlock and Parser.BalanceChanges but those seemed insufficient).
Describe alternatives you've considered
Patching all accounts in our Rosetta implementation. That would defeat the purpose of having aliases and also be prohibitively expensive.
Additional context
Any ideas of the correct way to implement this are greatly appreciated. I'll be happy to propose a PR with the necessary changes to for example support overriding the behavior of Syncer.