Skip to content

Inner asset txns#2871

Closed
jannotti wants to merge 16 commits into
algorand:masterfrom
jannotti:inner-asset-txns
Closed

Inner asset txns#2871
jannotti wants to merge 16 commits into
algorand:masterfrom
jannotti:inner-asset-txns

Conversation

@jannotti
Copy link
Copy Markdown
Contributor

acfg and afrz inner transactions

This also sorts out inner txcounting, so that an innner transaction knows the current txncount as it executes, so it can get the right id if it creates.

Need some more tests, but so far we have some teal unit tests, and ledger level integration tests.

jannotti and others added 7 commits September 8, 2021 20:57
This only changes the blocks, so there is still a lot of work to do so
that external APIs see things properly.  The REST API assumes that it
can determine a creatble ID based on the index of a transaction in a
block and the block's TxnCounter.  That is no longer true, it must
actually figure out how many inner txns it is skipping over.
Co-authored-by: Jason Paulos <jasonpaulos@users.noreply.github.com>
This also sorts out inner txcounting, so that an innner transaction
knows the current txncount as it executes, so it can get the right id
if it creates.
algorandskiy
algorandskiy previously approved these changes Sep 11, 2021
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

I like this one better. Probably need to add some e2e tests

Comment thread data/transactions/logic/eval.go Outdated
Comment thread data/transactions/logic/eval.go
Comment thread data/transactions/logic/evalAppTxn_test.go
Comment thread ledger/apptxn_test.go
vb := l.endBlock(t, eval)

asaIndex := vb.blk.Payset[1].EvalDelta.InnerTxns[0].ConfigAsset
require.Equal(t, basics.AssetIndex(5), asaIndex)
Copy link
Copy Markdown
Contributor

@jasonpaulos jasonpaulos Sep 11, 2021

Choose a reason for hiding this comment

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

Could you also pull out the params of the newly created asset and check its fields match the values set by the AVM? (Maybe this is better in an e2e test)

Also, I suppose it's not possible to actually transfer the newly created asset or use the asset_param_get op on it since it can't be in the foreign assets array? I wonder if we should make an exception in this case and allow the asset to be "available" anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

WiIll do, on testing.

I was strongly considering adding a special case (as we did for the app address) that would allow the use of an asset that had been created in the same transaction (or txgroup?). But as for as I can tell, it's pretty much impossible to use, because no recipient could possibly be opted-in yet.

Copy link
Copy Markdown
Contributor

@jasonpaulos jasonpaulos Sep 13, 2021

Choose a reason for hiding this comment

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

Well theoretically the app could have another account rekeyed to it, so it could potentially opt that account into the new asset and perform a transfer.

The bigger issue I see is that there's currently no way to get the ID of the created asset. If we don't support this, there's no reason to support the special case of adding newly created assets to the "available" list.

(I suppose I'm ok with delaying the ID retrieval to a later update, since it's better to have acfg without that than no acfg at all.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd certainly like it too. Let me see if I can think of a decent interface that doesn't paint us into a corner. Ideas welcome.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Perhaps

itxna Logs X
itxn ConfigAsset

(and attendant itxn NumLogs, itxnas)

These would all return results from previous tx_submit execution. And perhaps they become itxn_begin etc.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 12, 2021

Codecov Report

Merging #2871 (9afb79b) into master (6afa86b) will increase coverage by 0.00%.
The diff coverage is 58.33%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #2871    +/-   ##
========================================
  Coverage   47.34%   47.34%            
========================================
  Files         351      351            
  Lines       56523    56711   +188     
========================================
+ Hits        26758    26852    +94     
- Misses      26758    26839    +81     
- Partials     3007     3020    +13     
Impacted Files Coverage Δ
config/consensus.go 84.28% <ø> (ø)
daemon/algod/api/server/v1/handlers/handlers.go 0.62% <0.00%> (-0.01%) ⬇️
daemon/algod/api/server/v2/utils.go 13.86% <0.00%> (-0.87%) ⬇️
data/pools/transactionPool.go 44.50% <0.00%> (ø)
data/transactions/logic/doc.go 82.75% <ø> (ø)
data/transactions/logic/fields.go 83.58% <ø> (ø)
data/transactions/logic/opcodes.go 100.00% <ø> (ø)
data/transactions/transaction.go 31.98% <0.00%> (-0.53%) ⬇️
data/transactions/verify/txn.go 44.29% <ø> (ø)
ledger/apply/asset.go 19.00% <0.00%> (-0.20%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6afa86b...9afb79b. Read the comment docs.

Comment thread data/transactions/logic/evalAppTxn_test.go Outdated
Comment thread data/transactions/logic/eval.go Outdated
Comment thread data/transactions/logic/evalAppTxn_test.go
Comment thread data/transactions/transaction.go
Comment thread ledger/eval_test.go Outdated
Comment thread ledger/eval.go
Comment on lines +907 to +912
// We are not allowing InnerTxns to have InnerTxns yet. Error if that happens.
for _, itx := range applyData.EvalDelta.InnerTxns {
if len(itx.ApplyData.EvalDelta.InnerTxns) > 0 {
return fmt.Errorf("inner transaction has inner transactions %v", itx)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is really needed, since we don't have any way to trigger this; but I don't see how having this check would be a bad thing either.

Comment thread data/transactions/logic/eval.go Outdated
Copy link
Copy Markdown
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

Overall looks great. I've added few minor code styling requests.

@jasonpaulos
Copy link
Copy Markdown
Contributor

Also, I did some local testing and pending transaction REST endpoint does not return the created asset ID when an inner txn creates an asset. See the implementation for convertTxn in daemon/algod/api/server/v2/utils.go.

@jannotti
Copy link
Copy Markdown
Contributor Author

Also, I did some local testing and pending transaction REST endpoint does not return the created asset ID when an inner txn creates an asset. See the implementation for convertTxn in daemon/algod/api/server/v2/utils.go.

Oh my. Thank you.

// change the fee. Do it in itxn_submit.
fee = basics.SubSaturate(fee, *cx.FeeCredit)
}
cx.subtxn.Txn.Header = transactions.Header{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi, a quick question. Should we assume the inner tx belongs to the same group/lease than the parent despite not present and should be added when calculating the ID of the inner tx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The inner txn has no id.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ahh ok, thanks for the info because, from the indexers and from AlgoExplorer point of view, we didn't know if these txs could be identified individually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indexer may well put a fake id in its internal table in order to place itxns in the same table with top-level. But you would obtain the info pertaining to an itxn only by asking for the top-level, and receive a tree back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, that's a good idea and will see with @winder the approach to show the same fake id.

Copy link
Copy Markdown

@agodnic agodnic Sep 14, 2021

Choose a reason for hiding this comment

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

Using fake IDs may allow Indexer/AlgoExplorer users to search for an inner transaction easily using a regular TXID.

If we do that, we should agree on a definition for those fake txids. Maybe it could be something like digest(tx, parent id, offset)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't love the fake txid thing. I hope we'll keep it an implementation detail and avoid confusing users.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And what about adding an "inner transaction index" field to the subtxn. Node must check this field is not defined or zero when a TX is submitted. This plus the first/last round you already added, should do the work.

@jannotti
Copy link
Copy Markdown
Contributor Author

Closed in favor of #2883

@jannotti jannotti closed this Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants