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

fix: always take gas price from previous block #9638

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

Longarithm
Copy link
Member

Part of #9618.

In post-state-root, chunk production is moved before block production, thus we don't have a Block during applying chunk anymore. We need to make sure that all necessary data is still propagated to Runtime::apply.

It should've not have been an error for gas price, as it is taken from previous block in the general case:

let gas_price = prev_block.header().gas_price();
However, when there is no chunk, there seem to be a very old error - it is taken from the same block.

Luckily, after ProtocolFeature::FixApplyChunks it is not an issue: when there is no chunk, gas price is not used at all. So I just start taking it from previous block for consistency, to ensure that in post-state-root current block can be safely removed.

Full context: https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

Testing

As the change must be no-op, existing tests are enough.

@Longarithm Longarithm self-assigned this Oct 5, 2023
@Longarithm Longarithm added the A-chain Area: Chain, client & related label Oct 5, 2023
@Longarithm Longarithm requested a review from pugachAG October 5, 2023 09:51
@Longarithm Longarithm marked this pull request as ready for review October 5, 2023 09:52
@Longarithm Longarithm requested a review from a team as a code owner October 5, 2023 09:52
@Longarithm Longarithm added this pull request to the merge queue Oct 6, 2023
Merged via the queue into near:master with commit 3fc242f Oct 6, 2023
@Longarithm Longarithm deleted the prev-gas-price branch October 6, 2023 11:20
nikurt pushed a commit that referenced this pull request Oct 9, 2023
Part of #9618.

In post-state-root, chunk production is moved before block production,
thus we don't have a `Block` during applying chunk anymore. We need to
make sure that all necessary data is still propagated to
`Runtime::apply`.

It should've not have been an error for gas price, as it is taken from
previous block in the general case:
https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
However, when there is no chunk, there seem to be a very old error - it
is taken from the same block.

Luckily, after `ProtocolFeature::FixApplyChunks` it is not an issue:
when there is no chunk, gas price is not used at all. So I just start
taking it from previous block for consistency, to ensure that in
post-state-root current block can be safely removed.

Full context:
https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

## Testing

As the change must be no-op, existing tests are enough.
nikurt pushed a commit that referenced this pull request Oct 11, 2023
Part of #9618.

In post-state-root, chunk production is moved before block production,
thus we don't have a `Block` during applying chunk anymore. We need to
make sure that all necessary data is still propagated to
`Runtime::apply`.

It should've not have been an error for gas price, as it is taken from
previous block in the general case:
https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
However, when there is no chunk, there seem to be a very old error - it
is taken from the same block.

Luckily, after `ProtocolFeature::FixApplyChunks` it is not an issue:
when there is no chunk, gas price is not used at all. So I just start
taking it from previous block for consistency, to ensure that in
post-state-root current block can be safely removed.

Full context:
https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

## Testing

As the change must be no-op, existing tests are enough.
nikurt pushed a commit that referenced this pull request Oct 16, 2023
Part of #9618.

In post-state-root, chunk production is moved before block production,
thus we don't have a `Block` during applying chunk anymore. We need to
make sure that all necessary data is still propagated to
`Runtime::apply`.

It should've not have been an error for gas price, as it is taken from
previous block in the general case:
https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
However, when there is no chunk, there seem to be a very old error - it
is taken from the same block.

Luckily, after `ProtocolFeature::FixApplyChunks` it is not an issue:
when there is no chunk, gas price is not used at all. So I just start
taking it from previous block for consistency, to ensure that in
post-state-root current block can be safely removed.

Full context:
https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

## Testing

As the change must be no-op, existing tests are enough.
nikurt pushed a commit that referenced this pull request Oct 19, 2023
Part of #9618.

In post-state-root, chunk production is moved before block production,
thus we don't have a `Block` during applying chunk anymore. We need to
make sure that all necessary data is still propagated to
`Runtime::apply`.

It should've not have been an error for gas price, as it is taken from
previous block in the general case:
https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
However, when there is no chunk, there seem to be a very old error - it
is taken from the same block.

Luckily, after `ProtocolFeature::FixApplyChunks` it is not an issue:
when there is no chunk, gas price is not used at all. So I just start
taking it from previous block for consistency, to ensure that in
post-state-root current block can be safely removed.

Full context:
https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

## Testing

As the change must be no-op, existing tests are enough.
nikurt pushed a commit that referenced this pull request Oct 23, 2023
Part of #9618.

In post-state-root, chunk production is moved before block production,
thus we don't have a `Block` during applying chunk anymore. We need to
make sure that all necessary data is still propagated to
`Runtime::apply`.

It should've not have been an error for gas price, as it is taken from
previous block in the general case:
https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
However, when there is no chunk, there seem to be a very old error - it
is taken from the same block.

Luckily, after `ProtocolFeature::FixApplyChunks` it is not an issue:
when there is no chunk, gas price is not used at all. So I just start
taking it from previous block for consistency, to ensure that in
post-state-root current block can be safely removed.

Full context:
https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

## Testing

As the change must be no-op, existing tests are enough.
nikurt pushed a commit that referenced this pull request Oct 24, 2023
Part of #9618.

In post-state-root, chunk production is moved before block production,
thus we don't have a `Block` during applying chunk anymore. We need to
make sure that all necessary data is still propagated to
`Runtime::apply`.

It should've not have been an error for gas price, as it is taken from
previous block in the general case:
https://github.com/near/nearcore/blob/9c8d0bbec6a71876bb3317db2ade425f0077a184/chain/chain/src/chain.rs#L4120
However, when there is no chunk, there seem to be a very old error - it
is taken from the same block.

Luckily, after `ProtocolFeature::FixApplyChunks` it is not an issue:
when there is no chunk, gas price is not used at all. So I just start
taking it from previous block for consistency, to ensure that in
post-state-root current block can be safely removed.

Full context:
https://near.zulipchat.com/#narrow/stream/295302-general/topic/.E2.9C.94.20gas.20price.20inconsistency/near/394894144

## Testing

As the change must be no-op, existing tests are enough.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-chain Area: Chain, client & related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants