Skip to content

Commit

Permalink
Modify EIP-7702 Txn impl per pectra-devnet-4 specs (#12416)
Browse files Browse the repository at this point in the history
  • Loading branch information
somnathb1 authored and yperbasis committed Oct 25, 2024
1 parent 3ba3e0a commit 8a55232
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 5 additions & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype
}

// 7. set authority code
st.state.SetCode(authority, types.AddressToDelegation(auth.Address))
if auth.Address == (libcommon.Address{}) {
st.state.SetCode(authority, nil)
} else {
st.state.SetCode(authority, types.AddressToDelegation(auth.Address))
}

// 8. increase the nonce of authority
st.state.SetNonce(authority, authorityNonce+1)
Expand Down
10 changes: 10 additions & 0 deletions core/types/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ func (ath *Authorization) RecoverSigner(data *bytes.Buffer, b []byte) (*libcommo
copy(sig[32-len(r):32], r)
copy(sig[64-len(s):64], s)

if ath.Nonce == 1<<64-1 {
return nil, errors.New("Failed assertion: auth.nonce < 2**64 - 1")
}
if _, overflow := ath.ChainID.Uint64WithOverflow(); overflow {
return nil, errors.New("Failed assertion: auth.chain_id < 2**64")
}
if ath.V.GtUint64(1 << 8) {
return nil, errors.New("Failed assertion: auth.y_parity < 2**8")
}

if ath.V.Eq(u256.Num0) || ath.V.Eq(u256.Num1) {
sig[64] = byte(ath.V.Uint64())
} else {
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/common/fixedgas/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ const (

// EIP-7702: set code tx
PerEmptyAccountCost = 25000
PerAuthBaseCost = 2500
PerAuthBaseCost = 12500
)
9 changes: 0 additions & 9 deletions tests/exec_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ func TestExecutionSpec(t *testing.T) {
bt := new(testMatcher)

dir := filepath.Join(".", "execution-spec-tests")

// bt.skipLoad(`^`)

// // TODO(yperbasis) make it work
// bt.skipLoad(`^prague/eip2935_historical_block_hashes_from_state/block_hashes/block_hashes_history.json`)
// bt.skipLoad(`^prague/eip7251_consolidations/`)
// bt.skipLoad(`^prague/eip7685_general_purpose_el_requests/`)
// bt.skipLoad(`^prague/eip7002_el_triggerable_withdrawals/`)
bt.skipLoad(`^prague/eip7702_set_code_tx/`)
checkStateRoot := true

bt.walk(t, dir, func(t *testing.T, name string, test *BlockTest) {
Expand Down

0 comments on commit 8a55232

Please sign in to comment.