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

Block info for contract Instantiation should be returned in Contract Info Response #1295

Closed
donkey-donkey opened this issue May 4, 2022 · 4 comments

Comments

@donkey-donkey
Copy link

We are building a list of certain contracts on chain. The block and datetime info of when the contract was deployed would be really great to know for showing how long a contract has been around and various comparisons.

Block info could be returned in ContractInfoResponse from the WasmQuery::ContractInfo

@webmaster128
Copy link
Member

This data is available in wasmd as:

  // Created Tx position when the contract was instantiated.
  // This data should kept internal and not be exposed via query results. Just
  // use for sorting
  AbsoluteTxPosition created = 5;

where

AbsoluteTxPosition is a unique transaction position that allows for global
ordering of transactions.

with the fields

Field Type Label Description
block_height uint64 BlockHeight is the block the contract was created at
tx_index uint64 TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed)

So you don't get a timestamp but something.

I wonder if it makes sense to expose this information as part of the ContractInfoResponse. Are we good to consider this stable enought to expose? What happens with this value on a dum-state-restart scenario? @alpe @ethanfrey

@ethanfrey
Copy link
Member

@alpe would know about the stability between dump-restart approaches.

I think that we could provide this. I would remove tx_index or make it an option, as it depends on a middleware being installed before x/wasm (and may not always be present).

My question is why? I understand the OP is building an explorer or such, and the wasmd api exposes all the information they need. Are they building this explorer as a contract that needs to query this info?

I would just include block_height unless @alpe says that is unstable.

@alpe
Copy link
Contributor

alpe commented May 25, 2022

On dump-restart the contract "created" field as well as the history are not preserved. In order to support this request, we need to revisit this approach. Current design is:

// Created Tx position when the contract was instantiated.
// This data should kept internal and not be exposed via query results. Just
// use for sorting
AbsoluteTxPosition created = 5;

I see some value in returning the block height in queries but it is a good package of work to apply the changes to the genesis export/ import

@chipshort
Copy link
Collaborator

This is not planned at the moment

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

5 participants