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

docs: Adding details about the information that get_execution_info syscall returns. #918

Merged
merged 8 commits into from
Mar 13, 2024

Conversation

stoobie
Copy link
Collaborator

@stoobie stoobie commented Nov 6, 2023

Description of the Changes

This PR addresses issue #917

PR Preview URL

get_execution_info

Check List

  • Changes have been done against dev branch, and PR does not conflict
  • PR title follows the convention: <docs/feat/fix/chore>(optional scope): <description>, e.g: fix: minor typos in code

This change is Reviewable

@stoobie stoobie added the enhancement New feature or request label Nov 6, 2023
@stoobie stoobie marked this pull request as draft November 6, 2023 09:28
Copy link

github-actions bot commented Nov 6, 2023

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

@stoobie stoobie changed the base branch from dev to master November 28, 2023 07:46
Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

@stoobie stoobie changed the base branch from master-to_be_deleted to main December 31, 2023 09:00
@stoobie stoobie force-pushed the steve/get_execution_info_syscall_example branch from a7fc3f1 to f559879 Compare March 11, 2024 16:23
Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

@stoobie stoobie marked this pull request as ready for review March 12, 2024 14:33
@stoobie stoobie requested review from ArniStarkware and removed request for ArielElp and leo-starkware March 12, 2024 14:33
Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

Copy link
Collaborator

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 6 unresolved discussions (waiting on @stoobie)


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 2 at r2 (raw file):

[id="execution_info"]
= Execution information for the current block

Are we sure we like this headline?

I want to say that the tx_info (and the rest of the parameters that are even more specific than the tx_info) are not the same tx info for all transactions run in a given block...
The only think that is for the current block in this context is the block info...

Code quote:

[id="execution_info"]
= Execution information for the current block

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 11 at r2 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`block_info: Box<BlockInfo>`:: Contains information about a block. For details, see xref:#block_info[]

Does the link to block_info work here?

Code quote:

`block_info: Box<BlockInfo>`:: Contains information about a block. For details, see xref:#block_info[]

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 12 at r2 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`block_info: Box<BlockInfo>`:: Contains information about a block. For details, see xref:#block_info[]
`tx_info: Box<TxInfo>`:: Contains information about a transaction.

add xref to tx_info.

Suggestion:

`tx_info: Box<TxInfo>`:: Contains information about a transaction.  For details, see xref#tx_info[]

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 22 at r2 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_block_number_: u64`:: The number of the block that is currently being executed. When called from an account contracts +`__validate__`+ function, this value is rounded down to the nearest multiple of 100.
`_block_timestamp_: u64`:: The timestamp showing the creation time of the block. When called from an account contracts +`__validate__`+ function, this value is rounded down to the nearest hour. #Is this in UTC time? Or seconds since the Unix epoch? Or something else?#

I am not sure. I think it is UTC time...

Code quote:

`_block_timestamp_: u64`:: The timestamp showing the creation time of the block. When called from an account contracts +`__validate__`+ function, this value is rounded down to the nearest hour. #Is this in UTC time? Or seconds since the Unix epoch? Or something else?#

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 36 at r2 (raw file):

This field can be used to prevent replay of testnet transactions on mainnet.
`_nonce_: felt252`:: The transaction's nonce.
`_resource_bounds_: Span<ResourceBounds>`:: A span of `ResourceBounds` structs.

Not sure I am doing it right - but I believe I have the right spirit.

Suggestion:

`_resource_bounds_: Span<ResourceBounds>`:: A span of `ResourceBounds` structs. For details, see xref#resource_bounds[]

@ArniStarkware
Copy link
Collaborator

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 2 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Are we sure we like this headline?

I want to say that the tx_info (and the rest of the parameters that are even more specific than the tx_info) are not the same tx info for all transactions run in a given block...
The only think that is for the current block in this context is the block info...

In this context, the only thing* that is for the current block is the block info.

@stoobie stoobie requested a review from ArniStarkware March 13, 2024 12:33
Copy link
Collaborator Author

@stoobie stoobie left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 6 unresolved discussions (waiting on @ArniStarkware)


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 2 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

In this context, the only thing* that is for the current block is the block info.

OK. I changed to "Block execution info" WDYT?


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 11 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Does the link to block_info work here?

Done. Fixed.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 12 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

add xref to tx_info.

Done.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 22 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

I am not sure. I think it is UTC time...

Who would know the answer?


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 36 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Not sure I am doing it right - but I believe I have the right spirit.

Done. :)

stoobie added 2 commits March 13, 2024 14:33
…:starknet-io/starknet-docs into steve/get_execution_info_syscall_example
Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

@ArniStarkware
Copy link
Collaborator

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 22 at r2 (raw file):

Previously, stoobie (Steve Goodman) wrote…

Who would know the answer?

OK, I traced back the source of truth for this number.
Here is its creation: https://github.com/starkware-industries/starkware/blob/5dd1a061c90b3a52889d9a8356040ec29e45fce8/src/services/everest/batcher/suggester/suggester.py#L206

Under the hood, this time function is just this time function: https://docs.python.org/3/library/time.html
Which uses UTC

Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

Copy link
Collaborator

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 7 unresolved discussions (waiting on @stoobie)


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 2 at r2 (raw file):

Previously, stoobie (Steve Goodman) wrote…

OK. I changed to "Block execution info" WDYT?

How about Execution information? No specific refer to the block.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 22 at r4 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_block_number_: u64`:: The number of the block that is currently being executed. When called from an account contracts +`__validate__`+ function, this value is rounded down to the nearest multiple of 100.

