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

wip: Use world.key instead of world.id to generate entity PDA #58

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

crypto-vincent
Copy link
Contributor

@crypto-vincent crypto-vincent commented Jun 18, 2024

Status Type ⚠️ Core Change Issue
Ready Refactor No --

Problem

When adding a new entity using seeds, we have to fetch the WorldId which can needs to be resolved from the onchain state. This means we have to do an RPC call for each transaction we are trying to prepare in those cases.

Solution

An easy solution is just to allow users to generate the Entity PDA from the worldPda instead, that way the users avoid unecessary lookups from the on-chain state when using entity seeds.

Notes

Also change the naming from "extraSeed" to "seed" in the entity API, since this seed effectively replace the "entity id", it's not an addition on top of it.

@crypto-vincent crypto-vincent self-assigned this Jun 18, 2024
: FindEntityPda({ worldId, entityId: new BN(worldInstance.entities) });
let entityPda: PublicKey;
if (seed !== undefined) {
entityPda = FindEntityPda({ world, seed });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now the happy path, much faster to generate transactions

@crypto-vincent crypto-vincent changed the title proposal: Use worldPda instead of worldId to generate entityPda proposal: Use world.key instead of world.id to generate entityPda Jun 18, 2024
@crypto-vincent crypto-vincent changed the title proposal: Use world.key instead of world.id to generate entityPda proposal: Use world.key instead of world.id to generate entity PDA Jun 18, 2024
@crypto-vincent crypto-vincent changed the title proposal: Use world.key instead of world.id to generate entity PDA wip: Use world.key instead of world.id to generate entity PDA Jun 24, 2024
@notdanilo
Copy link
Contributor

This PR seems old. Is it still an issue?

@crypto-vincent
Copy link
Contributor Author

This PR seems old. Is it still an issue?

Hello there, yes latest master still seem to have the issue: we always have to read the latest world.Id through a "World.fromAccountAddress" before creating any new entity (but seed-based entities may not need to do that in theory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants