Skip to content

Commit

Permalink
chore: rename isthmus to interop on golang files (ethereum-optimism#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDiscotech authored Sep 26, 2024
1 parent c65c1f8 commit 3210a8c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions op-node/rollup/derive/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestPreparePayloadAttributes(t *testing.T) {
require.Equal(t, l1InfoTx, []byte(attrs.Transactions[0]))
require.True(t, attrs.NoTxPool)
})
t.Run("new origin with deposits on post-Isthmus", func(t *testing.T) {
t.Run("new origin with deposits on post-Interop", func(t *testing.T) {
rng := rand.New(rand.NewSource(1234))
l1Fetcher := &testutils.MockL1Source{}
defer l1Fetcher.AssertExpectations(t)
Expand Down Expand Up @@ -247,7 +247,7 @@ func TestPreparePayloadAttributes(t *testing.T) {
require.True(t, attrs.NoTxPool)
})

t.Run("same origin without deposits on post-Isthmus", func(t *testing.T) {
t.Run("same origin without deposits on post-Interop", func(t *testing.T) {
rng := rand.New(rand.NewSource(1234))
l1Fetcher := &testutils.MockL1Source{}
defer l1Fetcher.AssertExpectations(t)
Expand Down
10 changes: 5 additions & 5 deletions op-node/rollup/derive/fuzz_parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ func FuzzL1InfoEcotoneRoundTrip(f *testing.F) {
if !cmp.Equal(in, out, cmp.Comparer(testutils.BigEqual)) {
t.Fatalf("The Ecotone data did not round trip correctly. in: %v. out: %v", in, out)
}
enc, err = in.marshalBinaryIsthmus()
enc, err = in.marshalBinaryInterop()
if err != nil {
t.Fatalf("Failed to marshal Isthmus binary: %v", err)
t.Fatalf("Failed to marshal Interop binary: %v", err)
}
err = out.unmarshalBinaryIsthmus(enc)
err = out.unmarshalBinaryInterop(enc)
if err != nil {
t.Fatalf("Failed to unmarshal Isthmus binary: %v", err)
t.Fatalf("Failed to unmarshal Interop binary: %v", err)
}
if !cmp.Equal(in, out, cmp.Comparer(testutils.BigEqual)) {
t.Fatalf("The Isthmus data did not round trip correctly. in: %v. out: %v", in, out)
t.Fatalf("The Interop data did not round trip correctly. in: %v. out: %v", in, out)
}

})
Expand Down
30 changes: 15 additions & 15 deletions op-node/rollup/derive/l1_block_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ import (
const (
L1InfoFuncBedrockSignature = "setL1BlockValues(uint64,uint64,uint256,bytes32,uint64,bytes32,uint256,uint256)"
L1InfoFuncEcotoneSignature = "setL1BlockValuesEcotone()"
L1InfoFuncIsthmusSignature = "setL1BlockValuesIsthmus()"
L1InfoFuncInteropSignature = "setL1BlockValuesInterop()"
DepositsCompleteSignature = "depositsComplete()"
L1InfoArguments = 8
L1InfoBedrockLen = 4 + 32*L1InfoArguments
L1InfoEcotoneLen = 4 + 32*5 // after Ecotone upgrade, args are packed into 5 32-byte slots
DepositsCompleteLen = 4 // only the selector
// DepositsCompleteGas allocates 21k gas for intrinsic tx costs, and
// an additional 15k to ensure that the DepositsComplete call does not run out of gas.
// GasBenchMark_L1BlockIsthmus_DepositsComplete:test_depositsComplete_benchmark() (gas: 7768)
// GasBenchMark_L1BlockIsthmus_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5768)
// GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7768)
// GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5768)
// see `test_depositsComplete_benchmark` at: `/packages/contracts-bedrock/test/BenchmarkTest.t.sol`
DepositsCompleteGas = uint64(21_000 + 15_000)
)

var (
L1InfoFuncBedrockBytes4 = crypto.Keccak256([]byte(L1InfoFuncBedrockSignature))[:4]
L1InfoFuncEcotoneBytes4 = crypto.Keccak256([]byte(L1InfoFuncEcotoneSignature))[:4]
L1InfoFuncIsthmusBytes4 = crypto.Keccak256([]byte(L1InfoFuncIsthmusSignature))[:4]
L1InfoFuncInteropBytes4 = crypto.Keccak256([]byte(L1InfoFuncInteropSignature))[:4]
DepositsCompleteBytes4 = crypto.Keccak256([]byte(DepositsCompleteSignature))[:4]
L1InfoDepositerAddress = common.HexToAddress("0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001")
L1BlockAddress = predeploys.L1BlockAddr
Expand Down Expand Up @@ -155,7 +155,7 @@ func (info *L1BlockInfo) unmarshalBinaryBedrock(data []byte) error {
return nil
}

// Isthmus & Ecotone Binary Format
// Interop & Ecotone Binary Format
// +---------+--------------------------+
// | Bytes | Field |
// +---------+--------------------------+
Expand All @@ -179,16 +179,16 @@ func (info *L1BlockInfo) marshalBinaryEcotone() ([]byte, error) {
return out, nil
}

func (info *L1BlockInfo) marshalBinaryIsthmus() ([]byte, error) {
out, err := marshalBinaryWithSignature(info, L1InfoFuncIsthmusBytes4)
func (info *L1BlockInfo) marshalBinaryInterop() ([]byte, error) {
out, err := marshalBinaryWithSignature(info, L1InfoFuncInteropBytes4)
if err != nil {
return nil, fmt.Errorf("failed to marshal Isthmus l1 block info: %w", err)
return nil, fmt.Errorf("failed to marshal Interop l1 block info: %w", err)
}
return out, nil
}

func marshalBinaryWithSignature(info *L1BlockInfo, signature []byte) ([]byte, error) {
w := bytes.NewBuffer(make([]byte, 0, L1InfoEcotoneLen)) // Ecotone and Isthmus have the same length
w := bytes.NewBuffer(make([]byte, 0, L1InfoEcotoneLen)) // Ecotone and Interop have the same length
if err := solabi.WriteSignature(w, signature); err != nil {
return nil, err
}
Expand Down Expand Up @@ -231,8 +231,8 @@ func (info *L1BlockInfo) unmarshalBinaryEcotone(data []byte) error {
return unmarshalBinaryWithSignatureAndData(info, L1InfoFuncEcotoneBytes4, data)
}

func (info *L1BlockInfo) unmarshalBinaryIsthmus(data []byte) error {
return unmarshalBinaryWithSignatureAndData(info, L1InfoFuncIsthmusBytes4, data)
func (info *L1BlockInfo) unmarshalBinaryInterop(data []byte) error {
return unmarshalBinaryWithSignatureAndData(info, L1InfoFuncInteropBytes4, data)
}

func unmarshalBinaryWithSignatureAndData(info *L1BlockInfo, signature []byte, data []byte) error {
Expand Down Expand Up @@ -285,7 +285,7 @@ func isEcotoneButNotFirstBlock(rollupCfg *rollup.Config, l2Timestamp uint64) boo
return rollupCfg.IsEcotone(l2Timestamp) && !rollupCfg.IsEcotoneActivationBlock(l2Timestamp)
}

// isInteropButNotFirstBlock returns whether the specified block is subject to the Isthmus upgrade,
// isInteropButNotFirstBlock returns whether the specified block is subject to the Interop upgrade,
// but is not the activation block itself.
func isInteropButNotFirstBlock(rollupCfg *rollup.Config, l2Timestamp uint64) bool {
// Since we use the pre-interop L1 tx one last time during the upgrade block,
Expand All @@ -300,7 +300,7 @@ func L1BlockInfoFromBytes(rollupCfg *rollup.Config, l2BlockTime uint64, data []b
var info L1BlockInfo
// Important, this should be ordered from most recent to oldest
if isInteropButNotFirstBlock(rollupCfg, l2BlockTime) {
return &info, info.unmarshalBinaryIsthmus(data)
return &info, info.unmarshalBinaryInterop(data)
}
if isEcotoneButNotFirstBlock(rollupCfg, l2BlockTime) {
return &info, info.unmarshalBinaryEcotone(data)
Expand Down Expand Up @@ -333,9 +333,9 @@ func L1InfoDeposit(rollupCfg *rollup.Config, sysCfg eth.SystemConfig, seqNumber
l1BlockInfo.BlobBaseFeeScalar = scalars.BlobBaseFeeScalar
l1BlockInfo.BaseFeeScalar = scalars.BaseFeeScalar
if isInteropButNotFirstBlock(rollupCfg, l2Timestamp) {
out, err := l1BlockInfo.marshalBinaryIsthmus()
out, err := l1BlockInfo.marshalBinaryInterop()
if err != nil {
return nil, fmt.Errorf("failed to marshal Isthmus l1 block info: %w", err)
return nil, fmt.Errorf("failed to marshal Interop l1 block info: %w", err)
}
data = out
} else {
Expand Down
18 changes: 9 additions & 9 deletions op-node/rollup/derive/l1_block_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestParseL1InfoDepositTxData(t *testing.T) {
require.Equal(t, depTx.Gas, uint64(RegolithSystemTxGas))
require.Equal(t, L1InfoEcotoneLen, len(depTx.Data))
})
t.Run("isthmus", func(t *testing.T) {
t.Run("interop", func(t *testing.T) {
rng := rand.New(rand.NewSource(1234))
info := testutils.MakeBlockInfo(nil)(rng)
rollupCfg := rollup.Config{BlockTime: 2, Genesis: rollup.Genesis{L2Time: 1000}}
Expand All @@ -165,25 +165,25 @@ func TestParseL1InfoDepositTxData(t *testing.T) {
require.NoError(t, err)
require.False(t, depTx.IsSystemTransaction)
require.Equal(t, depTx.Gas, uint64(RegolithSystemTxGas))
require.Equal(t, L1InfoEcotoneLen, len(depTx.Data), "the length is same in isthmus")
require.Equal(t, L1InfoFuncIsthmusBytes4, depTx.Data[:4], "upgrade is active, need isthmus signature")
require.Equal(t, L1InfoEcotoneLen, len(depTx.Data), "the length is same in interop")
require.Equal(t, L1InfoFuncInteropBytes4, depTx.Data[:4], "upgrade is active, need interop signature")
})
t.Run("activation-block isthmus", func(t *testing.T) {
t.Run("activation-block interop", func(t *testing.T) {
rng := rand.New(rand.NewSource(1234))
info := testutils.MakeBlockInfo(nil)(rng)
rollupCfg := rollup.Config{BlockTime: 2, Genesis: rollup.Genesis{L2Time: 1000}}
rollupCfg.ActivateAtGenesis(rollup.Fjord)
isthmusTime := rollupCfg.Genesis.L2Time + rollupCfg.BlockTime // activate isthmus just after genesis
rollupCfg.InteropTime = &isthmusTime
depTx, err := L1InfoDeposit(&rollupCfg, randomL1Cfg(rng, info), randomSeqNr(rng), info, isthmusTime)
interopTime := rollupCfg.Genesis.L2Time + rollupCfg.BlockTime // activate interop just after genesis
rollupCfg.InteropTime = &interopTime
depTx, err := L1InfoDeposit(&rollupCfg, randomL1Cfg(rng, info), randomSeqNr(rng), info, interopTime)
require.NoError(t, err)
require.False(t, depTx.IsSystemTransaction)
require.Equal(t, depTx.Gas, uint64(RegolithSystemTxGas))
// Isthmus activates, but ecotone L1 info is still used at this upgrade block
// Interop activates, but ecotone L1 info is still used at this upgrade block
require.Equal(t, L1InfoEcotoneLen, len(depTx.Data))
require.Equal(t, L1InfoFuncEcotoneBytes4, depTx.Data[:4])
})
t.Run("genesis-block isthmus", func(t *testing.T) {
t.Run("genesis-block interop", func(t *testing.T) {
rng := rand.New(rand.NewSource(1234))
info := testutils.MakeBlockInfo(nil)(rng)
rollupCfg := rollup.Config{BlockTime: 2, Genesis: rollup.Genesis{L2Time: 1000}}
Expand Down

0 comments on commit 3210a8c

Please sign in to comment.