Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat: update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 31, 2024
1 parent 5716c6d commit cfd26eb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 120 deletions.
72 changes: 0 additions & 72 deletions bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,6 @@ var (
GoldenTouchPrivKey = "92954368afd3caa1f3ce3ead0069c1af414054aefe1ef9aeacc1bf426222ce38"
)

// BlockHeader represents an Ethereum block header.
type BlockHeader struct {
ParentHash [32]byte
OmmersHash [32]byte
Beneficiary common.Address
StateRoot [32]byte
TransactionsRoot [32]byte
ReceiptsRoot [32]byte
LogsBloom [8][32]byte
Difficulty *big.Int
Height *big.Int
GasLimit uint64
GasUsed uint64
Timestamp uint64
ExtraData []byte
MixHash [32]byte
Nonce uint64
BaseFeePerGas *big.Int
}

// HookCall should be same with TaikoData.HookCall
type HookCall struct {
Hook common.Address
Expand Down Expand Up @@ -89,58 +69,6 @@ type ZKEvmProof struct {
PointProof []byte
}

// FromGethHeader converts a GETH *types.Header to *BlockHeader.
func FromGethHeader(header *types.Header) *BlockHeader {
baseFeePerGas := header.BaseFee
if baseFeePerGas == nil {
baseFeePerGas = common.Big0
}
return &BlockHeader{
ParentHash: header.ParentHash,
OmmersHash: header.UncleHash,
Beneficiary: header.Coinbase,
StateRoot: header.Root,
TransactionsRoot: header.TxHash,
ReceiptsRoot: header.ReceiptHash,
LogsBloom: BloomToBytes(header.Bloom),
Difficulty: header.Difficulty,
Height: header.Number,
GasLimit: header.GasLimit,
GasUsed: header.GasUsed,
Timestamp: header.Time,
ExtraData: header.Extra,
MixHash: header.MixDigest,
Nonce: header.Nonce.Uint64(),
BaseFeePerGas: baseFeePerGas,
}
}

// ToGethHeader converts a *BlockHeader to GETH *types.Header.
func ToGethHeader(header *BlockHeader) *types.Header {
baseFeePerGas := header.BaseFeePerGas
if baseFeePerGas.Cmp(common.Big0) == 0 {
baseFeePerGas = nil
}
return &types.Header{
ParentHash: header.ParentHash,
UncleHash: header.OmmersHash,
Coinbase: header.Beneficiary,
Root: header.StateRoot,
TxHash: header.TransactionsRoot,
ReceiptHash: header.ReceiptsRoot,
Bloom: BytesToBloom(header.LogsBloom),
Difficulty: header.Difficulty,
Number: header.Height,
GasLimit: header.GasLimit,
GasUsed: header.GasUsed,
Time: header.Timestamp,
Extra: header.ExtraData,
MixDigest: header.MixHash,
Nonce: types.EncodeNonce(header.Nonce),
BaseFee: baseFeePerGas,
}
}

// ToExecutableData converts a GETH *types.Header to *engine.ExecutableData.
func ToExecutableData(header *types.Header) *engine.ExecutableData {
executableData := &engine.ExecutableData{
Expand Down
47 changes: 0 additions & 47 deletions bindings/encoding/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,53 +35,6 @@ var (
}
)

func TestFromGethHeader(t *testing.T) {
header := FromGethHeader(testHeader)

require.Equal(t, testHeader.ParentHash, common.BytesToHash(header.ParentHash[:]))
require.Equal(t, testHeader.UncleHash, common.BytesToHash(header.OmmersHash[:]))
require.Equal(t, testHeader.Coinbase, header.Beneficiary)
require.Equal(t, testHeader.Root, common.BytesToHash(header.StateRoot[:]))
require.Equal(t, testHeader.TxHash, common.BytesToHash(header.TransactionsRoot[:]))
require.Equal(t, testHeader.ReceiptHash, common.BytesToHash(header.ReceiptsRoot[:]))
require.Equal(t, BloomToBytes(testHeader.Bloom), header.LogsBloom)
require.Equal(t, testHeader.Difficulty, header.Difficulty)
require.Equal(t, testHeader.Number, header.Height)
require.Equal(t, testHeader.GasLimit, header.GasLimit)
require.Equal(t, testHeader.GasUsed, header.GasUsed)
require.Equal(t, testHeader.Time, header.Timestamp)
require.Equal(t, testHeader.Extra, header.ExtraData)
require.Equal(t, testHeader.MixDigest, common.BytesToHash(header.MixHash[:]))
require.Equal(t, testHeader.Nonce.Uint64(), header.Nonce)
require.Equal(t, testHeader.BaseFee.Uint64(), header.BaseFeePerGas.Uint64())
}

func TestFromToGethHeaderLegacyTx(t *testing.T) {
testHeader := testHeader // Copy the original struct
testHeader.BaseFee = nil
header := FromGethHeader(testHeader)

require.Equal(t, testHeader.ParentHash, common.BytesToHash(header.ParentHash[:]))
require.Equal(t, testHeader.UncleHash, common.BytesToHash(header.OmmersHash[:]))
require.Equal(t, testHeader.Coinbase, header.Beneficiary)
require.Equal(t, testHeader.Root, common.BytesToHash(header.StateRoot[:]))
require.Equal(t, testHeader.TxHash, common.BytesToHash(header.TransactionsRoot[:]))
require.Equal(t, testHeader.ReceiptHash, common.BytesToHash(header.ReceiptsRoot[:]))
require.Equal(t, BloomToBytes(testHeader.Bloom), header.LogsBloom)
require.Equal(t, testHeader.Difficulty, header.Difficulty)
require.Equal(t, testHeader.Number, header.Height)
require.Equal(t, testHeader.GasLimit, header.GasLimit)
require.Equal(t, testHeader.GasUsed, header.GasUsed)
require.Equal(t, testHeader.Time, header.Timestamp)
require.Equal(t, testHeader.Extra, header.ExtraData)
require.Equal(t, testHeader.MixDigest, common.BytesToHash(header.MixHash[:]))
require.Equal(t, testHeader.Nonce.Uint64(), header.Nonce)
require.Equal(t, new(big.Int).SetInt64(0).Uint64(), header.BaseFeePerGas.Uint64())

gethHeader := ToGethHeader(header)
require.Equal(t, testHeader, gethHeader)
}

func TestToExecutableData(t *testing.T) {
data := ToExecutableData(testHeader)
require.Equal(t, testHeader.ParentHash, data.ParentHash)
Expand Down
2 changes: 1 addition & 1 deletion driver/anchor_tx_constructor/anchor_tx_constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func New(rpc *rpc.Client, signalServiceAddress common.Address) (*AnchorTxConstru
return nil, err
}

signer, err := signer.NewFixedKSigner(encoding.GoldenTouchPrivKey)
signer, err := signer.NewFixedKSigner("0x" + encoding.GoldenTouchPrivKey)
if err != nil {
return nil, fmt.Errorf("invalid golden touch private key %s", encoding.GoldenTouchPrivKey)
}
Expand Down

0 comments on commit cfd26eb

Please sign in to comment.