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

Redesign Execution queries #4075

Closed
damip opened this issue Jun 13, 2023 · 1 comment · Fixed by #4152
Closed

Redesign Execution queries #4075

damip opened this issue Jun 13, 2023 · 1 comment · Fixed by #4152
Assignees
Labels
api Issues related to the API enhancement New feature or request p2

Comments

@damip
Copy link
Member

damip commented Jun 13, 2023

Problem

Currently, we can't gather information from multiple elements in Execution atomically (eg. addresses and datastore values).

Also, get_op_exec_status is extremely heavy as it scans through all executed operations (10k/second !).

Solution

Create a single endpoint query(input: ExecutionQueryRequest) -> ExecutionQueryResponse method in the execution controller that allows to atomically (same slot guaranteed) query a well-defined list of things:

pub struct ExecutionQueryRequest {
   requests: Vec<ExecutionQueryRequestItem>,
}

pub struct ExecutionQueryResponse {
   responses: Vec<Result<ExecutionQueryResponseItem, Error>>,
   final_cursor: Slot,
   candidate_cursor: Slot
}

pub enum ExecutionQueryRequestItem {
    AddressExistsCandidate(Address),
    AddressExistsFinal(Address),
    AddressBalanceCandidate(Address),
    AddressBalanceFinal(Address),
    AddressBytecodeCandidate(Address),
    AddressBytecodeFinal(Address),
    AddressRollsCandidate(Address),
    AddressRollsFinal(Address),
    AddressDeferredCreditsCandidate(Address),
    AddressDeferredCreditsFinal(Address),
    AddressCycleInfos(Address),
    AddressDatastoreKeysCandidate {
        addr: Address,
        prefix: Vec<u8>,
    },
    AddressDatastoreKeysFinal {
        addr: Address,
        prefix: Vec<u8>,
    },
    AddressDatastoreValueCandidate {
        addr: Address,
        key: Vec<u8>,
    },
    AddressDatastoreValueFinal {
        addr: Address,
        key: Vec<u8>,
    },
    OpExecutionStatusCandidate(OperationId),
    OpExecutionStatusFinal(OperationId),
    DenunciationExecutionStatusCandidate(DenunciationIndex),
    DenunciationExecutionStatusFinal(DenunciationIndex),
}

pub enum ExecutionQueryResponseItem {
    AddressExists(bool),
    AddressBalance(Amount),
    AddressBytecode(Vec<u8>),
    AddressRolls(u64),
    AddressDeferredCredits(BTreeMap<Slot, Amount>),
    AddressCycleInfos(Vec<ExecutionAddressCycleInfo>),
    AddressDatastoreKeys(BTreeSet<Vec<u8>>),
    AddressDatastoreValue(Vec<u8>),
    OpExecutionStatus(bool),  // TODO as a followup more info, eg when it was executed, in which block, error output, ledger changes (?)
    DenunciationExecutionStatus(bool),  // TODO as a followup more info, eg when it was executed, in which block, error output, ledger changes (?)
}

Note that errors are properly managed: if we ask for the bytecode of an address that does not exist, it should give a NotFound error for that query.

This also opens the door to atomic batched GRPC queries in the API @aoudiamoncef.

@AurelienFT AurelienFT added the p2 label Jun 19, 2023
@aoudiamoncef aoudiamoncef added enhancement New feature or request api Issues related to the API labels Jun 23, 2023
@aoudiamoncef aoudiamoncef self-assigned this Jun 26, 2023
@damip damip self-assigned this Jun 26, 2023
@aoudiamoncef aoudiamoncef removed their assignment Jun 26, 2023
@damip damip linked a pull request Jun 29, 2023 that will close this issue
@AurelienFT
Copy link
Contributor

Done in #4152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API enhancement New feature or request p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants