Commit d6734f62 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

l2geth: change `ROLLUP_BASE_TX_SIZE` to camelcase (#518)

* l2geth: rename ROLLUP_BASE_TX_SIZE to standard golang style

* l2geth: add changeset
parent 6bcf22ba
---
"@eth-optimism/l2geth": patch
---
Change ROLLUP_BASE_TX_SIZE to camelcase for standard style
......@@ -4,16 +4,16 @@ import (
"math/big"
)
/// ROLLUP_BASE_TX_SIZE is the encoded rollup transaction's compressed size excluding
/// the variable length data.
/// Ref: https://github.com/ethereum-optimism/contracts/blob/409f190518b90301db20d0d4f53760021bc203a8/contracts/optimistic-ethereum/OVM/precompiles/OVM_SequencerEntrypoint.sol#L47
const ROLLUP_BASE_TX_SIZE int = 96
// RollupBaseTxSize is the encoded rollup transaction's compressed size excluding
// the variable length data.
// Ref: https://github.com/ethereum-optimism/optimism/blob/91a9a3dcddf534ae1c906133b6d8e015a23c463b/packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol#L47
const RollupBaseTxSize int = 96
/// CalculateFee calculates the fee that must be paid to the Rollup sequencer, taking into
/// account the cost of publishing data to L1.
/// Returns: (ROLLUP_BASE_TX_SIZE + len(data)) * dataPrice + executionPrice * gasUsed
// CalculateFee calculates the fee that must be paid to the Rollup sequencer, taking into
// account the cost of publishing data to L1.
// Returns: (RollupBaseTxSize + len(data)) * dataPrice + executionPrice * gasUsed
func CalculateRollupFee(data []byte, gasUsed uint64, dataPrice, executionPrice *big.Int) *big.Int {
dataLen := int64(ROLLUP_BASE_TX_SIZE + len(data))
dataLen := int64(RollupBaseTxSize + len(data))
// get the data fee
dataFee := new(big.Int).Mul(dataPrice, big.NewInt(dataLen))
executionFee := new(big.Int).Mul(executionPrice, new(big.Int).SetUint64(gasUsed))
......
......@@ -23,7 +23,7 @@ func TestCalculateRollupFee(t *testing.T) {
data := make([]byte, 0, tt.dataLen)
fee := CalculateRollupFee(data, tt.gasUsed, big.NewInt(tt.dataPrice), big.NewInt(tt.executionPrice))
dataFee := uint64((ROLLUP_BASE_TX_SIZE + len(data)) * int(tt.dataPrice))
dataFee := uint64((RollupBaseTxSize + len(data)) * int(tt.dataPrice))
executionFee := uint64(tt.executionPrice) * tt.gasUsed
expectedFee := dataFee + executionFee
if fee.Cmp(big.NewInt(int64(expectedFee))) != 0 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment