-
Notifications
You must be signed in to change notification settings - Fork 212
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
agd export
option for diagnosis
#10344
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
golang/cosmos/daemon/cmd/root.go
Outdated
} | ||
|
||
// We don't have to launch VM in case the swing store export is not required | ||
if !(swingStoreExportMode == swingsetkeeper.SwingStoreArtifactModeSkip || OnExportHook == 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.
@mhofman since OnExportHook
currently points to launchVM
, is it okay to bypass this hook in case swing-store export is not needed? Or do you see us adding cosmic side future hook changes?
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 think that's fine, but I'd like @michaelfig to confirm, especially with his upcoming changed for split brains. Basically export only needs to launch the VM if it will export the swing-store, which is decided by a command line config. Since OnExportHook
is unconditionally set or not based on the entrypoint used, the only option we have is to ignore it here.
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.
Btw, my brain still struggles with distributing negations.
if !(swingStoreExportMode == swingsetkeeper.SwingStoreArtifactModeSkip || OnExportHook == nil) { | |
if swingStoreExportMode != swingsetkeeper.SwingStoreArtifactModeSkip && OnExportHook != nil { |
golang/cosmos/x/swingset/genesis.go
Outdated
artifactsEnded = true | ||
if eventHandler.exportMode == keeper.SwingStoreArtifactModeDebug { | ||
err = nil | ||
exportDataReader, err := getExportDataReader() |
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.
Do we need to close this reader in defer?
defer exportDataReader.Close()
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 thought EncodeKVEntryReaderToJsonl
function will close the reader passed to it at the end but it seems like it doesn'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.
Right, EncodeKVEntryReaderToJsonl
doesn't close the reader. I think that was because I wanted the reader to be closed even if a read error occurred, and leave the caller in charge of handling potentially double errors. I'm not sure if that's the idiomatic golang thing to do, and would be open to reconsider if it's not.
golang/cosmos/x/swingset/genesis.go
Outdated
artifact = types.SwingStoreArtifact{ | ||
Data: encodedExportData.Bytes(), | ||
Name: keeper.UntrustedExportDataArtifactName, | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
So in-case exportMode is "debug", we are sending an extra artifact at the end which is a full export of swingStore (Kvstore)? Right? Assuming that caller iterates over ReadNextArtifact
until gets io.EOF.
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.
Thanks for digging through this. The main issue is that we don't currently write out the "export data" as "untrusted copy" in debug mode, but instead we-write the cosmos DB copy.
golang/cosmos/daemon/cmd/root.go
Outdated
} | ||
|
||
// We don't have to launch VM in case the swing store export is not required | ||
if !(swingStoreExportMode == swingsetkeeper.SwingStoreArtifactModeSkip || OnExportHook == 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.
I think that's fine, but I'd like @michaelfig to confirm, especially with his upcoming changed for split brains. Basically export only needs to launch the VM if it will export the swing-store, which is decided by a command line config. Since OnExportHook
is unconditionally set or not based on the entrypoint used, the only option we have is to ignore it here.
golang/cosmos/daemon/cmd/root.go
Outdated
} | ||
|
||
// We don't have to launch VM in case the swing store export is not required | ||
if !(swingStoreExportMode == swingsetkeeper.SwingStoreArtifactModeSkip || OnExportHook == 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.
Btw, my brain still struggles with distributing negations.
if !(swingStoreExportMode == swingsetkeeper.SwingStoreArtifactModeSkip || OnExportHook == nil) { | |
if swingStoreExportMode != swingsetkeeper.SwingStoreArtifactModeSkip && OnExportHook != nil { |
err = agoric.EncodeKVEntryReaderToJsonl( | ||
exportDataReader, | ||
&encodedExportData, | ||
) | ||
if err == nil { | ||
artifact = types.SwingStoreArtifact{ | ||
Data: encodedExportData.Bytes(), | ||
Name: keeper.UntrustedExportDataArtifactName, | ||
} | ||
} |
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 really is a bit unfortunate we have to read, decode, re-encode it all in memory before finally writing it out, but streamlining this is definitely out of scope.
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.
Assuming my final nit is addressed, feel free to merge this. Thanks for working on this.
const ( | ||
// SwingStoreExportModeSkip indicates swing store data should be | ||
// excluded from the export. | ||
SwingStoreExportModeSkip = "skip" | ||
|
||
// SwingStoreExportModeOperational (default) indicates export should | ||
// have the minimal set of artifacts needed to operate a node. | ||
SwingStoreExportModeOperational = "operational" | ||
|
||
// SwingStoreExportModeDebug indicates export should have the maximal | ||
// set of artifacts available in the JS swing-store. | ||
SwingStoreExportModeDebug = "debug" | ||
) | ||
|
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.
Let's move these to genesis.go
as it's only applicable to that logic.
golang/cosmos/x/swingset/genesis.go
Outdated
artifactsEnded = true | ||
if eventHandler.exportMode == keeper.SwingStoreArtifactModeDebug { | ||
err = nil | ||
exportDataReader, err := getExportDataReader() |
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.
Right, EncodeKVEntryReaderToJsonl
doesn't close the reader. I think that was because I wanted the reader to be closed even if a read error occurred, and leave the caller in charge of handling potentially double errors. I'm not sure if that's the idiomatic golang thing to do, and would be open to reconsider if it's not.
closes: #8420
ref: #8152
Description
This PR adds a new optional flag
--swing-store-export-mode
to theagd export
command which can be used to specify the nature of swing-store exportSecurity Considerations
None
Scaling Considerations
None
Documentation Considerations
An optional flag
--swing-store-export-mode
option is now supported foragd export
to specify the kind of swing store export required:operational
(default) option will retain the existing behavior and export the swing-store artifacts using the latest heightskip
option will not export any swing-store artifactdebug
option will export all swing-store artifacts, starting from height0
Testing Considerations
Tested manually
Upgrade Considerations
None