Commit 1b908768 authored by vicotor's avatar vicotor

update proto

parent 6b703c0d
...@@ -34,8 +34,11 @@ func (e *ExChainAPI) OutputV0AtBlock(ctx context.Context, blockHash common.Hash) ...@@ -34,8 +34,11 @@ func (e *ExChainAPI) OutputV0AtBlock(ctx context.Context, blockHash common.Hash)
} }
func (e *ExChainAPI) ChainID(ctx context.Context) (*big.Int, error) { func (e *ExChainAPI) ChainID(ctx context.Context) (*big.Int, error) {
//TODO implement me id, err := e.chain.ChainId()
panic("implement me") if err != nil {
return nil, err
}
return new(big.Int).SetUint64(id.Uint64()), nil
} }
func (e *ExChainAPI) NewPayload(params exchain.PayloadParams) (exchain.ExecutionResult, error) { func (e *ExChainAPI) NewPayload(params exchain.PayloadParams) (exchain.ExecutionResult, error) {
......
...@@ -32,6 +32,7 @@ message TransactionReceipt { ...@@ -32,6 +32,7 @@ message TransactionReceipt {
LimitOrderReceipt limit_r = 11; LimitOrderReceipt limit_r = 11;
MarketOrderReceipt market_r = 12; MarketOrderReceipt market_r = 12;
CancelOrderReceipt cancel_r = 13; CancelOrderReceipt cancel_r = 13;
ProtocolTransactionReceipt protocol_r = 14;
} }
} }
...@@ -60,3 +61,6 @@ message MarketOrderReceipt { ...@@ -60,3 +61,6 @@ message MarketOrderReceipt {
message CancelOrderReceipt { message CancelOrderReceipt {
string order_id = 1; string order_id = 1;
} }
message ProtocolTransactionReceipt {
}
...@@ -24,6 +24,7 @@ enum TxType { ...@@ -24,6 +24,7 @@ enum TxType {
LimitTx = 5; LimitTx = 5;
MarketTx = 6; MarketTx = 6;
CancelTx = 7; CancelTx = 7;
ProtocolTx = 8;
} }
message Signature { message Signature {
...@@ -50,8 +51,9 @@ message Transaction { ...@@ -50,8 +51,9 @@ message Transaction {
LimitOrderTransaction limit_tx = 10; LimitOrderTransaction limit_tx = 10;
MarketOrderTransaction market_tx = 11; MarketOrderTransaction market_tx = 11;
CancelOrderTransaction cancel_tx = 12; CancelOrderTransaction cancel_tx = 12;
ProtocolTransaction protocol_tx = 13;
} }
Signature signature = 13; Signature signature = 14;
} }
message SignProxyTransaction { message SignProxyTransaction {
...@@ -97,3 +99,11 @@ message MarketOrderTransaction { ...@@ -97,3 +99,11 @@ message MarketOrderTransaction {
message CancelOrderTransaction { message CancelOrderTransaction {
string order_id = 1; string order_id = 1;
} }
message ProtocolTransaction {
uint64 l1_number = 1;
uint64 l1_time = 2;
bytes l1_block_hash = 3;
uint64 sequence_number = 4;
bytes batcher_addr = 5;
}
...@@ -3,7 +3,6 @@ package derive ...@@ -3,7 +3,6 @@ package derive
import ( import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"github.com/exchain/go-exchain/op-node/rollup" "github.com/exchain/go-exchain/op-node/rollup"
"github.com/exchain/go-exchain/op-service/eth" "github.com/exchain/go-exchain/op-service/eth"
) )
...@@ -22,11 +21,21 @@ func PayloadToBlockRef(rollupCfg *rollup.Config, payload *eth.ExecutionPayload) ...@@ -22,11 +21,21 @@ func PayloadToBlockRef(rollupCfg *rollup.Config, payload *eth.ExecutionPayload)
sequenceNumber = 0 sequenceNumber = 0
} else { } else {
// todo: vicotor implement this. // todo: vicotor implement this.
data := make([]byte, 0) //if len(payload.Transactions) == 0 {
info, err := L1BlockInfoFromBytes(rollupCfg, uint64(payload.Timestamp), data) // return eth.L2BlockRef{}, fmt.Errorf("l2 block is missing L1 info deposit tx, block hash: %s", payload.BlockHash)
if err != nil { //}
return eth.L2BlockRef{}, fmt.Errorf("failed to parse L1 info deposit tx from L2 block: %w", err) //var tx types.Transaction
} //if err := tx.UnmarshalBinary(payload.Transactions[0]); err != nil {
// return eth.L2BlockRef{}, fmt.Errorf("failed to decode first tx to read l1 info from: %w", err)
//}
//if tx.Type() != types.DepositTxType {
// return eth.L2BlockRef{}, fmt.Errorf("first payload tx has unexpected tx type: %d", tx.Type())
//}
info, err := L1BlockInfoFromBytes(rollupCfg, uint64(payload.Timestamp), tx.Data())
//if err != nil {
// return eth.L2BlockRef{}, fmt.Errorf("failed to parse L1 info deposit tx from L2 block: %w", err)
//}
//l1Origin = eth.BlockID{Hash: info.BlockHash, Number: info.Number}
l1Origin = eth.BlockID{Hash: info.BlockHash, Number: info.Number} l1Origin = eth.BlockID{Hash: info.BlockHash, Number: info.Number}
sequenceNumber = info.SequenceNumber sequenceNumber = info.SequenceNumber
} }
......
...@@ -37,11 +37,11 @@ func (eq *EngDeriver) onBuildStart(ev BuildStartEvent) { ...@@ -37,11 +37,11 @@ func (eq *EngDeriver) onBuildStart(ev BuildStartEvent) {
eq.emitter.Emit(rollup.CriticalErrorEvent{Err: err}) // make the node exit, things are very wrong. eq.emitter.Emit(rollup.CriticalErrorEvent{Err: err}) // make the node exit, things are very wrong.
return return
} }
fc := eth.ForkchoiceState{ //fc := eth.ForkchoiceState{
HeadBlockHash: fcEvent.UnsafeL2Head.Hash, // HeadBlockHash: fcEvent.UnsafeL2Head.Hash,
SafeBlockHash: fcEvent.SafeL2Head.Hash, // SafeBlockHash: fcEvent.SafeL2Head.Hash,
FinalizedBlockHash: fcEvent.FinalizedL2Head.Hash, // FinalizedBlockHash: fcEvent.FinalizedL2Head.Hash,
} //}
buildStartTime := time.Now() buildStartTime := time.Now()
result, err := startPayload(context.TODO(), eq.ec.engine, fc, ev.Attributes.Attributes) result, err := startPayload(context.TODO(), eq.ec.engine, fc, ev.Attributes.Attributes)
if err != nil { if err != nil {
......
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