Skip to content

Commit

Permalink
change hash to keccak256
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Dec 18, 2024
1 parent fbc3116 commit e1cff6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 0 additions & 3 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ func NewExecutionServiceServerV1(eth *eth.Ethereum) (*ExecutionServiceServerV1,
}
}

log.Info("astriaOracleContractAddress", "address", bc.Config().AstriaOracleContractAddress.String())
log.Info("astriaOracleCallerAddress", "address", bc.Config().AstriaOracleCallerAddress.String())

return &ExecutionServiceServerV1{
eth: eth,
bc: bc,
Expand Down
15 changes: 9 additions & 6 deletions grpc/execution/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/holiman/uint256"
)

func hashCurrencyPair(currencyPair *connecttypesv2.CurrencyPair) [32]byte {
cpStr := fmt.Sprintf("%s/%s", currencyPair.Base, currencyPair.Quote)
return sha256.Sum256([]byte(cpStr))
var bytes [32]byte
copy(bytes[:], crypto.Keccak256([]byte(cpStr)))
return bytes
}

func validateAndConvertOracleDataTx(
Expand All @@ -33,7 +36,7 @@ func validateAndConvertOracleDataTx(
) ([]*types.Transaction, error) {
txs := make([]*types.Transaction, 0)

log.Info("creating oracle data update tx", "price count", len(oracleData.Prices))
log.Debug("creating oracle data update tx", "price count", len(oracleData.Prices))
abi, err := contracts.AstriaOracleMetaData.GetAbi()
if err != nil {
// this should never happen, as the abi is hardcoded in the contract bindings
Expand Down Expand Up @@ -100,15 +103,15 @@ func validateAndConvertOracleDataTx(
txdata := types.InjectedTx{
From: cfg.oracleCallerAddress,
Value: new(big.Int),
Gas: 100000, // TODO
Gas: 10000,
To: &cfg.oracleContractAddress,
Data: calldata,
SourceTransactionId: primitivev1.TransactionId{},
SourceTransactionIndex: 0,
}
tx := types.NewTx(&txdata)
txs = append(txs, tx)
log.Info("created initializeCurrencyPair tx for currency pair", "pair", price.CurrencyPair)
log.Debug("created initializeCurrencyPair tx for currency pair", "pair", price.CurrencyPair)
}

args := []interface{}{currencyPairs, prices}
Expand All @@ -120,14 +123,14 @@ func validateAndConvertOracleDataTx(
txdata := types.InjectedTx{
From: cfg.oracleCallerAddress,
Value: new(big.Int),
// TODO: max gas costs?
// TODO: max gas costs; proportional to the amount of pairs being updated
Gas: 500000,
To: &cfg.oracleContractAddress,
Data: calldata,
SourceTransactionId: primitivev1.TransactionId{}, // not relevant
SourceTransactionIndex: 0, // not relevant
}
log.Info("created updatePriceData tx", "pairs", oracleData.Prices)
log.Debug("created updatePriceData tx", "pairs", oracleData.Prices)
tx := types.NewTx(&txdata)
txs = append(txs, tx)
return txs, nil
Expand Down

0 comments on commit e1cff6a

Please sign in to comment.