true for any __validate__ type function. See the comment below.

Code quote:

When called from an account contracts +`__validate__`+ function,

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 23 at r4 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_block_number_: u64`:: The number of the block that is currently being executed. When called from an account contracts +`__validate__`+ function, this value is rounded down to the nearest multiple of 100.
`_block_timestamp_: u64`:: The timestamp showing the creation time of the block, in seconds since the Unix epoch, based on UTC time, rounded down to the nearest second. When called from an account contract's +`__validate__`+ function, this value is rounded down to the nearest hour.

true for any __validate__ type function. See the comment below.

Code quote:

When called from an account contract's +`__validate__`+ function, this value is rounded down to the nearest hour.

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 30 at r4 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_version_: felt252`:: The version of the transaction. It is fixed (currently, 1) in the OS, and should be signed by the account contract. This field allows invalidating old transactions, whenever the meaning of the other transaction fields is changed (in the OS).

Suggestion:

`_version_: felt252`:: The version of the transaction. It is fixed (currently, 3) in the OS, and should be signed by the account contract. This field allows invalidating old transactions, whenever the meaning of the other transaction fields is changed (in the OS).

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 68 at r4 (raw file):

In Cairo 1.0, this single system call contains all information for a block, transaction, and execution context.

When an account's `+__validate__+` function calls `get_execution_info`:

I am not sure if this is a technical fix.

This statement is true for any "__validate__ type" function.
I mean to say this is true for either of the functions: __validate__, __validate_declare__, __validate_deploy__.

Code quote:

When an account's `+__validate__+` function calls `get_execution_info`:

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 71 at r4 (raw file):

* `block_timestamp` returns the hour, rounded down to the nearest hour.
* `block_number` returns the block number, rounded down to the nearest multiple of 100.

A different topic than my last comment:
Here is a suggestion.

It is odd to state what the syscall returns in validate mode but not explain what is returned in any other case.

To see what is usually returned by this syscall, one needs to look into the other file first. maybe link it here as well?
I like that this information is present here. It will help any confused developer dealing with this syscall (dealing with odd bugs related to validate).

Suggestion:

When an account's `+__validate__+` function calls `get_execution_info` some of the returned values are modified:

* `block_timestamp` returns the hour, rounded down to the nearest hour.
* `block_number` returns the block number, rounded down to the nearest multiple of 100.

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 82 at r4 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
link:https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/info.cairo#L8[`ExecutionInfo`]:: A struct that contains information about the currently executing block and the transactions in the block.

The information is related to either:
The currently executed function.
The currently executed transaction.
The currently executed block.

all of them are tightly connected to the current run. Non of the info is referring to other transactions.

Suggestion:

link:https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/info.cairo#L8[`ExecutionInfo`]:: A struct that contains information about the currently executing function, transaction and block.

@stoobie stoobie requested a review from ArniStarkware March 13, 2024 14:41
Copy link
Collaborator Author

@stoobie stoobie left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 7 unresolved discussions (waiting on @ArniStarkware)


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 2 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

How about Execution information? No specific refer to the block.

