-
Notifications
You must be signed in to change notification settings - Fork 208
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
base: master
Are you sure you want to change the base?
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
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.
// genesis.json file. | ||
// TODO: document this flag in config, likely alongside the genesis path | ||
FlagSwingStoreExportDir = "swing-store-export-dir" | ||
FlagSwingStoreExportMode = "swing-store-export-mode" |
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 add a godoc comment for this flag
golang/cosmos/daemon/cmd/root.go
Outdated
swingsetkeeper.SwingStoreArtifactModeDebug: true, | ||
swingsetkeeper.SwingStoreArtifactModeOperational: true, | ||
swingsetkeeper.SwingStoreArtifactModeSkip: 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.
This is a bit of a hacky reuse, especially because skip is not a current artifact mode. It would be clearer to define explicit constants for the swing-store genesis export mode, describing what each one does.
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 are right. skip
is not a supported artifact mode. I will revert SwingStoreArtifactModeSkip
to SwingStoreArtifactModeNone
.
But I don't see SwingStoreArtifactModeNone
and SwingStoreArtifactModeDebug
used elsewhere and I think they were defined for controlling the artifact mode. So why not use them?
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 more of a conceptual question. We're not just controlling the artifacts part of the swing-store export, but what kind of swing-store export we want to do. It happens that we're partially reusing the same words to describe the whole export, as the artifacts part if a bug component of it.
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
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 { |
golang/cosmos/x/swingset/genesis.go
Outdated
snapshotHeight, | ||
eventHandler, | ||
keeper.SwingStoreExportOptions{ | ||
ArtifactMode: swingStoreExportMode, |
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 would prefer to set above a artifactMode := swingStoreExportMode
and explain that the values for this option currently matches for non skip.
golang/cosmos/x/swingset/genesis.go
Outdated
if err == io.EOF { | ||
artifactsEnded = true | ||
if eventHandler.exportMode == keeper.SwingStoreArtifactModeDebug { | ||
exportDataReader, _ := 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.
This should come from the swing-store export (aka provider.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.
Yes. My bad. Not sure why I changed it in this commit 😄
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.
@@ -160,7 +160,7 @@ type swingStoreRestoreExportAction struct { | |||
const ( | |||
// SwingStoreArtifactModeNone means that no artifacts are part of the | |||
// export / import. | |||
SwingStoreArtifactModeNone = "none" | |||
SwingStoreArtifactModeSkip = "skip" |
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 very much would like to not change this as it matches cosmic-swingset definitions
return nil | ||
}), nil | ||
} | ||
|
||
artifactsProvider := keeper.SwingStoreExportProvider{ |
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.
In the case of debug mode (and only in this case), the export artifact should capture the blockHeight of the swing-store, so we don't completely lose track of it (we unfortunately don't have a better place to stash it)
if eventHandler.exportMode == keeper.SwingStoreArtifactModeDebug {
artifactProvider.BlockHeight = provider.BlockHeight
}
golang/cosmos/x/swingset/genesis.go
Outdated
if !((eventHandler.exportMode == keeper.SwingStoreArtifactModeDebug && eventHandler.snapshotHeight == 0) || | ||
eventHandler.snapshotHeight == provider.BlockHeight) { |
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.
Part of this check is technically redundant
if !((eventHandler.exportMode == keeper.SwingStoreArtifactModeDebug && eventHandler.snapshotHeight == 0) || | |
eventHandler.snapshotHeight == provider.BlockHeight) { | |
if eventHandler.exportMode != keeper.SwingStoreArtifactModeDebug && | |
eventHandler.snapshotHeight != provider.BlockHeight { |
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