Skip to content

Commit

Permalink
Merge branch 'main' into releases/v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Nov 12, 2024
2 parents 4bc072d + 04ccbcf commit ae2d85e
Show file tree
Hide file tree
Showing 31 changed files with 945 additions and 162 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/e2e-evm-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: EVM E2E Cron

on:
schedule:
- cron: '0 * * * *' # every hour at 00 min
# cron syntax: https://jasonet.co/posts/scheduled-actions/

jobs:
# The "evm-e2e-cron" job runs end-to-end tests on a schedule against instances
# of Nibiru to ensure core functionality remains stable. This is intended to
# highlight any outage or catch degredations in public endpoint functionality
# early. Failures trigger immediate Slack notifications to alert the team.
#
# This workflow:
# 1. Executes basic EVM integration tests against the testnet
# 2. Uses a dedicated test wallet (configured via secrets)
# 3. Reports failures to the testnet Slack channel
#
# Environment requirements:
# - WALLET_MNEMONIC_TESTNET: Secret for test wallet access
# - SLACK_WEBHOOK_TESTNET: Webhook URL for failure notifications
evm-e2e-cron:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: "Install just"
# casey/just: https://just.systems/man/en/chapter_6.html
# taiki-e/install-action: https://github.com/taiki-e/install-action
uses: taiki-e/install-action@just

- name: 'just install'
run: just install
working-directory: 'evm-e2e'

- name: 'Run tests (just test-basic)'
run: just test-basic
working-directory: 'evm-e2e'
# 2024-11-12: We're using the Testnet 1 validator account because it has
# a lot of funds in NIBI.
env:
JSON_RPC_ENDPOINT: https://evm-rpc.testnet-1.nibiru.fi
MNEMONIC: ${{ secrets.MNEMONIC_TESTNET1_VALIDATOR }}