Done.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 22 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

true for any __validate__ type function. See the comment below.

Done.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 23 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

true for any __validate__ type function. See the comment below.

Done.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 30 at r4 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_version_: felt252`:: The version of the transaction. It is fixed (currently, 1) in the OS, and should be signed by the account contract. This field allows invalidating old transactions, whenever the meaning of the other transaction fields is changed (in the OS).

Done.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 68 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

I am not sure if this is a technical fix.

This statement is true for any "__validate__ type" function.
I mean to say this is true for either of the functions: __validate__, __validate_declare__, __validate_deploy__.

Done.


components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 71 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

A different topic than my last comment:
Here is a suggestion.

It is odd to state what the syscall returns in validate mode but not explain what is returned in any other case.

To see what is usually returned by this syscall, one needs to look into the other file first. maybe link it here as well?
I like that this information is present here. It will help any confused developer dealing with this syscall (dealing with odd bugs related to validate).

I moved the link to the other page to the top of this section. How's that?

I changed the text to:

When an account's `+__validate__+`, +`__validate_deploy__`+, or +`__validate_declare__`+ function calls `get_execution_info`, the return values for `block_timestamp` and `block_number` are modified as follows:

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 82 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

The information is related to either:
The currently executed function.
The currently executed transaction.
The currently executed block.

all of them are tightly connected to the current run. Non of the info is referring to other transactions.

Done.

Copy link

Your preview build is ready! ✨ Check the following link in 1-2 minutes: https://starknet-io.github.io/starknet-docs/pr-918/documentation/ .

Copy link
Collaborator

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 2 files at r3, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @stoobie)

@ArniStarkware
Copy link
Collaborator

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 22 at r5 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_block_number_: u64`:: The number of the block that is currently being executed. When called from an account contract's +`__validate__`+, +`__validate_deploy__`+, or +`__validate_declare__`+ function, this value is rounded down to the nearest multiple of 100.

Suggestion:

`_block_number_: u64`:: The number of the block that is currently being executed. When called from an account contract's +`__validate__`+, +`__validate_deploy__`+, +`__validate_declare__`+, or +`constructor`+ function, this value is rounded down to the nearest multiple of 100.

@ArniStarkware
Copy link
Collaborator

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/execution_info.adoc line 23 at r5 (raw file):

[horizontal,labelwidth="25",role="stripes-odd"]
`_block_number_: u64`:: The number of the block that is currently being executed. When called from an account contract's +`__validate__`+, +`__validate_deploy__`+, or +`__validate_declare__`+ function, this value is rounded down to the nearest multiple of 100.
`_block_timestamp_: u64`:: The timestamp showing the creation time of the block, in seconds since the Unix epoch, based on UTC time, rounded down to the nearest second. When called from an account contract's +`__validate__`+, +`__validate_deploy__`+, or +`__validate_declare__`+ function, this value is rounded down to the nearest hour.

Suggestion:

When called from an account contract's +`__validate__`+, +`__validate_deploy__`+, +`__validate_declare__`+, or +`constructor`+ function, this value is rounded down to the nearest hour.

@ArniStarkware
Copy link
Collaborator

components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc line 68 at r5 (raw file):

This single system call contains all information for a block, transaction, and execution context.

When an account's `+__validate__+`, +`__validate_deploy__`+, or +`__validate_declare__`+ function calls `get_execution_info`, the return values for `block_timestamp` and `block_number` are modified as follows:

Suggestion:

When an account's `+__validate__+`, +`__validate_deploy__`+, +`__validate_declare__`+, or +`constructor`+ function calls `get_execution_info`, the return values for `block_timestamp` and `block_number` are modified as follows:

@stoobie stoobie merged commit 023f837 into main Mar 13, 2024
3 of 4 checks passed
@stoobie stoobie deleted the steve/get_execution_info_syscall_example branch March 13, 2024 18:06
xiaolou86 pushed a commit to xiaolou86/starknet-docs that referenced this pull request Apr 7, 2024
…syscall returns. (starknet-io#918)

* Adding details about the information that `get_execution_info` syscall returns.

* Removed extraneous code block delimiter.

* Added 0.13.1 info, and added new page describing execution info.

* Update components/Starknet/modules/architecture_and_concepts/nav.adoc

* SME comments

* Added details for `block_timestamp`

* SME comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants