Skip to content

Commit

Permalink
fixup! fix(cosmos): prevent Golang error wrapping stack frame divergence
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jun 20, 2023
1 parent 1c395a9 commit 2879ec3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions golang/cosmos/daemon/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

info, err := kb.Key(args[0])
if err != nil {
return fmt.Errorf("failed to get address from Keybase: %w", err)
return fmt.Errorf("failed to get address from Keybase: %s", err)
}

addr = info.GetAddress()
}

coins, err := sdk.ParseCoinsNormalized(args[1])
if err != nil {
return fmt.Errorf("failed to parse coins: %w", err)
return fmt.Errorf("failed to parse coins: %s", err)
}

vestingStart, err := cmd.Flags().GetInt64(flagVestingStart)
Expand All @@ -87,7 +87,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

vestingAmt, err := sdk.ParseCoinsNormalized(vestingAmtStr)
if err != nil {
return fmt.Errorf("failed to parse vesting amount: %w", err)
return fmt.Errorf("failed to parse vesting amount: %s", err)
}

// create concrete account type based on input parameters
Expand Down Expand Up @@ -119,20 +119,20 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
}

if err := genAccount.Validate(); err != nil {
return fmt.Errorf("failed to validate new genesis account: %w", err)
return fmt.Errorf("failed to validate new genesis account: %s", err)
}

genFile := config.GenesisFile()
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
return fmt.Errorf("failed to unmarshal genesis state: %s", err)
}

authGenState := authtypes.GetGenesisStateFromAppState(clientCtx.Codec, appState)

accs, err := authtypes.UnpackAccounts(authGenState.Accounts)
if err != nil {
return fmt.Errorf("failed to get accounts from any: %w", err)
return fmt.Errorf("failed to get accounts from any: %s", err)
}

if accs.Contains(addr) {
Expand All @@ -146,13 +146,13 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

genAccs, err := authtypes.PackAccounts(accs)
if err != nil {
return fmt.Errorf("failed to convert accounts into any's: %w", err)
return fmt.Errorf("failed to convert accounts into any's: %s", err)
}
authGenState.Accounts = genAccs

authGenStateBz, err := clientCtx.Codec.MarshalJSON(&authGenState)
if err != nil {
return fmt.Errorf("failed to marshal auth genesis state: %w", err)
return fmt.Errorf("failed to marshal auth genesis state: %s", err)
}

appState[authtypes.ModuleName] = authGenStateBz
Expand All @@ -164,14 +164,14 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

bankGenStateBz, err := clientCtx.Codec.MarshalJSON(bankGenState)
if err != nil {
return fmt.Errorf("failed to marshal bank genesis state: %w", err)
return fmt.Errorf("failed to marshal bank genesis state: %s", err)
}

appState[banktypes.ModuleName] = bankGenStateBz

appStateJSON, err := json.Marshal(appState)
if err != nil {
return fmt.Errorf("failed to marshal application genesis state: %w", err)
return fmt.Errorf("failed to marshal application genesis state: %s", err)
}

genDoc.AppState = appStateJSON
Expand Down
2 changes: 1 addition & 1 deletion golang/cosmos/x/swingset/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func AfterCommitBlock(keeper Keeper) error {
// fmt.Fprintf(os.Stderr, "AFTER_COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
if err != nil {
// Panic here, in the hopes that a replay from scratch will fix the problem.
panic(fmt.Errorf("AFTER_COMMIT_BLOCK failed: %w. Swingset is in an irrecoverable inconsistent state", err))
panic(fmt.Errorf("AFTER_COMMIT_BLOCK failed: %s. Swingset is in an irrecoverable inconsistent state", err))
}
return err
}

0 comments on commit 2879ec3

Please sign in to comment.