-
Notifications
You must be signed in to change notification settings - Fork 1
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
Initial implementation #1
Conversation
.github/workflows/golangci-lint.yml
Outdated
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.5 |
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.
go-version: 1.20.5 | |
go-version: 1.20.7 |
to have the same version as in the other flow
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.
done
cmd/chainsimulator/main.go
Outdated
) | ||
|
||
var ( | ||
log = logger.GetOrCreate("indexer") |
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.
log = logger.GetOrCreate("indexer") | |
log = logger.GetOrCreate("chainSimulator") |
?
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.
changed
pkg/proxy/api/endpoints.go
Outdated
}, nil | ||
} | ||
|
||
// ExtendProxyServer will extend the proxy server with extra endponts |
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.
// ExtendProxyServer will extend the proxy server with extra endponts | |
// ExtendProxyServer will extend the proxy server with extra endpoints |
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.
done
const ( | ||
pathToNodeConfig = "../../../mx-chain-go/cmd/node/config" | ||
pathToProxyConfig = "../../../mx-chain-proxy-go/cmd/proxy/config" |
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.
suggestion to add path to proxy and node config as cli parameters
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.
yes, this is done in the next PR
cmd := exec.Command("cp", "-r", args.PathToProxyConfig, newConfigsPath) | ||
err := cmd.Run() | ||
if err != nil { | ||
return nil, err |
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.
as suggested above, I think it's not up to this binary to handle node and proxy's configs. Also it seems that here you're just reading the configs so there is no need to copy the proxy config to another location. Or if you really want to copy the configs to a separate temporary location, i think it's better to create a CopyDir function instead of using system binary cp
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.
Will refactor this in the next PR because there I implemented a function that will copy a folder of a file
pkg/proxy/creator/creator.go
Outdated
|
||
proxyInstance.closableComponents.Add(nodeGroupProc, valStatsProc, nodeStatusProc, bp) | ||
|
||
//nodeGroupProc.StartCacheUpdate() |
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.
uncomment this?
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.
We don't need heartbeats here, so I will remove this commented line.
pkg/proxy/creator/creator.go
Outdated
log.Error("cannot ListenAndServe()", "err", err) | ||
os.Exit(1) |
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.
return error here? there is already an os.Exit(1)
in main.go in case of error
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.
removed and changed the log
pkg/proxy/creator/creator.go
Outdated
|
||
func (p *proxy) GetHttpServer() *http.Server { |
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.
missing comment
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.
added
cmd/chainsimulator/main.go
Outdated
//buildInfo, ok := debug.ReadBuildInfo() | ||
//if !ok { | ||
// panic("Can't read BuildInfo") |
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.
remove commented code?
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.
done
} | ||
|
||
startTime := time.Now().Unix() | ||
roundDurationInMillis := uint64(6000) |
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.
suggestion to parametrize this in a next PR
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's done in the next PR
|
||
startTime := time.Now().Unix() | ||
roundDurationInMillis := uint64(6000) | ||
roundsPerEpoch := core.OptionalUint64{ |
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.
suggestion to parametrize this in a next PR
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's done in the next PR
Value: 20, | ||
} | ||
|
||
apiConfigurator := api.NewFreePortAPIConfigurator("localhost") |
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.
suggestion to parametrize this in a next PR
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's done in the next PR
} | ||
|
||
apiConfigurator := api.NewFreePortAPIConfigurator("localhost") | ||
simulator, err := chainSimulator.NewChainSimulator(os.TempDir(), 3, pathToNodeConfig, startTime, roundDurationInMillis, roundsPerEpoch, apiConfigurator) |
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.
suggestion to parametrize number of shards in a next PR
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's done in the next PR
@@ -0,0 +1,6 @@ | |||
package facade | |||
|
|||
type SimulatorHandler interface { |
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.
missing comments
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.
added
pkg/proxy/configs/configs.go
Outdated
for shardID, nodeAPIInterface := range args.RestApiInterfaces { | ||
cfg.Observers = append(cfg.Observers, &data.NodeData{ | ||
ShardId: shardID, | ||
Address: "http://" + nodeAPIInterface, |
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.
const for "http://" ?
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.
added
} | ||
|
||
// CreateProxy will create a new instance of proxy | ||
func CreateProxy(args ArgsProxy) (proxy2.ProxyHandler, error) { |
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.
with a little bit of code refactoring in the proxy repo, we can reuse this construction part. Not for this PR.
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.
yes, will make a task to refactor the proxy main.go file
chainsimulator
binary/simulator/generate-blocks/:num-blocks
that will generate a provided number of blocks for every shard