Skip to content

Implement EIP3541#1240

Merged
holgerd77 merged 3 commits into
masterfrom
eip3541
May 9, 2021
Merged

Implement EIP3541#1240
holgerd77 merged 3 commits into
masterfrom
eip3541

Conversation

@jochem-brouwer

@jochem-brouwer jochem-brouwer commented May 2, 2021

Copy link
Copy Markdown
Member

Implements EIP3541.

Verify that if we deploy 0xEF on 3541 activated commons we should consume all gas (this is most likely the case). (confirmed on ACD)

@codecov

codecov Bot commented May 2, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1240 (b7b4a5c) into master (a459a0e) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

Flag Coverage Δ
block 82.66% <ø> (-0.34%) ⬇️
blockchain 84.16% <ø> (ø)
client 84.75% <ø> (ø)
common 86.92% <ø> (ø)
devp2p 84.13% <ø> (-0.15%) ⬇️
ethash 82.08% <ø> (ø)
tx 88.68% <ø> (ø)
vm 81.05% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@jochem-brouwer jochem-brouwer marked this pull request as ready for review May 3, 2021 13:47
@jochem-brouwer jochem-brouwer requested review from holgerd77 and ryanio May 3, 2021 13:47
@jochem-brouwer

Copy link
Copy Markdown
Member Author

Ok also added extensive tests here, so I am pretty sure that we are correct here as well 😄

@holgerd77 holgerd77 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi Jochem,
had a first look here, thanks a lot for taking on these two additional EIPs as well, you are really our hero atm! 😄 Have some comments, generally the whole PR looks great though with these extensive tests and everything.

Comment thread packages/vm/lib/evm/evm.ts Outdated
}
}

export function EIP3541ViolationResult(gasLimit: BN): ExecResult {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe I am missing something, but where is this function actually called? 😜

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Heh. Oops.

Comment thread packages/vm/lib/exceptions.ts Outdated
INVALID_BEGINSUB = 'invalid BEGINSUB',
INVALID_RETURNSUB = 'invalid RETURNSUB',
INVALID_JUMPSUB = 'invalid JUMPSUB',
EIP3541_VIOLATION = 'eip3541 violation: cannot put contracts starting with 0xEF bytecode',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we can use something more semantically expressive here - a bit analog to the last discussions we had coming to the conclusion to rather avoid EIP numbers for names? 🤔

Suggestion (not sure yet though):

  • RESTRICTED_STARTING_BYTECODE

Or similar.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(same a bit for the function name from above)

@axic axic May 4, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In some place seen INVALID_CODE (geth) or INVALID_BYTECODE, and in EVMC we also had CONTRACT_VALIDATION_FAILED from earlier, that may be also a good one in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah yeah, that's better, my suggestion is likely still to specific, I like INVALID_BYTECODE. 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But CONTRACT_VALIDATION_FAILED might be a bit better targeted, so eventually more suited.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably INVALID_CODE/INVALID_BYTECODE seems to be the best for now, and if any "real validation" is rolled out later (such as EIP-3540), then the CONTRACT_VALIDATION_FAILED error could be introduced in addition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I personally like INVALID_BYTECODE.

st.end()
})

t.test('should not deploy contracts starting with 0xEF using CREATE', async (st) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These header are not matching the test cases applied with both the success and failure cases, maybe just drop the "should not" here (and other occurrences where it applies)

@jochem-brouwer

Copy link
Copy Markdown
Member Author

Updated and rebased. Ready for re-review @holgerd77 @ryanio

@holgerd77 holgerd77 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, really nice, looks good to me. 🙂


code = await vm.stateManager.getContractCode(created!)

st.ok(code.length > 0, 'did deposit code')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice test case! 😄

st.ok(code.length > 0, 'did deposit code')

st.end()
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Important counter case (with all the last 1559 experiences 😛 ).

@holgerd77 holgerd77 merged commit dfc25ee into master May 9, 2021
@holgerd77 holgerd77 deleted the eip3541 branch May 9, 2021 08:18
@axic

axic commented May 9, 2021

Copy link
Copy Markdown
Member

Could you run ethereumjs no this PR by any chance to confirm everything is in order: ethereum/tests#835 ?

@jochem-brouwer

Copy link
Copy Markdown
Member Author

@axic Yup will do 😄

@holgerd77

Copy link
Copy Markdown
Member

@jochem-brouwer @axic I am on it, see #1247

@holgerd77

Copy link
Copy Markdown
Member

@axic @jochem-brouwer Ok, I am through (see comments on linked PR), two test runs which might need some further investigation:

undefinedOpcodeFirstByte: all test runs with the EIP deactivated are also passing
Opcodes_TransactionInit: all test cases except one with the EIP deactivated are also passing

This might either hint to the test cases being non-testing things but alternatively also to an error in our implementation (we might apply the EIP-3541 condition to a pre-EIP-3541 state).

Likely need to stop for now and pass this on.

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.

3 participants