From 846f4c89cbabc46e3841228bf9dccedb9ab42ecc Mon Sep 17 00:00:00 2001 From: pellekrab <78560773+PelleKrab@users.noreply.github.com> Date: Fri, 27 Sep 2024 22:10:34 -0600 Subject: [PATCH 1/2] Added 7702tx case to modInvokeEmit --- cmd/hivechain/generate.go | 2 +- cmd/hivechain/mod.go | 2 +- cmd/hivechain/mod_txinvoke.go | 48 +++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/cmd/hivechain/generate.go b/cmd/hivechain/generate.go index 6d68680b91..cd0ebf49bd 100644 --- a/cmd/hivechain/generate.go +++ b/cmd/hivechain/generate.go @@ -152,7 +152,7 @@ func (g *generator) importChain(engine consensus.Engine, chain []*types.Block) ( cacheconfig := core.DefaultCacheConfigWithScheme("hash") cacheconfig.Preimages = true vmconfig := vm.Config{EnablePreimageRecording: true} - blockchain, err := core.NewBlockChain(db, cacheconfig, g.genesis, nil, engine, vmconfig, nil, nil) + blockchain, err := core.NewBlockChain(db, cacheconfig, g.genesis, nil, engine, vmconfig, nil) if err != nil { return nil, fmt.Errorf("can't create blockchain: %v", err) } diff --git a/cmd/hivechain/mod.go b/cmd/hivechain/mod.go index d39df135b2..b0e3883614 100644 --- a/cmd/hivechain/mod.go +++ b/cmd/hivechain/mod.go @@ -73,7 +73,7 @@ func (ctx *genBlockContext) TxCreateIntrinsicGas(data []byte) uint64 { isHomestead := genesis.Config.IsHomestead(ctx.block.Number()) isEIP2028 := genesis.Config.IsIstanbul(ctx.block.Number()) isEIP3860 := genesis.Config.IsShanghai(ctx.block.Number(), ctx.block.Timestamp()) - igas, err := core.IntrinsicGas(data, nil, true, isHomestead, isEIP2028, isEIP3860) + igas, err := core.IntrinsicGas(data, nil, nil, true, isHomestead, isEIP2028, isEIP3860) if err != nil { panic(err) } diff --git a/cmd/hivechain/mod_txinvoke.go b/cmd/hivechain/mod_txinvoke.go index fa6c879908..00d02fbbea 100644 --- a/cmd/hivechain/mod_txinvoke.go +++ b/cmd/hivechain/mod_txinvoke.go @@ -39,6 +39,13 @@ func init() { gasLimit: 100000, } }) + + register("tx-emit-eip7702", func() blockModifier { + return &modInvokeEmit{ + txType: types.SetCodeTxType, + gasLimit: 100000, + } + }) } // modInvokeEmit creates transactions that invoke the 'emit' contract. @@ -151,6 +158,47 @@ func (m *modInvokeEmit) apply(ctx *genBlockContext) bool { BlobHashes: sidecar.BlobHashes(), Sidecar: sidecar, } + + case types.SetCodeTxType: + if !ctx.ChainConfig().IsPrague(ctx.Number(), ctx.Timestamp()) { + return false + } + + auth := &types.Authorization{ + ChainID: big.NewInt(1), + Address: recipient, + Nonce: uint64(1), + V: big.NewInt(1), + R: big.NewInt(1), + S: big.NewInt(1), + } + + signedAuth, err := types.SignAuth(auth, sender.key) + if err != nil { + return false + } + + authList := types.AuthorizationList{signedAuth} + + txdata = &types.SetCodeTx{ + Nonce: ctx.AccountNonce(sender.addr), + GasTipCap: uint256.NewInt(1), + GasFeeCap: uint256.MustFromBig(ctx.TxGasFeeCap()), + Gas: m.gasLimit, + To: recipient, + Value: uint256.NewInt(3), + Data: calldata, + AccessList: types.AccessList{ + { + Address: recipient, + StorageKeys: []common.Hash{{}, datahash}, + }, + }, + AuthList: authList, + V: uint256.NewInt(1), + R: uint256.NewInt(1), + S: uint256.NewInt(1), + } default: panic(fmt.Errorf("unhandled tx type %d", m.txType)) From e5b820512d771e43832c61c944962c5bbc4aecbe Mon Sep 17 00:00:00 2001 From: pellekrab <78560773+PelleKrab@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:08:31 -0600 Subject: [PATCH 2/2] fmt --- cmd/hivechain/mod_txinvoke.go | 80 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/cmd/hivechain/mod_txinvoke.go b/cmd/hivechain/mod_txinvoke.go index 00d02fbbea..eb0bb8a297 100644 --- a/cmd/hivechain/mod_txinvoke.go +++ b/cmd/hivechain/mod_txinvoke.go @@ -39,7 +39,7 @@ func init() { gasLimit: 100000, } }) - + register("tx-emit-eip7702", func() blockModifier { return &modInvokeEmit{ txType: types.SetCodeTxType, @@ -158,47 +158,47 @@ func (m *modInvokeEmit) apply(ctx *genBlockContext) bool { BlobHashes: sidecar.BlobHashes(), Sidecar: sidecar, } - + case types.SetCodeTxType: - if !ctx.ChainConfig().IsPrague(ctx.Number(), ctx.Timestamp()) { - return false - } - - auth := &types.Authorization{ - ChainID: big.NewInt(1), - Address: recipient, - Nonce: uint64(1), - V: big.NewInt(1), - R: big.NewInt(1), - S: big.NewInt(1), - } - - signedAuth, err := types.SignAuth(auth, sender.key) - if err != nil { - return false - } - - authList := types.AuthorizationList{signedAuth} - - txdata = &types.SetCodeTx{ - Nonce: ctx.AccountNonce(sender.addr), - GasTipCap: uint256.NewInt(1), - GasFeeCap: uint256.MustFromBig(ctx.TxGasFeeCap()), - Gas: m.gasLimit, - To: recipient, - Value: uint256.NewInt(3), - Data: calldata, - AccessList: types.AccessList{ - { - Address: recipient, - StorageKeys: []common.Hash{{}, datahash}, - }, + if !ctx.ChainConfig().IsPrague(ctx.Number(), ctx.Timestamp()) { + return false + } + + auth := &types.Authorization{ + ChainID: big.NewInt(1), + Address: recipient, + Nonce: uint64(1), + V: big.NewInt(1), + R: big.NewInt(1), + S: big.NewInt(1), + } + + signedAuth, err := types.SignAuth(auth, sender.key) + if err != nil { + return false + } + + authList := types.AuthorizationList{signedAuth} + + txdata = &types.SetCodeTx{ + Nonce: ctx.AccountNonce(sender.addr), + GasTipCap: uint256.NewInt(1), + GasFeeCap: uint256.MustFromBig(ctx.TxGasFeeCap()), + Gas: m.gasLimit, + To: recipient, + Value: uint256.NewInt(3), + Data: calldata, + AccessList: types.AccessList{ + { + Address: recipient, + StorageKeys: []common.Hash{{}, datahash}, }, - AuthList: authList, - V: uint256.NewInt(1), - R: uint256.NewInt(1), - S: uint256.NewInt(1), - } + }, + AuthList: authList, + V: uint256.NewInt(1), + R: uint256.NewInt(1), + S: uint256.NewInt(1), + } default: panic(fmt.Errorf("unhandled tx type %d", m.txType))