Skip to content

Commit

Permalink
Release v0.1.5 (contracts version) (#194)
Browse files Browse the repository at this point in the history
* bugfix: fix abstract command abi validation to work with cw-plus contracts

These use anyOf instead of oneOf to list the available functions

* add report output (#131)

Also adds the option of setting what the report name will be via the environment variable "REPORT_NAME" which aids in automated tests.

* Remove crates/query-proxy

We no longer have the flags proxy so there's no sense to share
definitions.

* Multisig wrapper command (#111)

* commands export data

raw tx on inspection command

* basic package and schema

* multisig command

* multisig command improvements

list some todos

* more detailed state

* execute option on multisig

* refactor

* Feature/29149 multisig group commands (#132)

* 29141: update_admin command

* 29149: update_members command

* 29149: export update_admin and update_memners commands

* 29149: MR feedback - file reorganisation

* 29149: applying formatting

* pkg/terra: add Test_parseAttributes (#128)

* fix tests (#139)

* correctly set cosmos queries

* rename juelsperluna to juelsperfeecoin in the set_config event

* add check to make sure all fields are extracted from logs

* switch to cropping the config digest before publishing to kafka.

* add test for decoding configuration, transmission and balance from the
chain read

* revert to using the decoded config digest

* use the relay monitoring Logger interface instead of the core logger

* fix terra monitoring main

* migration up test boiler (#138)

* fix chaos CI (#140)

* refactor ocr2:deploy --id to args[0] (#137)

* changed flag on proxy command (#144)

* fix proxy query for decimals, version, description

* Improvements after Multisig testing (#145)

* inspection improvements

improvements on inspection

* inspect msig comand

* max voting period 7 days

* Document lack of transmitters prefix (#150)

* additional unit tests for remaining proxy functions (#149)

* add ocr2 spec changes, switch image repo (#152)

* Add gauntlet e2e tests through accepting a proposal (#141)

* Add a hello-world consumer example (#143)

* Add a hello-world consumer example

* wrap up consumer contract + test cases

* remove unneeded boilerplate - simplify mocked contract

Co-authored-by: aalu1418 <[email protected]>

* change env naming convention (#155)

* proxy cmds uses args[0] and pull aggregator from RDD (#148)

* add codeId for proxy_ocr2 testnet (#undefined)

* feat: update OCR2 spec examples (#154)

* Add Ocr2 Proxy E2E Test (#162)

* implement the contracts for proxy so we can deploy them

* Add ocr2 proxy test for latestRound, decimals, and description

* pkg/terra: add MsgEnqueuer.GetMsgs (#113)

* fix inspection bugs + improvements (#161)

* proxy monitoring stub

* move chain reader into its own file

* proxy source factory uses the proxy address. Also update corresponding
data generator for tests

* add prometheus exporter factory and test, along with metrics and mocks

* fix the issues reported by the linter

* bump chainlink-relay to get the panic recover feature from Source

* bump chainlink-relay dependency

* add support for monitoring feeds that don't have a proxy contract
configured

* fix url path for fetching transactions from FCD

* bump to the latest relay version where tx failed/succeeded metrics are
counters instead of gauges

* sequence requests to the terra rpc endpoint for all sources

* bump chainlink-relay

* introduce individual sequencers for TxsEvents and ContractStore

* bump chainlink-relay and add GetType to all the terra monitoring source

* fix go.sum

* Token commands + Improvements (#157)

* added balance diff in inspection

* transfer token and send uluna commands

* added mainnet ids

* refactor before execution

* refactor and improvements

* fix rebase

* Gauntlet sec improvements (#166)

* transfer ownership checks

* inpect offchain config from event info

* provider in execution context. minor improvements

* updated test

* hex to base64

* Update guantlet e2e test to use an rdd with all non zero false values so the inspect command can check all values have changed
No longer use the digest in the test as it is not needed

Co-authored-by: Tate <[email protected]>

* added cw20 code id and more validations

* small refactor

Co-authored-by: Tate <[email protected]>

* unit test: reverted payments do not change owed balance (#169)

* Payout oracles when set_billing is called (#168)

* fix: rename accept_proposal method attribute

* payout oracles when billing is set

* Support negative observations (#165)

* Use generic helper

* Add a test

* Placate linter

* Address comments

* Linter

* 30252 tx simulation (#159)

* 30252: TX Simulation method in AbstractCommand

* 30252: Adding isSimulate instruction field to all oc2 initialize flow commands

* 30252: Formatting

* 30252: Removing optional isSimulate field (i.e always simulate)

* 30252: Tx simulation for the arbitrary provided signer

* 30252: batch simulation

* 30252: tx simulation for multisig

* 30252: Adjusting simulation success message

* 30252: Formatting

* Fee coin bounds check (#172)

* Fee coin bounds check

* Sanity check reimbursement calc

* Cargo fmt

* include chain_id length in config digest (#173)

* include chain_id length in config digest

* validate length below uint8 max, test case assert error

* Providing raw proposal id for command input (#179)

* Multisig simulation: generating tx using provider instead of wallet to avoid default assignments (#178)

* drop the namespace from the logger

* make the proxy source fetch and export the link available for payments
of an aggregator contract

* remove the link_available_for_payments metric on cleaup

* ensure Client methods respect context cancel or expired

* bump chainlink-relay to get the fix on the balances/observations
precision

* More mocked sources for tests (#156)

* More mocked sources tests

* in progress

* Fix regex (#182)

* Feature/31183 settings diff (#171)

* added balance diff in inspection

* transfer token and send uluna commands

* added mainnet ids

* refactor before execution

* refactor and improvements

* transfer ownership checks

* inpect offchain config from event info

* added balance diff in inspection

* transfer token and send uluna commands

* added mainnet ids

* refactor before execution

* refactor and improvements

* fix rebase

* transfer ownership checks

* inpect offchain config from event info

* provider in execution context. minor improvements

* 31183: adding printDiff

* 31183: printDiff function

* 31183: getLatestOCRConfig function

* 31183: proposeConfig

* 31183: proposeOffchainConfig

* 31183: acceptProposal

* 31183: Small fixes based on the code review

* 31183: randomSecret requested while creating the proposal to guarantee deterministic check

* 31183: Cleanup

* 31183: Resolving conflicts with token-commands

* added cw20 code id and more validations

* 31183: longsToNumber into a separate function

* 31183: Updating inspect command with getLatestOCRConfig

* refactor encryptions to accept secret

* 31183: Adding payees to proposedConfig

* Update e2e gauntlet test to grab the offchain proposal secret from the report and use it in the accept proposal

* lint format

* 31183: make longsInObjToNumbers pure and add deepCopy implementation to utils

* 31183: Formatting

* 31183: Review implementation - reorderings, renamings, comments

Co-authored-by: RodrigoAD <[email protected]>
Co-authored-by: Tate <[email protected]>

* Add instructions for running the e2e tests to the readme (#174)

* Add instructions for running the e2e tests to the readme

* Move to docs and use readme link to it

* bring solana and terra more in sync

* Defaulting migrationContract to sender accAddress (#183)

* add prod testnet environment (#184)

* Add default rdd setting, and require for acceptOwnership

Minor changes related to -rdd gauntlet flag (suggested during multisig review):

1. Will default to "../reference-data-directory/directory-terra-mainnet.json" if not passed explicitly
2. acceptOwnership & transferOwnership will throw Error instead of warn, if there is no rdd flag

The first one should make it so the second one can never happen, but this
is better behavior just in case.  And it matches what most other commands already do.

* Update default multisig-proposal expiration time to 24 hours

* Expose payees on the set_config event

* Add a note regarding validation execution

* Fix event names in owned crate

* Fix CI by removing a non-working 'defaultFlags.rdd'

* copy all versions of cosmwasm to /lib

* upgrade contract codeIds to v0.1.5

* update testnet-internal and add new lines to all codeIds files

Co-authored-by: Domino Valdano <[email protected]>
Co-authored-by: Tate <[email protected]>
Co-authored-by: Blaž Hrastnik <[email protected]>
Co-authored-by: Rodrigo Ariza <[email protected]>
Co-authored-by: Sergei Drugalev <[email protected]>
Co-authored-by: Jordan Krage <[email protected]>
Co-authored-by: Sergey Kudasov <[email protected]>
Co-authored-by: alexandru topliceanu <[email protected]>
Co-authored-by: Frank Zhu <[email protected]>
Co-authored-by: aalu1418 <[email protected]>
Co-authored-by: Connor Stein <[email protected]>
Co-authored-by: Aaron Lu <[email protected]>
Co-authored-by: Rens Rooimans <[email protected]>
Co-authored-by: Gheorghe Strimtu <[email protected]>
Co-authored-by: Akhil Chainani <[email protected]>
  • Loading branch information
16 people authored Mar 8, 2022
1 parent 97f5b57 commit 5f2f32d
Show file tree
Hide file tree
Showing 149 changed files with 5,440 additions and 1,123 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/chaos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ jobs:
run: go mod download
- name: Install Ginkgo CLI
run: |
go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.0.0
go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.0.0
go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.0.0
go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.2
go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.2
go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.2
go install github.com/onsi/ginkgo/v2/ginkgo
- uses: actions/download-artifact@master
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ on:
type: string
cl_repo:
required: true
default: 795953128386.dkr.ecr.us-west-2.amazonaws.com/chainlink
default: public.ecr.aws/z0b1w9r9/chainlink
type: string
cl_image:
required: true
default: develop.latest
default: develop
type: string
secrets:
QA_AWS_ACCESS_KEY_ID:
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.direnv
.vscode
.idea
target/
artifacts/bin/
tarpaulin-report.html
Expand All @@ -10,11 +11,14 @@ node_modules
dist
.env
flow-report.json
report.json
.envrc
bin

# test
packages-ts/gauntlet-terra-contracts/codeIds/test*
packages-ts/gauntlet-terra-contracts/networks/.env.test*
tests/e2e/logs
networks/.env.test*
packages-ts/gauntlet-terra-contracts/networks/.env.test*
tests/e2e/smoke/rdd/directory*
tests/e2e/smoke/reports
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodejs 14.19.0
golang 1.17.6
golang 1.17.7
rust 1.58.1
36 changes: 19 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

members = [
"contracts/*",
"crates/*"
"crates/*",
"examples/hello-world",
]

[profile.dev]
Expand Down
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ download:
go mod download

install:
go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.0.0
go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.0.0
go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.0.0
go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.2
go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.2
go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.2
go install github.com/onsi/ginkgo/v2/ginkgo

build_js:
Expand Down Expand Up @@ -45,11 +45,24 @@ artifacts_clean_terrad:

build: build_js build_contracts

test_relay_unit:
go build -v ./pkg/terra/...
go test -v ./pkg/terra/...

test_smoke:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo -p -procs=2 tests/e2e/smoke
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo -p -procs=3 tests/e2e/smoke

test_ocr:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@ocr tests/e2e/smoke
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@ocr2 tests/e2e/smoke

test_ocr_proxy:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@ocr_proxy tests/e2e/smoke

test_migration:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo tests/e2e/migration

test_gauntlet:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@gauntlet tests/e2e/smoke

test_chaos:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo tests/e2e/chaos
22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# Chainlink Terra Integration
# Chainlink Terra

This repository is a monorepo of the various components required for Chainlink on Terra.
## Quick Start

- Terra Contracts (OCR2, ...)
- Terra CL Relay
- Terra Gauntlet
- Terra On-chain Monitoring
- Ops (infrastructure)
- Integration (tests)
- Demos & Examples

# Local asdf initial setup

asdf plugin-add golang https://github.com/kennyp/asdf-golang.git
# for other golang requirements for your os go to https://github.com/kennyp/asdf-golang
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin-add rust https://github.com/asdf-community/asdf-rust.git

# Then run
asdf install
For more information, see the [Chainlink Terra Documentation](./docs/).
25 changes: 21 additions & 4 deletions cmd/monitoring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
func main() {
ctx := context.Background()

log := logger.NewLogger().With("project", "terra")
coreLog := logger.NewLogger()
log := logWrapper{coreLog}

terraConfig, err := monitoring.ParseTerraConfig()
if err != nil {
Expand All @@ -24,15 +25,16 @@ func main() {
terraConfig.ChainID,
terraConfig.TendermintURL,
terraConfig.ReadTimeout,
log,
coreLog,
)
if err != nil {
log.Fatalw("failed to create a terra client", "error", err)
return
}
chainReader := monitoring.NewChainReader(client)

envelopeSourceFactory := monitoring.NewEnvelopeSourceFactory(
client,
chainReader,
log.With("component", "source-envelope"),
)
txResultsFactory := monitoring.NewTxResultsSourceFactory(
Expand All @@ -41,7 +43,7 @@ func main() {

entrypoint, err := relayMonitoring.NewEntrypoint(
ctx,
logWrapper{log},
log,
terraConfig,
envelopeSourceFactory,
txResultsFactory,
Expand All @@ -52,6 +54,21 @@ func main() {
return
}

proxySourceFactory := monitoring.NewProxySourceFactory(
chainReader,
log.With("component", "source-proxy"),
)
if entrypoint.Config.Feature.TestOnlyFakeReaders {
proxySourceFactory = monitoring.NewFakeProxySourceFactory(log.With("component", "fake-proxy-source"))
}
entrypoint.SourceFactories = append(entrypoint.SourceFactories, proxySourceFactory)

prometheusExporterFactory := monitoring.NewPrometheusExporterFactory(
log.With("component", "terra-prometheus-exporter"),
monitoring.NewMetrics(log.With("component", "terra-metrics")),
)
entrypoint.ExporterFactories = append(entrypoint.ExporterFactories, prometheusExporterFactory)

entrypoint.Run()
log.Info("monitor stopped")
}
Expand Down
50 changes: 47 additions & 3 deletions contracts/ocr2/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub fn execute_accept_proposal(

let proposal = PROPOSALS.load(deps.storage, id.u128().into())?;

let response = Response::new().add_attribute("method", "propose_config");
let response = Response::new().add_attribute("method", "accept_proposal");

// Only approve proposal if finalized
require!(proposal.finalized, InvalidInput);
Expand Down Expand Up @@ -451,6 +451,11 @@ pub fn execute_accept_proposal(
.iter()
.map(|(_, transmitter, _)| attr("transmitters", transmitter));

let payees = proposal
.oracles
.iter()
.map(|(_, _, payee)| attr("payees", payee));

response = response.add_event(
Event::new("set_config")
.add_attribute(
Expand All @@ -464,6 +469,7 @@ pub fn execute_accept_proposal(
.add_attribute("config_count", config.config_count.to_string())
.add_attributes(signers)
.add_attributes(transmitters)
.add_attributes(payees)
.add_attribute("f", proposal.f.to_string())
.add_attribute("onchain_config", Binary(onchain_config).to_base64())
.add_attribute(
Expand Down Expand Up @@ -505,6 +511,9 @@ pub fn execute_propose_config(
// validate new config
require!(f != 0, InvalidInput);
require!(signers_len <= MAX_ORACLES, TooManySigners);
// See corresponding comment https://github.com/smartcontractkit/chainlink-terra/blob/5c229358eea2633922de615be509eb47c5bcb998/pkg/terra/config_digester.go#L30
// If this requirement of len(transmitters) == len(signers) is removed, we'll need
// to update the config digester to include a length prefix on transmitters.
require!(transmitters.len() == signers.len(), InvalidInput);
require!(payees.len() == signers.len(), InvalidInput);
require!(3 * (usize::from(f)) < signers_len, InvalidInput);
Expand Down Expand Up @@ -626,6 +635,9 @@ fn validate_answer(deps: Deps, config: &Config, round_id: u32, answer: i128) ->
.answer;

Some(
// Validation happens in a submessage, which will "will revert any partial state changes due to this message,
// but not revert any state changes in the calling contract." This way the validator going over the gas limit
// or failing validation won't block publishing to the feed.
SubMsg::new(WasmMsg::Execute {
contract_addr: validator.address.to_string(),
msg: to_binary(&ValidatorMsg::Validate {
Expand Down Expand Up @@ -1129,7 +1141,7 @@ pub fn execute_set_billing_access_controller(
// ---

pub fn execute_set_billing(
deps: DepsMut,
mut deps: DepsMut,
_env: Env,
info: MessageInfo,
billing_config: Billing,
Expand All @@ -1145,10 +1157,17 @@ pub fn execute_set_billing(
Unauthorized
);

// payout oracles
let (_total, response) = pay_oracles(
&mut deps,
&config,
Response::new().add_attribute("method", "set_billing"),
)?;

config.billing = billing_config;
CONFIG.save(deps.storage, &config)?;

Ok(Response::default().add_event(
Ok(response.add_event(
Event::new("set_billing")
.add_attribute(
"recommended_gas_price_micro",
Expand Down Expand Up @@ -1522,6 +1541,7 @@ pub fn execute_accept_payeeship(
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use crate::Decimal;
use cosmwasm_std::testing::{
mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
};
Expand Down Expand Up @@ -1698,4 +1718,28 @@ pub(crate) mod tests {
let execute_info = mock_info("payee2", &[]);
execute(deps.as_mut(), mock_env(), execute_info, msg).unwrap();
}

#[test]
fn test_calculate_reimbursement() {
use std::str::FromStr;
let recommended_gas_price = Decimal::from_str("0.011000").unwrap();
let juels_per_fee_coin = u128::from_str("6000000000000000000").unwrap(); // 6e18 juels in 1 luna (i.e. 6 link)

// Sanity check
let r = calculate_reimbursement(
&Billing {
recommended_gas_price_micro: recommended_gas_price,
observation_payment_gjuels: 0,
transmission_payment_gjuels: 0,
gas_base: Some(84_000),
gas_per_signature: Some(17_000),
gas_adjustment: Some(140),
},
juels_per_fee_coin,
1,
);
// juels = ((gas_per_sig*sigcount + gas_base)*gas_price_uluna/1e6)*juels_per_fee_coin
// juels = ((1 * 17000 + 84000)*1.4*0.011/1e6)*6e18 = 9332400000000000
assert_eq!(Uint128::from_str("9332400000000000").unwrap(), r);
}
}
Loading

0 comments on commit 5f2f32d

Please sign in to comment.