-
Notifications
You must be signed in to change notification settings - Fork 64
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
Feature/evm reader multi dapp #512
Conversation
2bbef0b
to
984437c
Compare
0b20cf4
to
9839466
Compare
c44553c
to
ed637c6
Compare
9839466
to
caee21b
Compare
ed637c6
to
217c97d
Compare
cf24743
to
426abc3
Compare
20ad909
to
8c701de
Compare
426abc3
to
f9c9a73
Compare
a376638
to
23825d2
Compare
f9c9a73
to
f62bf70
Compare
d9f780e
to
62bd20e
Compare
4ebb51e
to
70ce3b9
Compare
ad1b09b
to
b7bbd22
Compare
26946c6
to
5fa5fc6
Compare
022a767
to
213981b
Compare
a4d6e2e
to
e7f2563
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.
Approved with some suggestions to be addressed later on.
Run: run, | ||
} | ||
|
||
func run(cmd *cobra.Command, args []string) { |
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 may need to improve this command.
In the sequence below, there's:
- an upgrade
- check for version 2
- check for version 3
rollups-node$ go run ./cmd/cartesi-rollups-cli/ db upgrade
Database Schema successfully Updated. Current version is 2
rollups-node$
rollups-node$ go run ./cmd/cartesi-rollups-cli/ db check-version 2
Database Schema is at the correct version: 2
rollups-node$
rollups-node$ go run ./cmd/cartesi-rollups-cli/ db check-version 3
Database Schema is at the correct version: 2
rollups-node$
Also, message Database Schema successfully Updated. Current version is 2
should be similar to what cobra.CheckErr(err)
responds (Error: No valid database schema found).
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.
Check-version do not receive arguments. It only check is the DB is at the expected version.
var ( | ||
// Should be overridden during the final release build with ldflags | ||
// to contain the actual version number | ||
buildVersion = "devel" |
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.
buildVersion
should be held elsewhere in a common place that could be shared by all binaries we provide. Se also these places
// Validate Schema | ||
err := startup.ValidateSchema(c.PostgresEndpoint.Value) | ||
if err != nil { | ||
slog.Error("EVM Reader exited with an error", "error", err) | ||
os.Exit(1) | ||
} | ||
|
||
database, err := repository.Connect(ctx, c.PostgresEndpoint.Value) | ||
if err != nil { | ||
slog.Error("EVM Reader couldn't connect to the database", "error", err) | ||
os.Exit(1) | ||
} | ||
defer database.Close() | ||
|
||
_, err = startup.SetupNodePersistentConfig(ctx, database, c) | ||
if err != nil { | ||
slog.Error("EVM Reader couldn't connect to the database", "error", 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.
This could generalized to be used in all necessary commands, including cartesi-rollups-node
.
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.
I created the "startup" package for that. This can indeed further improved, making all "node binaries" similar
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.
Perhaps we could go one step further and perform all these steps in on shot there, then.
@@ -0,0 +1,17 @@ | |||
## cartesi-rollups-cli app |
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.
Perhaps we could add an HTML disclaimer to all generated MD files (via gen-docs) warning they were generated like we do with the automatically generated code.
for i := uint64(0); i <= maxRetries; i++ { | ||
lastValue, lastErr = fn(args) | ||
if lastErr == nil { | ||
return lastValue, nil |
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 are missing an INFO log for a successful execution.
InputBox = inputbox.InputBox | ||
) | ||
|
||
// InputBox Wrapper |
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.
Improve docs.
// Service tests | ||
func (s *EvmReaderSuite) TestItStopsWhenContextIsCanceled() { | ||
ctx, cancel := context.WithCancel(s.ctx) | ||
ready := make(chan struct{}, 1) | ||
errChannel := make(chan error, 1) | ||
go func() { | ||
errChannel <- s.evmReader.Run(ctx, ready) | ||
}() | ||
cancel() | ||
|
||
err := <-errChannel | ||
s.Require().Equal(context.Canceled, err, "stopped for the wrong reason") | ||
} | ||
|
||
func (s *EvmReaderSuite) TestItEventuallyBecomesReady() { | ||
ready := make(chan struct{}, 1) | ||
errChannel := make(chan error, 1) | ||
go func() { | ||
errChannel <- s.evmReader.Run(s.ctx, ready) | ||
}() | ||
|
||
select { | ||
case <-ready: | ||
case err := <-errChannel: | ||
s.FailNow("unexpected failure", 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.
I did this but, on hindsight, I think we should generalize these tests and move them to https://github.com/cartesi/rollups-node/tree/next/2.0/internal/services
s.client.AssertNumberOfCalls(s.T(), "SubscribeNewHead", 1) | ||
} | ||
|
||
func (s *EvmReaderSuite) TestItReadsInputsFromNewBlocks() { |
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.
Add tests covering more than one application at a time.
currentMostRecentFinalizedHeader, err := r.fetchMostRecentHeader( | ||
ctx, | ||
r.config.DefaultBlock, | ||
) | ||
if err != nil { | ||
slog.Error("Error fetching most recent block", | ||
"last default block", | ||
r.config.DefaultBlock, | ||
"error", | ||
err) | ||
continue | ||
} | ||
currentMostRecentFinalizedBlockNumber := currentMostRecentFinalizedHeader.Number.Uint64() | ||
|
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.
Shouldn't this whole block be moved outside the loop for groupedApps
(BTW, appGroup
would be better) to retrieve currentMostRecentFinalizedBlockNumber
only once and share it between apps?
Closes #332
To manually test EVM Reader Standalone first you need to build Devnet. In a terminal, type:
then start the dependencies
setup the database. Open a new terminal and type:
then, setup envrironment variables
and finally start EVM Reader
Now to "interact" with it, add aplications
-a
parameter sets the application address and-n
is Inputbox Deployment block numberTo send inputs use something like:
where
addresses.json
is a addresses.json file, where you can set the application contract you want