Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hooks to allow overriding Helper field in Syncer #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bisgardo
Copy link

@bisgardo bisgardo commented Jul 6, 2022

Fixes #422.

Motivation

For rosetta-cli check:data to do accounting correctly on the Concordium blockchain, it needs to rewrite account addresses into the same "normalized" alias.

Solution

Add (stateful)syncer options for overriding syncer.Options passed to syncer.New from outside the statefulsyncer.New.

Our internal fork of rosetta-cli is able to utilize this in https://github.com/Concordium/rosetta-cli/pull/1/files.

Open questions

There might be better ways to solve the underlying problem than patching block results, but I haven't been able to find one that works as reliably. So even if this is a bit brute-force'ish it's good enough for me.

Needed by a Concordium fork of 'rosetta-cli' that understands account aliases. This is necessary for the 'rosetta-cli check:data' test to pass on a Concordium network.
Comment on lines +72 to +76
func WithExtraSyncerOpts(os ...syncer.Option) Option {
return func(s *StatefulSyncer) {
s.extraSyncerOpts = os
}
}
Copy link
Author

@bisgardo bisgardo Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more flexible solution would be to instead register a mapping function (similar to what is passed to WithCustomHelper below).

The usage of this from our fork would then be something like

statefulsyncer.WithCustomSyncerOpts(
	func(opts ...syncer.Option) []syncer.Option {
		return append(
			opts,
			syncer.WithCustomHelper(func(h syncer.Helper) syncer.Helper {
				return newConcordiumHelper(h)
			}))
	},
),

Might be a little too much complexity...

bisgardo added a commit to Concordium/rosetta-sdk-go that referenced this pull request Sep 10, 2022
…extra options

The solution described in comment coinbase#423 (comment). It mostly demonstrates that it adds too much complexity for what it gains.
bisgardo added a commit to Concordium/rosetta-cli that referenced this pull request Sep 10, 2022
…extra options

The solution described in comment coinbase/mesh-sdk-go#423 (comment). It mostly demonstrates that it adds too much complexity for what it gains.
@bisgardo
Copy link
Author

Is anyone ever going to take a look at this? @jingweicb @shrimalmadhur @GeekArthur

@jingweicb
Copy link
Contributor

Is anyone ever going to take a look at this? @jingweicb @shrimalmadhur @GeekArthur

@bisgardo sorry for making you waiting, will circle back later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Handling account aliases on the Concordium blockchain (rosetta-cli)
2 participants