- name: Send failure to slack channel
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: 'failure'
notification_title: 'EVM basic tests failed on Testnet'
message_format: '{emoji} *{workflow}* {status_message} Run: {run_url}'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ about the expected resulting balance for the transfer recipient.
- [#2092](https://github.com/NibiruChain/nibiru/pull/2092) - feat(evm): add validation for wasm multi message execution
- [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling
- [#2105](https://github.com/NibiruChain/nibiru/pull/2105) - test(evm): precompile call with revert
- [#2106](https://github.com/NibiruChain/nibiru/pull/2106) - chore: scheduled basic e2e tests for evm testnet endpoint
- [#2107](https://github.com/NibiruChain/nibiru/pull/2107) -
feat(evm-funtoken-precompile): Implement methods: balance, bankBalance, whoAmI
- [#2108](https://github.com/NibiruChain/nibiru/pull/2108) - fix(evm): removed deprecated root key from eth_getTransactionReceipt
- [#2110](https://github.com/NibiruChain/nibiru/pull/2110) - fix(evm): Restore StateDB to its state prior to ApplyEvmMsg call to ensure deterministic gas usage. This fixes an issue where the StateDB pointer field in NibiruBankKeeper was being updated during readonly query endpoints like eth_estimateGas, leading to non-deterministic gas usage in subsequent transactions.
- [#2111](https://github.com/NibiruChain/nibiru/pull/2111) - fix: e2e-evm-cron.yml

#### Nibiru EVM | Before Audit 1 - 2024-10-18

Expand Down
3 changes: 2 additions & 1 deletion eth/rpc/backend/account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func (b *Backend) GetProof(
}

Check warning on line 61 in eth/rpc/backend/account_info.go

View check run for this annotation

Codecov / codecov/patch

eth/rpc/backend/account_info.go#L59-L61

Added lines #L59 - L61 were not covered by tests
ctx := rpc.NewContextWithHeight(height)

// if the height is equal to zero, meaning the query condition of the block is either "pending" or "latest"
// if the height is equal to zero, meaning the query condition of the block
// is either "pending" or "latest"
if height == 0 {
bn, err := b.BlockNumber()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions eth/rpc/backend/tx_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ func (r *TransactionReceipt) MarshalJSON() ([]byte, error) {
if r.EffectiveGasPrice != nil {
output["effectiveGasPrice"] = r.EffectiveGasPrice
}
// delete deprecated (pre Byzantium) key which is always set to 0x and fails parsing within hardhat
delete(output, "root")

return json.Marshal(output)
}

Expand Down
15 changes: 9 additions & 6 deletions eth/rpc/rpcapi/eth_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ func (s *NodeSuite) Test_BlockNumber() {

ethBlockNumber, err := s.ethClient.BlockNumber(context.Background())
s.NoError(err)
s.Equal(networkBlockNumber, int64(ethBlockNumber))
// It might be off by 1 block in either direction.
blockDiff := networkBlockNumber - int64(ethBlockNumber)
s.Truef(blockDiff <= 2, "networkBlockNumber %d, ethBlockNumber %d",
networkBlockNumber, ethBlockNumber,
)
}

// Test_BlockByNumber EVM method: eth_getBlockByNumber
Expand Down Expand Up @@ -366,11 +370,10 @@ func (s *NodeSuite) Test_SmartContract() {
txHash, err := s.ethAPI.SendRawTransaction(txBz)
s.Require().NoError(err)

s.T().Log("Assert: tx IS pending just after execution")
pendingTxs, err := s.ethAPI.GetPendingTransactions()
s.NoError(err)
s.Require().Len(pendingTxs, 1)
_ = s.network.WaitForNextBlock()
s.T().Log("Wait a few blocks so the tx won't be pending")
for i := 0; i < 5; i++ {
_ = s.network.WaitForNextBlock()
}

s.T().Log("Assert: tx NOT pending")
{
Expand Down
4 changes: 4 additions & 0 deletions evm-e2e/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ install:
test:
npm test

# Runs tx receipt tests. Used for testnet quick check.
test-basic:
npm test -- tx_receipt.test.ts

# Format
fmt:
npm run format
2 changes: 1 addition & 1 deletion evm-e2e/test/tx_receipt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Transaction Receipt Tests', () => {
let recipient = ethers.Wallet.createRandom().address;

it('simple transfer receipt', async () => {
const value = ethers.parseEther('1');
const value = ethers.parseEther('0.0001');
const tx = await account.sendTransaction({
to: recipient,
value,
Expand Down
137 changes: 136 additions & 1 deletion x/evm/embeds/artifacts/contracts/IFunToken.sol/IFunToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,110 @@
"contractName": "IFunToken",
"sourceName": "contracts/IFunToken.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "who",
"type": "address"
},
{
"internalType": "address",
"name": "funtoken",
"type": "address"
}
],
"name": "balance",
"outputs": [
{
"internalType": "uint256",
"name": "erc20Balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "bankBalance",
"type": "uint256"
},
{
"components": [
{
"internalType": "address",
"name": "erc20",
"type": "address"
},
{
"internalType": "string",
"name": "bankDenom",
"type": "string"
}
],
"internalType": "struct IFunToken.FunToken",
"name": "token",
"type": "tuple"
},
{
"components": [
{
"internalType": "address",
"name": "ethAddr",
"type": "address"
},
{
"internalType": "string",
"name": "bech32Addr",
"type": "string"
}
],
"internalType": "struct IFunToken.NibiruAccount",
"name": "whoAddrs",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "who",
"type": "address"
},
{
"internalType": "string",
"name": "bankDenom",
"type": "string"
}
],
"name": "bankBalance",
"outputs": [
{
"internalType": "uint256",
"name": "bankBalance",
"type": "uint256"
},
{
"components": [
{
"internalType": "address",
"name": "ethAddr",
"type": "address"
},
{
"internalType": "string",
"name": "bech32Addr",
"type": "string"
}
],
"internalType": "struct IFunToken.NibiruAccount",
"name": "whoAddrs",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand All @@ -21,7 +125,7 @@
"type": "string"
}
],
"name": "bankSend",
"name": "sendToBank",
"outputs": [
{
"internalType": "uint256",
Expand All @@ -31,6 +135,37 @@
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "who",
"type": "string"
}
],
"name": "whoAmI",
"outputs": [
{
"components": [
{
"internalType": "address",
"name": "ethAddr",
"type": "address"
},
{
"internalType": "string",
"name": "bech32Addr",
"type": "string"
}
],
"internalType": "struct IFunToken.NibiruAccount",
"name": "whoAddrs",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x",
Expand Down
Loading

0 comments on commit ae2d85e

Please sign in to comment.