-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from 0glabs/staking-precompile
feat: staking precompile
- Loading branch information
Showing
26 changed files
with
8,956 additions
and
28 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package common | ||
|
||
import ( | ||
"math/big" | ||
"strings" | ||
|
||
"cosmossdk.io/math" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
func ToLowerHexWithoutPrefix(addr common.Address) string { | ||
return strings.ToLower(addr.Hex()[2:]) | ||
} | ||
|
||
// BigIntToLegacyDec converts a uint number (18 decimals) to math.LegacyDec (18 decimals) | ||
func BigIntToLegacyDec(x *big.Int) math.LegacyDec { | ||
return math.LegacyNewDecFromBigIntWithPrec(x, math.LegacyPrecision) | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"avoid-low-level-calls": "off", | ||
"compiler-version": "off", | ||
"gas-custom-errors": "off", | ||
"explicit-types": ["warn", "implicit"], | ||
"func-visibility": ["warn", { "ignoreConstructors": true }], | ||
"max-states-count": "off", | ||
"no-empty-blocks": "off", | ||
"no-global-import": "off", | ||
"no-inline-assembly": "off", | ||
"not-rely-on-time": "off", | ||
"prettier/prettier": "error", | ||
"reason-string": "off" | ||
} | ||
} |
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,88 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.8.0; | ||
|
||
library BN254 { | ||
struct G1Point { | ||
uint X; | ||
uint Y; | ||
} | ||
|
||
// Encoding of field elements is: X[1] * i + X[0] | ||
struct G2Point { | ||
uint[2] X; | ||
uint[2] Y; | ||
} | ||
} | ||
|
||
interface IDASigners { | ||
/*=== struct ===*/ | ||
struct SignerDetail { | ||
address signer; | ||
string socket; | ||
BN254.G1Point pkG1; | ||
BN254.G2Point pkG2; | ||
} | ||
|
||
struct Params { | ||
uint tokensPerVote; | ||
uint maxVotesPerSigner; | ||
uint maxQuorums; | ||
uint epochBlocks; | ||
uint encodedSlices; | ||
} | ||
|
||
/*=== event ===*/ | ||
event NewSigner( | ||
address indexed signer, | ||
BN254.G1Point pkG1, | ||
BN254.G2Point pkG2 | ||
); | ||
event SocketUpdated(address indexed signer, string socket); | ||
|
||
/*=== function ===*/ | ||
function params() external view returns (Params memory); | ||
|
||
function epochNumber() external view returns (uint); | ||
|
||
function quorumCount(uint _epoch) external view returns (uint); | ||
|
||
function isSigner(address _account) external view returns (bool); | ||
|
||
function getSigner( | ||
address[] memory _account | ||
) external view returns (SignerDetail[] memory); | ||
|
||
function getQuorum( | ||
uint _epoch, | ||
uint _quorumId | ||
) external view returns (address[] memory); | ||
|
||
function getQuorumRow( | ||
uint _epoch, | ||
uint _quorumId, | ||
uint32 _rowIndex | ||
) external view returns (address); | ||
|
||
function registerSigner( | ||
SignerDetail memory _signer, | ||
BN254.G1Point memory _signature | ||
) external; | ||
|
||
function updateSocket(string memory _socket) external; | ||
|
||
function registeredEpoch( | ||
address _account, | ||
uint _epoch | ||
) external view returns (bool); | ||
|
||
function registerNextEpoch(BN254.G1Point memory _signature) external; | ||
|
||
function getAggPkG1( | ||
uint _epoch, | ||
uint _quorumId, | ||
bytes memory _quorumBitmap | ||
) | ||
external | ||
view | ||
returns (BN254.G1Point memory aggPkG1, uint total, uint hit); | ||
} |
Oops, something went wrong.