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

Add begin_block function to contract #2

Closed
frankbraun opened this issue Mar 9, 2021 · 9 comments
Closed

Add begin_block function to contract #2

frankbraun opened this issue Mar 9, 2021 · 9 comments
Assignees
Labels
C-enhancement Category: New feature or request

Comments

@frankbraun
Copy link
Contributor

For the evm-bully we need a begin_block function.
The begin_block function should allow to set the necessary block context the evm-bully needs to replay transactions successfully (see aurora-is-near/evm-bully#3).
It should only be available in a testing version of the contract.

artob added a commit that referenced this issue Mar 9, 2021
@artob artob changed the title Add begin_block function to EVM smart contract Add begin_block function to contract Mar 10, 2021
artob added a commit that referenced this issue Mar 12, 2021
artob added a commit that referenced this issue Mar 12, 2021
@artob
Copy link
Contributor

artob commented Mar 12, 2021

@frankbraun Commits 3f15f06 and 78c7c1f added the parameter definition for begin_block:

/// Borsh-encoded parameters for the `begin_block` function.
#[derive(BorshSerialize, BorshDeserialize)]
pub struct BeginBlockArgs {
/// The current block's hash (for replayer use).
pub hash: RawU256,
/// The current block's beneficiary address.
pub coinbase: RawU256,
/// The current block's timestamp (in seconds since the Unix epoch).
pub timestamp: RawU256,
/// The current block's number (the genesis block is number zero).
pub number: RawU256,
/// The current block's difficulty.
pub difficulty: RawU256,
/// The current block's gas limit.
pub gaslimit: RawU256,
}

Note that the input to the begin_block function is Borsh-encoded, not JSON-encoded.

@frankbraun
Copy link
Contributor Author

This needs to be put behind a feature flag and, as @ilblackdragon noted, should only be callable by the owner.

@artob
Copy link
Contributor

artob commented Mar 31, 2021

This needs to be put behind a feature flag and, as @ilblackdragon noted, should only be callable by the owner.

As of 529a751, these methods are now only callable by the owner.

@joshuajbouw
Copy link
Contributor

Isn't this closed now?

@artob
Copy link
Contributor

artob commented May 12, 2021

@frankbraun Can this be closed? Please close issues when they are done.

@frankbraun
Copy link
Contributor Author

The evm-bully calls begin_block with the correct arguments and they are decoded in the function in the contract:

let _args: BeginBlockArgs = sdk::read_input_borsh().sdk_unwrap();

However, the engine state is not updated correctly yet. @joshuajbouw, could you take a stab at this please? You are deeper into the engine. Might be related to #122

@frankbraun frankbraun assigned joshuajbouw and unassigned frankbraun Jun 4, 2021
@joshuajbouw
Copy link
Contributor

joshuajbouw commented Jun 4, 2021

Yes, still looking into it. @frankbraun

@mrLSD
Copy link
Member

mrLSD commented Jul 1, 2021

@frankbraun Is that Issue still should be open?

@joshuajbouw
Copy link
Contributor

Considering that this functionality has been added and there are other issues that are in a succession of this, I'm going to close it.

mrLSD pushed a commit that referenced this issue Feb 22, 2023
aleksuss added a commit that referenced this issue Mar 1, 2023
aleksuss added a commit that referenced this issue Mar 3, 2023
* chore: apply nursery and pedantic clippy lints

* chore: apply nursery and pedantic clippy lints #2

* changes proposed by code review

* chore: fix build after merge

* chore: remove unused constants
lempire123 pushed a commit that referenced this issue Apr 5, 2023
* chore: apply nursery and pedantic clippy lints

* chore: apply nursery and pedantic clippy lints #2

* changes proposed by code review

* chore: fix build after merge

* chore: remove unused constants
birchmd pushed a commit that referenced this issue Apr 5, 2023
* chore: apply nursery and pedantic clippy lints

* chore: apply nursery and pedantic clippy lints #2

* changes proposed by code review

* chore: fix build after merge

* chore: remove unused constants
aleksuss added a commit that referenced this issue Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants