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

Added 7702tx case to modInvokeEmit #1169

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/hivechain/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/hivechain/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
48 changes: 48 additions & 0 deletions cmd/hivechain/mod_txinvoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -152,6 +159,47 @@ func (m *modInvokeEmit) apply(ctx *genBlockContext) bool {
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))
}
Expand Down