Skip to content
Closed
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
6 changes: 6 additions & 0 deletions cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,14 @@
r.Address = sender
}
// Check intrinsic gas
<<<<<<< HEAD

Check failure on line 136 in cmd/evm/internal/t8ntool/transaction.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '<<' (typecheck)
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil,
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0)); err != nil {
=======

Check failure on line 139 in cmd/evm/internal/t8ntool/transaction.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '==' (typecheck)
rules := chainConfig.Rules(common.Big0, true, 0)
gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, &rules)
if err != nil {
>>>>>>> 6f1b514f2 (core: refactor IntrinsicGas function to accept rules parameter)

Check failure on line 143 in cmd/evm/internal/t8ntool/transaction.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '>>' (typecheck)
r.Error = err
results = append(results, r)
continue
Expand Down Expand Up @@ -174,4 +180,4 @@
out, err := json.MarshalIndent(results, "", " ")
fmt.Println(string(out))
return err
}

Check failure on line 183 in cmd/evm/internal/t8ntool/transaction.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected '}', found 'EOF' (typecheck)
14 changes: 14 additions & 0 deletions core/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,24 @@
// value-transfer transaction with n bytes of extra data in each
// block.
func genValueTx(nbytes int) func(int, *BlockGen) {
<<<<<<< HEAD
return func(i int, gen *BlockGen) {
toaddr := common.Address{}
data := make([]byte, nbytes)
gas, _ := IntrinsicGas(data, nil, false, false, false, false)
=======

Check failure on line 88 in core/bench_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '==' (typecheck)
// We can reuse the data for all transactions.
// During signing, the method tx.WithSignature(s, sig)
// performs:
// cpy := tx.inner.copy()
// cpy.setSignatureValues(signer.ChainID(), v, r, s)
// After this operation, the data can be reused by the caller.
data := make([]byte, nbytes)
rules := params.NonActivatedConfig.Rules(common.Big0, false, 0)
return func(i int, gen *BlockGen) {
toaddr := common.Address{}
gas, _ := IntrinsicGas(data, nil, nil, false, &rules)
>>>>>>> 6f1b514f2 (core: refactor IntrinsicGas function to accept rules parameter)
signer := gen.Signer()
gasPrice := big.NewInt(0)
if gen.header.BaseFee != nil {
Expand Down
14 changes: 11 additions & 3 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@
}

// IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
<<<<<<< HEAD

Check failure on line 70 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: non-declaration statement outside function body

Check failure on line 70 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: non-declaration statement outside function body

Check failure on line 70 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected declaration, found '<<' (typecheck)
func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP3860 bool) (uint64, error) {
=======

Check failure on line 72 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: unexpected ==, expected }

Check failure on line 72 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: unexpected ==, expected }
func IntrinsicGas(data []byte, accessList types.AccessList, authList []types.SetCodeAuthorization, isContractCreation bool, rules *params.Rules) (uint64, error) {
>>>>>>> 6f1b514f2 (core: refactor IntrinsicGas function to accept rules parameter)

Check failure on line 74 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: unexpected >>, expected }
// Set the starting gas for the raw transaction
var gas uint64
if isContractCreation && isHomestead {
if isContractCreation && rules.IsHomestead {

Check failure on line 77 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: non-declaration statement outside function body

Check failure on line 77 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected declaration, found 'if' (typecheck)
gas = params.TxGasContractCreation
} else {
gas = params.TxGas
Expand All @@ -80,14 +84,14 @@
if dataLen > 0 {
// Zero and non-zero bytes are priced differently
var nz uint64
for _, byt := range data {

Check failure on line 87 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: non-declaration statement outside function body

Check failure on line 87 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected declaration, found 'for' (typecheck)
if byt != 0 {
nz++
}
}
// Make sure we don't exceed uint64 for all data combinations
nonZeroGas := params.TxDataNonZeroGasFrontier
if isEIP2028 {
if rules.IsIstanbul {
nonZeroGas = params.TxDataNonZeroGasEIP2028
}
if (math.MaxUint64-gas)/nonZeroGas < nz {
Expand All @@ -101,7 +105,7 @@
}
gas += z * params.TxDataZeroGas

if isContractCreation && isEIP3860 {
if isContractCreation && rules.IsShanghai {
lenWords := toWordSize(dataLen)
if (math.MaxUint64-gas)/params.InitCodeWordGas < lenWords {
return 0, ErrGasUintOverflow
Expand Down Expand Up @@ -395,7 +399,11 @@
)

// Check clauses 4-5, subtract intrinsic gas if everything is correct
<<<<<<< HEAD

Check failure on line 402 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: unexpected <<, expected }

Check failure on line 402 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '<<' (typecheck)
gas, err := IntrinsicGas(msg.Data, msg.AccessList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
=======
gas, err := IntrinsicGas(msg.Data, msg.AccessList, msg.SetCodeAuthorizations, contractCreation, &rules)
>>>>>>> 6f1b514f2 (core: refactor IntrinsicGas function to accept rules parameter)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -427,7 +435,7 @@
ret []byte
vmerr error // vm errors do not effect consensus and are therefore not assigned to err
)
if contractCreation {

Check failure on line 438 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: non-declaration statement outside function body
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value)
} else {
// Increment the nonce for the next transaction
Expand All @@ -436,7 +444,7 @@
}

var gasRefund uint64
if !rules.IsLondon {

Check failure on line 447 in core/state_transition.go

View workflow job for this annotation

GitHub Actions / go_test_short

syntax error: non-declaration statement outside function body
// Before EIP-3529: refunds were capped to gasUsed / 2
gasRefund = st.refundGas(params.RefundQuotient)
} else {
Expand Down
4 changes: 4 additions & 0 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@
}
// Ensure the transaction has more gas than the bare minimum needed to cover
// the transaction metadata
<<<<<<< HEAD

Check failure on line 105 in core/txpool/validation.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '<<' (typecheck)
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time))
=======
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, &rules)
>>>>>>> 6f1b514f2 (core: refactor IntrinsicGas function to accept rules parameter)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions tests/transaction_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
return nil, nil, err
}
// Intrinsic gas
<<<<<<< HEAD
requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, false)
=======
requiredGas, err = core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules)
>>>>>>> 6f1b514f2 (core: refactor IntrinsicGas function to accept rules parameter)
if err != nil {
return nil, nil, err
}
Expand Down
Loading