Skip to content

Commit

Permalink
upgrade to lastest contractkit -- for better l2 compatability
Browse files Browse the repository at this point in the history
remove demurage / inflation test on Stable transfer e2e as that no longer exists
  • Loading branch information
aaronmgdr committed Aug 28, 2024
1 parent 0cca906 commit 73d682e
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 337 deletions.
2 changes: 1 addition & 1 deletion packages/celotool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"tiny-secp256k1": "2.2.1",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"web3": "1.10.0",
"web3": "1.10.4",
"web3-eth-admin": "1.0.0-beta.55",
"yargs": "17.7.2"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/celotool/src/cmds/deploy/upgrade/hotfix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This is a more unusual Celotool command. It basically helps you to execute Hotfixes on testnets. Because constructing proposals is difficult to do via a CLI, you should define them here in code. There are two examples below that you can start from.

import { newKitFromWeb3 } from '@celo/contractkit'
import { L1HotfixRecord } from '@celo/contractkit/lib/wrappers/Governance'
import { hotfixToHash, ProposalBuilder, proposalToJSON } from '@celo/governance'
import { privateKeyToAddress } from '@celo/utils/lib/address'
import { concurrentMap } from '@celo/utils/lib/async'
Expand Down Expand Up @@ -121,7 +122,9 @@ export const handler = async (argv: EthstatsArgv) => {
hotfixRecord = await governance.getHotfixRecord(proposalHash)
console.info('\nHotfix Record: ', hotfixRecord)

if (hotfixRecord.preparedEpoch.toNumber() === 0) {
// if this is actually used we need to handle the L2 case but that is out of scope for just upgrading ck

if ((hotfixRecord as L1HotfixRecord).preparedEpoch?.toNumber() === 0) {
console.error('Hotfix could not be prepared')
throw new Error()
}
Expand Down
3 changes: 2 additions & 1 deletion packages/celotool/src/cmds/generate/faucet-load-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StrongAddress } from '@celo/base'
import { newKit } from '@celo/contractkit'
import { switchToClusterFromEnv } from 'src/lib/cluster'
import { convertToContractDecimals } from 'src/lib/contract-utils'
Expand Down Expand Up @@ -65,7 +66,7 @@ export const handler = async (argv: CeloEnvArgv & FaucetLoadTest) => {
const kit = newKit('http://localhost:8545')
const account = (await kit.web3.eth.getAccounts())[0]
console.info(`Using account: ${account}`)
kit.defaultAccount = account
kit.defaultAccount = account as StrongAddress

const [goldToken, stableToken] = await Promise.all([
kit.contracts.getGoldToken(),
Expand Down
70 changes: 27 additions & 43 deletions packages/celotool/src/e2e-tests/cip35_tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StrongAddress } from '@celo/base'
import { CeloTx } from '@celo/connect'
import { ContractKit, newKitFromWeb3 } from '@celo/contractkit'
import { privateKeyToAddress } from '@celo/utils/lib/address'
Expand Down Expand Up @@ -26,7 +27,6 @@ const validatorPrivateKey = generatePrivateKey(mnemonic, AccountType.VALIDATOR,
const validatorAddress = privateKeyToAddress(validatorPrivateKey)
// Arbitrary addresses to use in the transactions
const toAddress = '0x8c36775E95A5f7FEf6894Ba658628352Ac58605B'
const gatewayFeeRecipientAddress = '0xc77538d1e30C0e4ec44B0DcaD97FD3dc63fcaCC4'

// Simple contract with a single constant
const bytecode =
Expand All @@ -47,8 +47,6 @@ const devFilter: Filter = {
ethCompatible: undefined,
contractCreation: undefined,
useFeeCurrency: undefined,
useGatewayFee: undefined,
useGatewayFeeRecipient: undefined,
sendRawTransaction: undefined,
}
/// ////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -65,8 +63,6 @@ interface TestCase {
ethCompatible: boolean
contractCreation: boolean
useFeeCurrency: boolean
useGatewayFee: boolean
useGatewayFeeRecipient: boolean
sendRawTransaction: boolean // whether to use eth_sendRawTransaction ot eth_sendTransaction
errorString: string | null
errorReason: string | null
Expand All @@ -88,38 +84,32 @@ function generateTestCases(cipIsActivated: boolean) {
for (const ethCompatible of getValues(devFilter.ethCompatible)) {
for (const contractCreation of getValues(devFilter.contractCreation)) {
for (const useFeeCurrency of getValues(devFilter.useFeeCurrency)) {
for (const useGatewayFee of getValues(devFilter.useGatewayFee)) {
for (const useGatewayFeeRecipient of getValues(devFilter.useGatewayFeeRecipient)) {
for (const sendRawTransaction of getValues(devFilter.sendRawTransaction)) {
let errorString: string | null = null
let errorReason: string | null = null
const hasCeloFields = useFeeCurrency || useGatewayFee || useGatewayFeeRecipient
if (ethCompatible && hasCeloFields) {
errorString = notCompatibleError
errorReason = 'transaction has celo-only fields'
} else if (ethCompatible && !cipIsActivated) {
errorString = notYetActivatedError
errorReason = 'Donut is not activated'
}
if (sendRawTransaction && ethCompatible && hasCeloFields) {
// Such scenarios don't make sense, since eth-compatible transactions in RLP can't have
// these fields. So skip these cases.
continue
}
cases.push({
cipIsActivated,
lightNode,
ethCompatible,
contractCreation,
useFeeCurrency,
useGatewayFee,
useGatewayFeeRecipient,
sendRawTransaction,
errorString,
errorReason,
})
}
for (const sendRawTransaction of getValues(devFilter.sendRawTransaction)) {
let errorString: string | null = null
let errorReason: string | null = null
const hasCeloFields = useFeeCurrency
if (ethCompatible && hasCeloFields) {
errorString = notCompatibleError
errorReason = 'transaction has celo-only fields'
} else if (ethCompatible && !cipIsActivated) {
errorString = notYetActivatedError
errorReason = 'Donut is not activated'
}
if (sendRawTransaction && ethCompatible && hasCeloFields) {
// Such scenarios don't make sense, since eth-compatible transactions in RLP can't have
// these fields. So skip these cases.
continue
}
cases.push({
cipIsActivated,
lightNode,
ethCompatible,
contractCreation,
useFeeCurrency,
sendRawTransaction,
errorString,
errorReason,
})
}
}
}
Expand Down Expand Up @@ -344,13 +334,7 @@ class TestEnv {
nonce: await this.kit.connection.nonce(validatorAddress),
}
if (testCase.useFeeCurrency) {
tx.feeCurrency = this.stableTokenAddr
}
if (testCase.useGatewayFee) {
tx.gatewayFee = '0x25'
}
if (testCase.useGatewayFeeRecipient) {
tx.gatewayFeeRecipient = gatewayFeeRecipientAddress
tx.feeCurrency = this.stableTokenAddr as StrongAddress
}

if (testCase.contractCreation) {
Expand Down
Loading

0 comments on commit 73d682e

Please sign in to comment.