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

Feature request - expose an interface to retrieve all affected addresses from a transaction #2252

Open
redmaner opened this issue Feb 26, 2024 · 4 comments

Comments

@redmaner
Copy link
Contributor

Current transactions returned over RPC include the from and to fields but these fields do not always cover all affected addresses in the transaction.

For example:

  • given pool X
  • having delegated staker A
  • pool X adds stake to staker A
  • the transaction from field is set to pool X and the recipient is set to the staking contract. The address of staker A has to be parsed from recipientData

This issue requests either of two things:

  • include the staker_address in the transaction, so we always know which staker is affected by a staking contract transaction and / or
  • expose an RPC method to retrieve the affected addresses for a transaction. Apparently a transaction struct already has a function to retrieve affected addresses which may be something that can be exposed over RPC so other languages don't have to manually parse convoluted fields to retrieve the required information.
@sisou
Copy link
Member

sisou commented Feb 26, 2024

Hmm... seems I was mistaken when I said there is already an internal mechanism to get affected addresses for a transaction. The history store in fact only indexes by sender and recipient :(

let index_tx_sender = self.get_last_tx_index_for_address(&tx.sender, Some(txn)) + 1;
txn.put(
&self.address_table,
&tx.sender,
&OrderedHash {
index: index_tx_sender,
hash: raw_tx_hash.clone().into(),
},
);
let index_tx_recipient =
self.get_last_tx_index_for_address(&tx.recipient, Some(txn)) + 1;
txn.put(
&self.address_table,
&tx.recipient,
&OrderedHash {
index: index_tx_recipient,
hash: raw_tx_hash.into(),
},
);

Probably what I remember was just an idea, instead of implemented.

@sisou
Copy link
Member

sisou commented Feb 29, 2024

Here is what I remembered: the Log struct has this method!

pub fn is_related_to_address(&self, address: &Address) -> bool {

@paberr
Copy link
Member

paberr commented Apr 19, 2024

It will be difficult to make this accessible from the transaction itself.
However, that's what the Log mechanism was designed for: to get more meaningful "events" related to specific addresses.

@redmaner: Does the Log mechanism solve your problem?

@redmaner
Copy link
Contributor Author

redmaner commented Apr 22, 2024

Why is this difficult to make accessible from the transaction itself while the data is encoded in recipient_data and sender_data just in an non human readable format? Having RPC calls to decode that into JSON would already be helpful

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

No branches or pull requests

3 participants