Skip to content

Commit

Permalink
chore: moved from uint64 to uint256 (#157)
Browse files Browse the repository at this point in the history
* chore: moved from uint64 to uint256

* chore: fixed tests for the oracle
  • Loading branch information
Mikelle authored and mrekucci committed Jun 21, 2024
1 parent 64bc907 commit f0332f8
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 185 deletions.
8 changes: 4 additions & 4 deletions contracts-abi/abi/BidderRegistry.abi
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
{
"name": "bidAmt",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "state",
Expand All @@ -52,8 +52,8 @@
},
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bidder",
Expand Down
40 changes: 20 additions & 20 deletions contracts-abi/abi/PreConfCommitmentStore.abi
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
},
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -288,8 +288,8 @@
},
{
"name": "_bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "_blockNumber",
Expand Down Expand Up @@ -349,8 +349,8 @@
},
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -433,8 +433,8 @@
},
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -601,8 +601,8 @@
},
{
"name": "_bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "_blockNumber",
Expand Down Expand Up @@ -766,8 +766,8 @@
},
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -960,8 +960,8 @@
"inputs": [
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -1014,8 +1014,8 @@
},
{
"name": "bid",
"type": "uint64",
"internalType": "uint64"
"type": "uint256",
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -1091,9 +1091,9 @@
},
{
"name": "bid",
"type": "uint64",
"type": "uint256",
"indexed": false,
"internalType": "uint64"
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down Expand Up @@ -1245,9 +1245,9 @@
},
{
"name": "bid",
"type": "uint64",
"type": "uint256",
"indexed": true,
"internalType": "uint64"
"internalType": "uint256"
},
{
"name": "blockNumber",
Expand Down
36 changes: 18 additions & 18 deletions contracts-abi/clients/BidderRegistry/BidderRegistry.go

Large diffs are not rendered by default.

160 changes: 80 additions & 80 deletions contracts-abi/clients/PreConfCommitmentStore/PreConfCommitmentStore.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/contracts/BidderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ contract BidderRegistry is
*/
function OpenBid(
bytes32 commitmentDigest,
uint64 bid,
uint256 bid,
address bidder,
uint64 blockNumber
) external onlyPreConfirmationEngine {
Expand Down
20 changes: 10 additions & 10 deletions contracts/contracts/PreConfCommitmentStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
/// @dev EIP-712 Type Hash for preconfirmation commitment
bytes32 public constant EIP712_COMMITMENT_TYPEHASH =
keccak256(
"PreConfCommitment(string txnHash,uint64 bid,uint64 blockNumber,uint64 decayStartTimeStamp,uint64 decayEndTimeStamp,bytes32 bidHash,string signature,string sharedSecretKey)"
"PreConfCommitment(string txnHash,uint256 bid,uint64 blockNumber,uint64 decayStartTimeStamp,uint64 decayEndTimeStamp,bytes32 bidHash,string signature,string sharedSecretKey)"
);

/// @dev EIP-712 Type Hash for preconfirmation bid
bytes32 public constant EIP712_BID_TYPEHASH =
keccak256(
"PreConfBid(string txnHash,uint64 bid,uint64 blockNumber,uint64 decayStartTimeStamp,uint64 decayEndTimeStamp)"
"PreConfBid(string txnHash,uint256 bid,uint64 blockNumber,uint64 decayStartTimeStamp,uint64 decayEndTimeStamp)"
);

// Represents the dispatch window in milliseconds
Expand Down Expand Up @@ -69,7 +69,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
bool isUsed;
address bidder;
address commiter;
uint64 bid;
uint256 bid;
uint64 blockNumber;
bytes32 bidHash;
uint64 decayStartTimeStamp;
Expand All @@ -87,7 +87,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
bytes32 indexed commitmentIndex,
address bidder,
address commiter,
uint64 bid,
uint256 bid,
uint64 blockNumber,
bytes32 bidHash,
uint64 decayStartTimeStamp,
Expand Down Expand Up @@ -122,7 +122,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
event SignatureVerified(
address indexed signer,
string txnHash,
uint64 indexed bid,
uint256 indexed bid,
uint64 blockNumber
);

Expand Down Expand Up @@ -216,7 +216,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
*/
function getBidHash(
string memory _txnHash,
uint64 _bid,
uint256 _bid,
uint64 _blockNumber,
uint64 _decayStartTimeStamp,
uint64 _decayEndTimeStamp
Expand Down Expand Up @@ -247,7 +247,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
*/
function getPreConfHash(
string memory _txnHash,
uint64 _bid,
uint256 _bid,
uint64 _blockNumber,
uint64 _decayStartTimeStamp,
uint64 _decayEndTimeStamp,
Expand Down Expand Up @@ -286,7 +286,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
* @return recoveredAddress the address from the bid hash.
*/
function verifyBid(
uint64 bid,
uint256 bid,
uint64 blockNumber,
uint64 decayStartTimeStamp,
uint64 decayEndTimeStamp,
Expand Down Expand Up @@ -316,7 +316,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
*/
function verifyPreConfCommitment(
string memory txnHash,
uint64 bid,
uint256 bid,
uint64 blockNumber,
uint64 decayStartTimeStamp,
uint64 decayEndTimeStamp,
Expand Down Expand Up @@ -388,7 +388,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
*/
function openCommitment(
bytes32 encryptedCommitmentIndex,
uint64 bid,
uint256 bid,
uint64 blockNumber,
string memory txnHash,
uint64 decayStartTimeStamp,
Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts/interfaces/IBidderRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
interface IBidderRegistry {
struct PreConfCommitment {
string txnHash;
uint64 bid;
uint256 bid;
uint64 blockNumber;
string bidHash;
string bidSignature;
Expand All @@ -14,7 +14,7 @@ interface IBidderRegistry {

struct BidState {
address bidder;
uint64 bidAmt;
uint256 bidAmt;
State state;
}

Expand All @@ -24,7 +24,7 @@ interface IBidderRegistry {
Withdrawn
}

function OpenBid(bytes32 commitmentDigest, uint64 bid, address bidder, uint64 blockNumber) external;
function OpenBid(bytes32 commitmentDigest, uint256 bid, address bidder, uint64 blockNumber) external;

function getDeposit(address bidder, uint256 window) external view returns (uint256);

Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts/interfaces/IPreConfCommitmentStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IPreConfCommitmentStore {
bool isUsed;
address bidder;
address commiter;
uint64 bid;
uint256 bid;
uint64 blockNumber;
bytes32 bidHash;
uint64 decayStartTimeStamp;
Expand All @@ -28,15 +28,15 @@ interface IPreConfCommitmentStore {
event SignatureVerified(
address indexed signer,
string txnHash,
uint64 indexed bid,
uint256 indexed bid,
uint64 blockNumber
);

// External functions that need to be implemented

function getBidHash(
string memory _txnHash,
uint64 _bid,
uint256 _bid,
uint64 _blockNumber
) external view returns (bytes32);

Expand Down
20 changes: 10 additions & 10 deletions contracts/test/PreConfirmationConfTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {WindowFromBlockNumber} from "../contracts/utils/WindowFromBlockNumber.so

contract TestPreConfCommitmentStore is Test {
struct TestCommitment {
uint64 bid;
uint256 bid;
uint64 blockNumber;
string txnHash;
uint64 decayStartTimestamp;
Expand Down Expand Up @@ -45,10 +45,10 @@ contract TestPreConfCommitmentStore is Test {
"0xkartik",
10,
20,
0xa0327970258c49b922969af74d60299a648c50f69a2d98d6ab43f32f64ac2100,
0x65618f8f9e46b8f0790c621ca2989cfe4c949594a4a3a81261baa682e8883840,
hex"876c1216c232828be9fabb14981c8788cebdf6ed66e563c4a2ccc82a577d052543207aeeb158a32d8977736797ae250c63ef69a82cd85b727da21e20d030fb311b",
hex"bfea9167927707ae7586ed3bba8565999f8b7ad874b2dd4f175caf81084c0d0a17f9599daf5b3f2773757408aa4b44875c95df0f4150cfb295f95273e1fefdd01b",
0x56c06a13be335eba981b780ea45dff258a7c429d0e9d993235ef2d3a7e435df8,
0x9d954942ad3f6cb41ccd029869be7b28036270b4754665a3783c2d6bf0ef7d08,
hex"2e7df27808c72d7d5b2543bb63b06c0ae2144e021593b8d2a7cca6a3fb2d9c4b1a82dd2a07266de9364d255bdb709476ad96b826ec855efb528eaff66682997e1c",
hex"682a1bc8659a0d2616f579ca0e0944d4e21911e65561b7d9ae7dba36c5a5b699248f1c93e8e6f52492ee6c3cb0f34f20f5a97fb2653c5a67200e1de9254389e11c",
15,
bytes("0xsecret")
);
Expand Down Expand Up @@ -264,8 +264,8 @@ contract TestPreConfCommitmentStore is Test {

(uint8 v, bytes32 r, bytes32 s) = vm.sign(bidderPk, bidHash);
bytes memory signature = abi.encodePacked(r, s, v);
console.logBytes(signature);
bytes memory sharedSecretKey = bytes("0xsecret");

bytes32 preConfHash = preConfCommitmentStore.getPreConfHash(
_testCommitmentAliceBob.txnHash,
_testCommitmentAliceBob.bid,
Expand Down Expand Up @@ -367,7 +367,7 @@ contract TestPreConfCommitmentStore is Test {

function verifyCommitmentNotUsed(
string memory txnHash,
uint64 bid,
uint256 bid,
uint64 blockNumber,
uint64 decayStartTimestamp,
uint64 decayEndTimestamp,
Expand Down Expand Up @@ -401,7 +401,7 @@ contract TestPreConfCommitmentStore is Test {

function storeCommitment(
address commiter,
uint64 bid,
uint256 bid,
uint64 blockNumber,
string memory txnHash,
uint64 decayStartTimestamp,
Expand Down Expand Up @@ -443,7 +443,7 @@ contract TestPreConfCommitmentStore is Test {
function openCommitment(
address msgSender,
bytes32 encryptedCommitmentIndex,
uint64 bid,
uint256 bid,
uint64 blockNumber,
string memory txnHash,
uint64 decayStartTimestamp,
Expand All @@ -470,7 +470,7 @@ contract TestPreConfCommitmentStore is Test {

function verifyStoredCommitment(
bytes32 index,
uint64 bid,
uint256 bid,
uint64 blockNumber,
uint64 decayStartTimestamp,
uint64 decayEndTimestamp,
Expand Down
2 changes: 1 addition & 1 deletion oracle/pkg/apiserver/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *Service) configureDashboard() error {
if !ok {
currentAmount = big.NewInt(0)
}
currentAmount = big.NewInt(0).Add(currentAmount, big.NewInt(0).SetUint64(cmt.Amount))
currentAmount = big.NewInt(0).Add(currentAmount, cmt.Amount)
existing.TotalAmount = currentAmount.String()
_ = s.blockStats.Add(uint64(cmt.BlockNum), existing)
},
Expand Down
Loading

0 comments on commit f0332f8

Please sign in to comment.