-
Notifications
You must be signed in to change notification settings - Fork 12
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
LFVM: Refactor interpreter Configuration, test registration of experimental and default features. #868
Conversation
08844a2
to
7743183
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.
nice refactor, I have some questions though
go/interpreter/lfvm/converter.go
Outdated
// Converter converts EVM code to LFVM code. | ||
type Converter struct { | ||
// converter converts EVM code to LFVM code. | ||
type converter struct { | ||
config ConversionConfig |
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.
does ConversionConfig
needs to be public ?
go/interpreter/lfvm/lfvm.go
Outdated
// configuration for production purposes. | ||
func NewInterpreter(Config) (*lfvm, error) { | ||
return newVm(config{ | ||
// DefaultConfiguration ist the set of configuration values sanctioned for |
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.
// DefaultConfiguration ist the set of configuration values sanctioned for | |
// DefaultConfiguration is the set of configuration values sanctioned for |
go/interpreter/lfvm/lfvm.go
Outdated
return Configuration{ | ||
ConversionConfig: ConversionConfig{ | ||
WithSuperInstructions: false, | ||
SuperInstructionsEnabled: false, | ||
}, | ||
WithShaCache: true, | ||
}) | ||
ShaCache: true, |
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.
if these values are supposed to be changed by the functions below, should they not be private ?
// This test is slightly different from other tests because of dealing with the | ||
// global registry: | ||
// - It is declared in it's own package to avoid leaking the registration to other tests. | ||
// - It tests different properties, in one single function. The reason is that the |
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.
// - It tests different properties, in one single function. The reason is that the | |
// - It tests different properties in one single function. The reason is that the |
go/interpreter/lfvm/converter.go
Outdated
// WithSuperInstructions enables the use of super instructions. | ||
WithSuperInstructions bool | ||
// SuperInstructionsEnabled mark the use of super instructions. | ||
SuperInstructionsEnabled bool |
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.
what I do not like about these fields being public is that anyone can change them. Maybe they should only be changed during construction and to read them a getter should be provided ? wdyt ?
As recommended in best practices
7743183
to
1065d2f
Compare
refactor will not be done, instead the file will be tested as it is now. |
part of #684
This PR refactors lfvm.go to clean up the public interface of the lfvm package
There were three different configuration structs found, in the package, in the interpreter and in the step function. The three objects have been merged into 2 objects:
configuration
is an opaque object that allows configuring the interpreter. Because the default value may not suffice, a functionDefaultConfiguration
is created with the features planned for the release.configurationOverrides
is a key-value map that can set a subset of configuration flags, final set of configs is TBD.The public interface of LFVM is:
Configuration
DefaultConfiguration
is the sanctioned features for the release.ConfigurationOverrides
is created because the unused any type passed to the factory, this type can be rewritten in any way.Interpreter
is the old lfvm instance. It is public to allow tests to query configuration parameters from outside the package.NewInterpreter
is the only constructorRegisterExperimentalInterpreterConfigurations
can be called to register more configurationsTo prevent polluting the registry during testing, registry tests use the lfvm_test package.