-
Notifications
You must be signed in to change notification settings - Fork 477
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
Refactor Blockchain Bridge Simulate to Support Multiple Generic Tracers #8148
base: master
Are you sure you want to change the base?
Refactor Blockchain Bridge Simulate to Support Multiple Generic Tracers #8148
Conversation
16a582f
to
5f088c6
Compare
5f088c6
to
2b7ad66
Compare
…t for SimulateBlockTracer, GethLikeBlockMemoryTracer, and ParityLikeBlockTracer while ensuring flexibility in SimulateBlockResult<T> and updating test cases accordingly.
2b7ad66
to
bd3accd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close but I think we need 2 generic parameters to make it smooth
if (tracer is SimulateBlockTracer simulateTracer) | ||
{ | ||
result.Items = simulateTracer.Results as IReadOnlyList<SimulateBlockResult<T>>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this make generic constraint where T : ISimulateTracer
and IBlockTracer<TTrace>
interface should have Results
of this type.
else | ||
{ | ||
throw new InvalidOperationException($"Tracer type {typeof(T).Name} does not support 'Results'"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also don't need this then as the generic constraint would guard it
public SimulateOutput<T> Simulate<T>( | ||
BlockHeader header, | ||
SimulatePayload<TransactionWithSourceDetails> payload, | ||
CancellationToken cancellationToken, | ||
ITracerFactory<T> tracerFactory) | ||
where T : class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public SimulateOutput<T> Simulate<T>( | |
BlockHeader header, | |
SimulatePayload<TransactionWithSourceDetails> payload, | |
CancellationToken cancellationToken, | |
ITracerFactory<T> tracerFactory) | |
where T : class | |
public SimulateOutput<TTrace> Simulate<TTracer, TTrace>( | |
BlockHeader header, | |
SimulatePayload<TransactionWithSourceDetails> payload, | |
CancellationToken cancellationToken, | |
ITracerFactory<TTracer> tracerFactory) | |
where TTracer : IBlockTracer<TTrace> |
Overview
This refactor makes
Simulate
in the Blockchain Bridge generic, allowing it to supportSimulateBlockTracer
,GethLikeBlockMemoryTracer
, andParityLikeBlockTracer
dynamically.Key Changes
Generic
Simulate
ImplementationSimulateBlockResult<T>
to support multiple tracers.Simulate
to a generic function to improve flexibility.Factory Method for Tracer Selection
Changes to Data Structures
SimulatePayload
andSimulateBlockResult
to work generically.