-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expand config fix: nothing to send feat: use finality as the syncer fix: rebase feat: add sequencer private key to config fix: add new fields fix: config fix: merge fix fix: remove ImportedExitRoots field feat: build certificates for L1 as well feat: set previous and new exit root in certificate fix: reorg detector for both l1 and l2 fix: rebase feat: add aggsender to run cmd feat: sign certificate POC feat: latest spec types fix: update comments fix: resolve TODOs on claim fix: height
- Loading branch information
1 parent
10fee93
commit 746f647
Showing
18 changed files
with
509 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package aggregator | ||
package agglayer | ||
|
||
import ( | ||
"crypto/ecdsa" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package agglayer | ||
|
||
import ( | ||
"math/big" | ||
|
||
cdkcommon "github.com/0xPolygon/cdk/common" | ||
"github.com/0xPolygon/cdk/tree" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
) | ||
|
||
// Certificate is the data structure that will be sent to the aggLayer | ||
type Certificate struct { | ||
NetworkID uint32 `json:"network_id"` | ||
Height uint64 `json:"height"` | ||
PrevLocalExitRoot common.Hash `json:"prev_local_exit_root"` | ||
NewLocalExitRoot common.Hash `json:"new_local_exit_root"` | ||
BridgeExits []*BridgeExit `json:"bridge_exits"` | ||
ImportedBridgeExits []*ImportedBridgeExit `json:"imported_bridge_exits"` | ||
} | ||
|
||
// Hash returns a hash that uniquely identifies the certificate | ||
func (c *Certificate) Hash() common.Hash { | ||
importedBridgeHashes := make([][]byte, 0, len(c.ImportedBridgeExits)) | ||
for _, claim := range c.ImportedBridgeExits { | ||
importedBridgeHashes = append(importedBridgeHashes, claim.Hash().Bytes()) | ||
} | ||
|
||
incomeCommitment := crypto.Keccak256Hash(importedBridgeHashes...) | ||
outcomeCommitment := c.NewLocalExitRoot | ||
|
||
return crypto.Keccak256Hash(outcomeCommitment.Bytes(), incomeCommitment.Bytes()) | ||
} | ||
|
||
// SignedCertificate is the struct that contains the certificate and the signature of the signer | ||
type SignedCertificate struct { | ||
*Certificate | ||
Signature []byte `json:"signature"` | ||
Signer common.Address `json:"signer"` | ||
} | ||
|
||
// TokenInfo encapsulates the information to uniquely identify a token on the origin network. | ||
type TokenInfo struct { | ||
OriginNetwork uint32 `json:"origin_network"` | ||
OriginTokenAddress common.Address `json:"origin_token_address"` | ||
} | ||
|
||
// BridgeExit represents a token bridge exit | ||
type BridgeExit struct { | ||
LeafType uint8 `json:"leaf_type"` | ||
TokenInfo *TokenInfo `json:"token_info"` | ||
DestinationNetwork uint32 `json:"destination_network"` | ||
DestinationAddress common.Address `json:"destination_address"` | ||
Amount *big.Int `json:"amount"` | ||
Metadata []byte `json:"metadata"` | ||
} | ||
|
||
// Hash returns a hash that uniquely identifies the bridge exit | ||
func (c *BridgeExit) Hash() common.Hash { | ||
return crypto.Keccak256Hash( | ||
cdkcommon.Uint8ToBytes(c.LeafType), | ||
cdkcommon.Uint32ToBytes(c.TokenInfo.OriginNetwork), | ||
c.TokenInfo.OriginTokenAddress.Bytes(), | ||
cdkcommon.Uint32ToBytes(c.DestinationNetwork), | ||
c.DestinationAddress.Bytes(), | ||
c.Amount.Bytes(), | ||
crypto.Keccak256(c.Metadata), | ||
) | ||
} | ||
|
||
// ImportedBridgeExit represents a token bridge exit originating on another network but claimed on the current network. | ||
type ImportedBridgeExit struct { | ||
BridgeExit *BridgeExit `json:"bridge_exit"` | ||
ImportedLocalExitRoot common.Hash `json:"imported_local_exit_root"` | ||
InclusionProof [tree.DefaultHeight]common.Hash `json:"inclusion_proof"` | ||
InclusionProofRER [tree.DefaultHeight]common.Hash `json:"inclusion_proof_rer"` | ||
GlobalIndex *big.Int `json:"global_index"` | ||
} | ||
|
||
// Hash returns a hash that uniquely identifies the imported bridge exit | ||
func (c *ImportedBridgeExit) Hash() common.Hash { | ||
return c.BridgeExit.Hash() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.