-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vlocalchain): refuse to use existing account (#10247)
closes: #10246 ## Description Changes `VLOCALCHAIN_ALLOCATE_ADDRESS` to continue using pseudorandom inputs to generate a likely-unused account address, but increments the sequence number until the address does not correspond to an existing account. Then, atomically, create a new account with that address. This prevents localchain account addresses from clashing with preexisting accounts or ones that were created after the address was known but before any deposit activity. ### Security Considerations Removes a race condition. ### Scaling Considerations Scanning for existing accounts should not be expensive, because in order for it to be repeated indefinitely, the account addresses would need to be predicted, and the prior messages to create those clashing accounts would still require gas payments. ### Documentation Considerations n/a ### Testing Considerations Added tests for collision detection and account creation via mock AccountKeeper. ### Upgrade Considerations n/a
- Loading branch information
Showing
6 changed files
with
83 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
) | ||
|
||
type AccountKeeper interface { | ||
NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI | ||
HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool | ||
SetAccount(ctx sdk.Context, acc authtypes.AccountI) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters