Skip to content
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

helper for async providing a value into a SharedStateRecord #10130

Closed
turadg opened this issue Sep 23, 2024 · 1 comment · Fixed by #10140
Closed

helper for async providing a value into a SharedStateRecord #10130

turadg opened this issue Sep 23, 2024 · 1 comment · Fixed by #10140
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@turadg
Copy link
Member

turadg commented Sep 23, 2024

What is the Problem Being Solved?

This is subject to race conditions:

if (!contractState.localAccount) {
const agoricChain = await orch.getChain('agoric');
contractState.localAccount = await agoricChain.makeAccount();
}

Multiple invocations of the same flow can concurrently find the localAccount to not be created yet, and attempt to create it.

Description of the Design

We need some provideOnce

Without membranes we’ve used makeAtomicProvider which takes a store and returns a provideAsync that uses a pending promises map to only try making each key once.

Security Considerations

Scaling Considerations

Test Plan

Upgrade Considerations

@turadg turadg added bug Something isn't working enhancement New feature or request labels Sep 23, 2024
@mhofman
Copy link
Member

mhofman commented Sep 24, 2024

IMO we should completely avoid the "shared state" record pattern unless the "provider" of the value is idempotent so that it can be invoked again in new incarnations because the "shared state" is not durable. And even then, I don't see why the "provider" cannot be directly endowed instead.

@turadg turadg self-assigned this Sep 24, 2024
@mergify mergify bot closed this as completed in #10140 Oct 2, 2024
mergify bot added a commit that referenced this issue Oct 2, 2024
closes: #10130


## Description

Provide examples of how a contract can have a shared local account, without the race condition of creating it conditionally in a flow.

In the course of this I corrected the `LocalOrchestrationAccount` method signatures (particularly `deposit` not returning the Amount).

### Security Considerations
none, just example code

### Scaling Considerations

none, example code

### Documentation Considerations
Examples are implicit documentation. Can be mined for docs site tutorials if the need arises.

### Testing Considerations
The upgrade test for `send-anywhere` is disabled, but since this just makes a vow there shouldn't be any upgrade interactions.

### Upgrade Considerations
The examples aren't to be deployed.

The remove of `sharedStateRecord` won't affect anything on chain. Same for changing the return of `deposit`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants